Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 10:37 Go to next message
riya williams is currently offline riya williamsFriend
Messages: 2
Registered: July 2018
Junior Member
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 21:40 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3880
Registered: July 2009
Senior Member

This isn't a general programming forum. Try StackOverflow.com instead.

Nitin Dahyabhai
Eclipse Web Tools Platform
Re: Hierarchy of models while designing a client for a RESTful service [message #1796806 is a reply to message #1796004] Fri, 19 October 2018 07:04 Go to previous message
Carlon Sins is currently offline Carlon SinsFriend
Messages: 3
Registered: October 2018
Junior Member
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: Tue Oct 27 07:28:27 GMT 2020

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

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

Back to the top