1

I can see in the payload JSON that the pubsub notification includes the events but is it also capable of sending the activity or sleep amounts (e.g steps or sleep minutes)?

RAY
  • 474
  • 4
  • 21

1 Answers1

1

No, the pubsub notification will only include the user and the list of events that took place. You can then use this information to query the APIs that pertain to those specific types of events.

For example, suppose you receive the following pubsub notification:

{
    "notification_timestamp": "1372787949",
    "events": [
        {
            "user_xid": "RGaCBFg9CsB83FsEcMY44A",
            "event_xid": "EJpCkyAtwoO0XTdkYyuTNw",
            "type": "move",
            "action": "creation" , 
            "timestamp": "1372787849"
        },
        {
            "user_xid": "RGaCBFg9CsB83FsEcMY44A",
            "event_xid": "blaHyAtwoO0XTdkYyuTNw",
            "type": "sleep",
            "action": "updation" , 
            "timestamp": "1372787859"
        }
    ],
    "secret_hash": "e570b3071a0964f9e2e69d13nd9ba19535392aaa",
}

Then you know that a move event was created and that a sleep event was updated for the user specified by user_xid: RGaCBFg9CsB83FsEcMY44A

Use this user's xid to determine which previously saved access_token to send with your next API requests.

You can get the details for the move event by sending a request to the moves endpoint with the event_xid: EJpCkyAtwoO0XTdkYyuTNw:

GET https://jawbone.com/nudge/api/v.1.1/moves/EJpCkyAtwoO0XTdkYyuTNw

And yo ucan get the details for the sleep event by querying the sleeps endpoint with the event_xid: blaHyAtwoO0XTdkYyuTN:

GET https://jawbone.com/nudge/api/v.1.1/sleeps/blaHyAtwoO0XTdkYyuTN
RAY
  • 474
  • 4
  • 21
  • Hi Ray, One question is how do I get the previously saved access token based on the user's xid. – Pushparaj Samant Nov 29 '16 at 03:18
  • You would have had to save the access token when the user completed the OAuth flow. After authenticating the user, you can call the user endpoint (https://jawbone.com/up/developer/endpoints/user) to get details like the XID--the user's XID is also returned in the "meta" field of every API call. – RAY Nov 30 '16 at 18:20
  • Another alternative to saving based on XID would be to create a user-specific webhook for PubSub notifications (https://jawbone.com/up/developer/pubsub and look for Programmable Webhooks). The webhook's URL should contain a way for you to identify the user and look up the previously saved access token that way. – RAY Nov 30 '16 at 18:24