user3778893
user3778893

Reputation: 125

Rest WebService for performing business operation

As I've read, Rest is used for create/update/delete/get of Resource using PUT/POST/DELETE/GET method.

Now Let's say, I've to expose a service which take 'price' and 'date' as request and it calculates 'service tax', 'sb cess', 'krishikalyalcess' on 'price' and 'date'. Api doesn't store/upate/delete anything in database/storage. I can easily do it using rest method in controller which takes request and provides desired response, and I can perform calculation of taxes and cess in that method.

My question is - I'll work fine. But does it come under REST as request ('price' and 'date') are neighter resource nor they are doing any CRUD operation in database/storage.

Please help me understand State transfer of Resource and Calling Business oriented method using REST.

Thanks,

Upvotes: 0

Views: 70

Answers (2)

cjungel
cjungel

Reputation: 3781

I suggest reading Richardson Maturity Model.

A model (developed by Leonard Richardson) that breaks down the principal elements of a REST approach into three steps. These introduce resources, http verbs, and hypermedia controls.

Upvotes: 1

Naros
Naros

Reputation: 21113

I believe you're intepreting RESTful web services too literal.

Developers expose RESTful web services for a variety of reasons. Sure, one of the most known is to take the HTTP verbs PUT, POST, DELETE, and GET and couple those based on some defined input resource to perform a specific action related to the CRUD-paradigm. But that isn't the only way to interpret a RESTful web service nor does a RESTful service have to interact specifically with some database.

The resource in your case is the calculation. What you are doing is exposing the calculation so that providing a series of inputs allows any external source to obtain a calculated value in a standard, highly accepted pattern.

Upvotes: 1

Related Questions