Question

I am trying to design my Class Diagram. But I get stuck on this one.

I have already created all database corresponding models. But this time I need to create a model for Amazon API with no corresponding database for it.

When creating a model for the database I use CActiveRecord. But for this one I dont know which one I can extend from. Look at this CWebService:

This is for SOAP, but the Amazon Product API uses REST.

So the question is, when creating a model to call a REST API which class I need to extend from?

EDIT: I do NOT want to create a REST API. I want to CALL a REST API and write a class for that.

Was it helpful?

Solution

Use the ActiveResource extension for Yii. Also indicated to you by bool.dev.

Now for instance if you want to get details about certain product you GET http://api.am.com/prodcut //(just a dummy url for reference)

The models you need to create will need to satisfy/handle the data being returned to you. If you are displaying the returned data in a Form extend from CFormModel. if you are not showing it in a Form extend from CModel to create a data model.

For example if you are just showing the data in a table view you can create a model for product like so: class product extends CModel

Hope this helps unless I misunderstood your problem

(I was gonna post this as a comment but thought it was too long for the comment).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top