jeudi 15 juin 2017

Creating an Ember Data Adapter to Pull from Flickr API

I'm working on building an Ember App that needs to pull in photo information using the Flickr API. I'd like some advice on how to write an adapter to pull this information into my Ember app. My call to the Flickr API returns a JSON of the form:

{
"photos": {
    "page": 1,
    "pages": 2,
    "perpage": 100,
    "total": "123",
    "photo": [
        {
            "id": "1234567890",
            "owner": "1234567@123",
            "secret": "1234567890",
            "server": "1111",
            "farm": 1,
            "title": "Some Title",
            "ispublic": 1,
            "isfriend": 0,
            "isfamily": 0
        },...
        ]
    },
 "stat": "ok"
}

Based on the format of this response, I've determined that I cannot use the JSONAPIAdapter and must use a RESTAdapter. The only part of the response that I'm really interested in is the photo array. This portion of the response also seems to be properly formatted to fit an Ember Data model because it provides an id for a primary key. I've spent a good bit of time looking through the docs to find a solution to this problem, but I am still very confused as to how these adapters and serializers work. What steps would I need to take to customize my adapter to properly pull this data into a photo model? Thank you in advance.




Aucun commentaire:

Enregistrer un commentaire