Skip to main content



      Home
Home » Language IDEs » Eclipse Web Tools Platform Project (WTP) » Hierarchy of models while designing a client for a RESTful service(RESTful API service)
Hierarchy of models while designing a client for a RESTful service [message #1795319] Thu, 20 September 2018 06:37 Go to next message
Eclipse UserFriend
I am trying to write a client for a restful service. I am confused in designing the models. Below are the details:

I have a Model named UnicastMessageRequest, it's definition is like this:

public class/abstract-class/interface UnicastMessageRequest
{
public string tId { get; set; }
public IDictionary<string, object> tVariables { get; set; }
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public CommunicationMedium communicationMedium { get; set; }
public IList<MessageAttachment> messageAttachments { get; set; }
public string to { get; set; }
}
I am not sure about making this class as a concrete class or abstract class or an interface, so right now I wrote the type as class/abstract class/interface.

This above model has the properties which I need to send as a body in an HTTP post request.

Now, I am performing different functions like sending email, sending SMS or sending WhatsApp message by hitting the same HTTP end point which needs the above defined UnicastMessageRequest model as the body of the request.

So, for convenience, I was thinking to write Wrapper data models for Email request, WhatsApp request and SMS request.

properties like tId, tVariables communicationMedium and to is necessary for all the request body, but messageAttachment isn't necessary.

Example of a EmailRequest model:

public class EmailRequest
{
public string tId { get; set; }
public IDictionary<string, object> tVariables { get; set; }
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public CommunicationMedium communicationMedium { get; set; }
public IList<MessageAttachment> messageAttachments { get; set; }
public string to { get; set; }
}
Example of a SMSRequest model:

public class EmailRequest
{
public string tId { get; set; }
public IDictionary<string, object> tVariables { get; set; }
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public CommunicationMedium communicationMedium { get; set; }
public string to { get; set; }
}
Here messageAttachments isn't required at all. Similarly, I have a WhatsAppRequest model. All these request model needs to be finally converted into the UnicastMessageRequest so that they can call a common API something like:

SendUnicastMessage(UnicastMessageRequest request)

How to design it the best way?

Regards,
Riya.
Api testinghttps://tekslate.com/api-testing-training/
Re: Hierarchy of models while designing a client for a RESTful service [message #1796004 is a reply to message #1795319] Wed, 03 October 2018 17:40 Go to previous messageGo to next message
Eclipse UserFriend
This isn't a general programming forum. Try StackOverflow.com instead.
Re: Hierarchy of models while designing a client for a RESTful service [message #1796806 is a reply to message #1796004] Fri, 19 October 2018 03:04 Go to previous message
Eclipse UserFriend
Exactly this forum is not for the programming you can try the web development forums instead of this.
Previous Topic:Making Jetty work with Wordpress on separate server (? right forum?)
Next Topic:Eclipse Oxygen Create Web Service for CXF 3.2 6 using wizard
Goto Forum:
  


Current Time: Sun Jul 27 02:23:54 EDT 2025

Powered by FUDForum. Page generated in 0.21173 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top