Re: [Architecture] Updating 5 star rating to 10 star rating

2018-09-04 Thread Sanjeewa Malalgoda
On Wed, Sep 5, 2018 at 9:47 AM Nuwan Dias  wrote:

>
>
> On Tue, Sep 4, 2018 at 9:44 PM Chanaka Jayasena  wrote:
>
>> Hi,
>>
>> I am updating API rating from 5 star rating to 10 star rating base on the
>> set of usability improvements we are planning for store.
>>
>
> When migrating from API Manager 2 to 3, this would mean that we have to
> multiply the rating value from 2 to fit into the 10 start rating scale.
>
>>
>> I am also updating the Rest API to support the same.
>>
>> Get operation of rating API is returning the following object format.
>>
>>1. avgRating:"4"
>>2. count:1
>>3. list:[{…}]
>>4. userRating:"4"
>>
>> Put operation to the Rating api returns the following.
>>
>>1. rating: 5
>>2. ratingId:"5f31ff42-1bc0-4295-8123-189dd34499dc"
>>3. username:"admin"
>>
>> Returning the userRating along with the response of the PUT operation
>> will remove the need for a second call to get the average rating to update
>> the UI.
>>
>> Will it break the RESTFull ness of the API, if I do this change?
>>
>
> I don't think so. If the GET operation returns the userRating I guess its
> fine for the PUT operation to return it too.
>
> Why are the responses of the GET and PUT operations very different? Ex:
> count, list are missing in PUT, ratingId is missing in GET.
>
Usually GET and PUT operations performed on atomic resources. So in such
cases user already know rating ID. But there can be situations where PUT
operation perform on resource collection. If the Request-URI refers to an
already existing atomic resource, the entity should be considered as a
modified version of the one residing on the server(in that case it can
return or not resource ID as client already know that). If the Request-URI
does not point to an existing resource, and that URI is capable of being
defined as a new resource by the requesting user agent, the origin server
can create the resource with that URI. In this case also client knows UUID.
I think in chanakas example put method request need to place on behalf of
rating user(to change his rating). And technically its not mandatory to
return anything. But if need it should return same response as get do.

Thanks,
sanjeewa

>
>> thanks,
>> Chanaka
>> --
>> Chanaka Jayasena
>> Associate Tech Lead,
>> email: chan...@wso2.com; cell: +94 77 4464006
>> blog: http://chanaka3d.blogspot.com
>>
>
>
> --
> Nuwan Dias
>
> Director - WSO2, Inc. http://wso2.com
> email : nuw...@wso2.com
> Phone : +94 777 775 729
>


-- 
*Sanjeewa Malalgoda*
WSO2 Inc.
Mobile : +94 712933253

blog
:http://sanjeewamalalgoda.blogspot.com/

___
Architecture mailing list
Architecture@wso2.org
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture


Re: [Architecture] Updating 5 star rating to 10 star rating

2018-09-04 Thread Nuwan Dias
On Tue, Sep 4, 2018 at 9:44 PM Chanaka Jayasena  wrote:

> Hi,
>
> I am updating API rating from 5 star rating to 10 star rating base on the
> set of usability improvements we are planning for store.
>

When migrating from API Manager 2 to 3, this would mean that we have to
multiply the rating value from 2 to fit into the 10 start rating scale.

>
> I am also updating the Rest API to support the same.
>
> Get operation of rating API is returning the following object format.
>
>1. avgRating:"4"
>2. count:1
>3. list:[{…}]
>4. userRating:"4"
>
> Put operation to the Rating api returns the following.
>
>1. rating: 5
>2. ratingId:"5f31ff42-1bc0-4295-8123-189dd34499dc"
>3. username:"admin"
>
> Returning the userRating along with the response of the PUT operation will
> remove the need for a second call to get the average rating to update the
> UI.
>
> Will it break the RESTFull ness of the API, if I do this change?
>

I don't think so. If the GET operation returns the userRating I guess its
fine for the PUT operation to return it too.

Why are the responses of the GET and PUT operations very different? Ex:
count, list are missing in PUT, ratingId is missing in GET.

>
> thanks,
> Chanaka
> --
> Chanaka Jayasena
> Associate Tech Lead,
> email: chan...@wso2.com; cell: +94 77 4464006
> blog: http://chanaka3d.blogspot.com
>


-- 
Nuwan Dias

Director - WSO2, Inc. http://wso2.com
email : nuw...@wso2.com
Phone : +94 777 775 729
___
Architecture mailing list
Architecture@wso2.org
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture


[Architecture] Updating 5 star rating to 10 star rating

2018-09-04 Thread Chanaka Jayasena
Hi,

I am updating API rating from 5 star rating to 10 star rating base on the
set of usability improvements we are planning for store.

I am also updating the Rest API to support the same.

Get operation of rating API is returning the following object format.

   1. avgRating:"4"
   2. count:1
   3. list:[{…}]
   4. userRating:"4"

Put operation to the Rating api returns the following.

   1. rating: 5
   2. ratingId:"5f31ff42-1bc0-4295-8123-189dd34499dc"
   3. username:"admin"

Returning the userRating along with the response of the PUT operation will
remove the need for a second call to get the average rating to update the
UI.

Will it break the RESTFull ness of the API, if I do this change?

thanks,
Chanaka
-- 
Chanaka Jayasena
Associate Tech Lead,
email: chan...@wso2.com; cell: +94 77 4464006
blog: http://chanaka3d.blogspot.com
___
Architecture mailing list
Architecture@wso2.org
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture