Skip to content

Instantly share code, notes, and snippets.

@nwgambee
Last active November 5, 2021 18:02
Show Gist options
  • Save nwgambee/31d66670a2b4fc8ed6f78221a0cfaa34 to your computer and use it in GitHub Desktop.
Save nwgambee/31d66670a2b4fc8ed6f78221a0cfaa34 to your computer and use it in GitHub Desktop.
CP SWP Call + Response Requests

CarePenguin Support Web Portal New Calls

Endpoint for an admin to hit when they deactivate an account from the SWP

Method: DELETE 
Path: /user/:user_id/delete (Nick has set this up for users to deactivate themselves already)
Content-Type: application/json
Body: {}

Responses:

  • 200 Success
{ 
data: { userID: 456, name: 'Noah', deactivated: true }
}

Endpoint for an admin to hit when they archive a sensor from the SWP

Method: DELETE 
Path: /sensor/:sensor_id/delete
Content-Type: application/json
Body: {}

Responses:

  • 200 Success
{ 
data: { sensorID: 54545, name: 'Grandpa's sensor', archived: true }
}

Endpoint for an admin to search for a user (via phone, name, or email)

Submit search request

Method: POST 
Path: /users/search
Content-Type: application/json
Body: JSON.stringify({
        queryString: 'gambee',
      }),

Responses:

  • 200 Success
{ 
data: [{ name: 'Noah Gambee', phone: '5555555555', email: '[email protected]', userID: 123 }, {  name: 'Tony Gambee', phone: '4555555555', email: '[email protected]', userID: 321}]
}
  • 200 but no results
{ 
data: []
}

Endpoint for an admin to edit account/sensor/location details ie: email/phone/name sensor_name/location_name

edit user info:

Method: PATCH 
Path: /user/:id
Content-Type: application/json-patch+json
Body: {
"patches" : [
  {
    "op" : "replace",
    "path" : "/email",
    "value" : "[email protected]"
  },
  {
    "op" : "replace",
    "path" : "/phone",
    "value" : "3035558739"
  }
 ]
}

edit location details:

Method: PATCH 
Path: /location/:location_id
Content-Type: application/json-patch+json
Body: {
"patches" : [
  {
    "op" : "replace",
    "path" : "/name",
    "value" : "Grandpa Joe's House"
  },
 ]
}

edit sensor details:

Method: PATCH 
Path: /sensor/:sensor_id
Content-Type: application/json-patch+json
Body: {
"patches" : [
  {
    "op" : "replace",
    "path" : "/name",
    "value" : "Grandpa's Water Heater"
  },
 ]
}

Endpoint for admin to fetch sensor/graph data (assuming we aren't using the non-admin endpoint that already does this)

Method: GET 
Path: /location/:location_id/data?=useCumulativeEvents=false&downsample=5.minute
Content-Type: application/json

Responses:

  • 200 Success
{ 
data: {sensors: [{ name: 'Grandpa's water heater', id: 53863, sensorData: [...] }]}
}

Endpoint for admin to login as a user into the CWP

Method: POST 
Path: /user/:user_id/login
Content-Type: application/json

Responses:

  • 200 Success
{ 
data: {userID: 123, name: 'Noah Gambee', phone: '555555555', email: '[email protected]'}
}
  • 404
{
errors: ['Unable to locate user with ID: 123']
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment