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

Initialize Resource without a request (from json api formatted streaming events) #174

Open
blakecash opened this issue Mar 7, 2016 · 2 comments

Comments

@blakecash
Copy link

I'm consuming a streaming api and events are coming over in text/event-stream format but the message in the event stream data key is in json api format. Is it possible to use this gem to initialize a resource from the json api formatted json?

Example event:

event: "event_name"
data: { "data":{ "id":"1", "type":"items", "links":{"self":"/api/v1/items/1"}, "attributes": { "foo":  "bar" } }

After the event message is parsed I'm left with the json api formatted json below.

{
  "data":{
  "id":"1",
  "type":"items",
  "links":{"self":"/api/v1/items/1"},
  "attributes": {
    "foo":  "bar"
  }
}

If I have an Item < JsonApiClient::Resource class is it possible to initialize it from the json above?

@blakecash blakecash changed the title Initialize resource without request from json api formatted json (from Streaming api) Initialize resource from Streaming api events Mar 7, 2016
@blakecash blakecash changed the title Initialize resource from Streaming api events Initialize Resource without a request (from json api formatted streaming events) Mar 7, 2016
@lmbautista
Copy link

Hi @blakecash , how is it going?

Did you finally achieve what you asked for? My team is trying to do something similar to use Redis with our client App to store the API call result.

Thanks in advice!

@adis-io
Copy link
Contributor

adis-io commented Feb 26, 2017

+1

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

3 participants