Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a custom adapter or adapter for deployd #48

Closed
taras opened this issue Aug 2, 2013 · 3 comments
Closed

Creating a custom adapter or adapter for deployd #48

taras opened this issue Aug 2, 2013 · 3 comments

Comments

@taras
Copy link
Contributor

taras commented Aug 2, 2013

deployd.com is a tool that provides RESTful APIs for custom models. I'd like to use it but has a slightly different API layout than Ember Data expects. For example, the returned JSON is not wrapped in hash, ie:

[
{ "id": "30", "name": "Hello World!" }
]

Not

{ 
    "items": [
        { "id": 30, "name": "Hello World!" } 
   ]
}

Are there any considerations for this in EPF? anything in particular that is relevant to building a custom adapter for this kind of an API?

@taras
Copy link
Contributor Author

taras commented Aug 4, 2013

I started to do and its pretty easy to do so far. You can see this Gist https://gist.github.com/taras/87c3c112ed5a2b17d791

I haven't done relationships yet, but basic CRUD functionality is working. Most of the work is removing and adding type wrapper around the payload.

One thing to note, I had to copy create & update functions because I couldn't modify the data that was used to make a request. It would be clearer to handle that via a callback ( possibly to the serializer )

@ghempton
Copy link
Contributor

ghempton commented Aug 6, 2013

I'm glad you got somewhere with this! Another way to do this would be to move a lot of this logic into your custom serializer. At a high level, serializer.deserialize should just returns a collection of models and you can create those models however you want based off of the JSON. You can also set isDeleted and errors to indicate more than just loading.

Someday I will get around to cleaning up/documenting the serializer API.

@taras
Copy link
Contributor Author

taras commented Aug 6, 2013

I realized that I can use serializer.deserialize about half way through it. I'm going to keep working on this and if I use it long enough then I'll turn it into a module that others will be able to use.

Thank you for EPF, its a pleasure to work with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants