Skip to content

Instantly share code, notes, and snippets.

@fespinoza
Last active January 12, 2017 14:33
Show Gist options
  • Save fespinoza/556386f93f7c36a1b1d5b3e5a7d53584 to your computer and use it in GitHub Desktop.
Save fespinoza/556386f93f7c36a1b1d5b3e5a7d53584 to your computer and use it in GitHub Desktop.
Webhook proposal

Update/Create/Delete Group

  • which group associations do we include? parents, children, both? how many?
  • what if the associated groups are not yet created: order of request matter

Request

Url

POST https://cubus.motimateapp.com/api/webhooks/mychain

Headers

Authorization: Basic base64encodedpassword

Body

{
  "event": {
    "type": "create",
    "id": "UUUID-XXXXXXXXXX"
  },
  "resource": {
    "type": "course"
    "id":  3505,
  },
  "group": {
    "import_id": "internal_id_3505"
    "name": "MyChain team",
    "level": "level_4",
    "enabled": true
  }
  "group_associations": [
    {
      "origin_import_id": "internal_id_3505",
      "destination_import_id": "internal_id_3935",
      "kind":"parent-child",
    }
  ]
}

Response

Status

200

Headers

Body

{}

Updating/Creating/Deleting an user

  • when do we fire the request?

    • on each update?
      • what about when updating stuff like invited_at
  • what about for groups and memberships, do we send that together?

  • what about groups that don't have import id?

Request

Url

POST https://cubus.motimateapp.com/api/webhooks/mychain

Headers

Authorization: Basic base64encodedpassword

Body

{
  "event": {
    "type": "update",
    "id": "UUUID-XXXXXXXXXX"
  },
  "resource": {
    "type": "user",
    "id": 74
  },
  "user": {
    "email": "tony@hyper.no",
    "employee_number": "000",
    "role": "system_admin",
    "phone_number": "+47XXXXXX",
    "first_name": "Tony",
    "last_name": "Stark",
    "middle_name": "",
    "status": "active"
  },
  "group_memberships": [
    { "role": "member",  "group_import_id": "country_NO"},
    { "role": "member",  "group_import_id": "internal_id_3465"},
    { "role": "member",  "group_import_id": "internal_id_3466"},
    { "role": "member",  "group_import_id": "internal_id_3467"},
    { "role": "member",  "group_import_id": "internal_id_3468"},
    { "role": "member",  "group_import_id": "internal_id_3469"},
    { "role": "member",  "group_import_id": "country_SE"},
    { "role": "member",  "group_import_id": "country_FI"}
  ]
}

Response

Status

200

Headers

Body

{}
@fespinoza
Copy link
Author

this to notice:

  • some group membership have group_import_id equal to internal_id_XXXX, those are groups that were not imported into MyChain, so they don't have an import_id. So i compute one from their id.
  • Authorization is thought using HTTP Basic Auth, i think it's ok since it's under https and at least i am not that clear regarding OAuth for identifying apps.
  • is possible to create a new model Event to keep record of the events sent from MyChain to Motimate.

@fespinoza
Copy link
Author

the response body is empty as it's common with other webhook endpoints

@fespinoza
Copy link
Author

on the motimate side, everything will be marked as imported

@fespinoza
Copy link
Author

at least my initial idea is to have just one endpoint to handle all the webhooks necessary POST https://cubus.motimateapp.com/api/webhooks/mychain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment