Skip to content

Instantly share code, notes, and snippets.

@joshco
Last active April 4, 2019 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshco/2f30c790c7887ac1e1e50ac6c6fd8695 to your computer and use it in GitHub Desktop.
Save joshco/2f30c790c7887ac1e1e50ac6c6fd8695 to your computer and use it in GitHub Desktop.
Spoke OSDI Endpoint

I've built on Larry Person's work and modified his pull request to retrieve spoke contacts as OSDI people, as well as take batched uploaded contacts. I've put a dev server up, you can play with. Whee...

Check it out online

Go Here

http://spoke.dev.joshco.org/hal/browser.html#http://spoke.dev.joshco.org/osdi/org/1/campaigns/1/api/v1/

This should bring up the olde trusty HAL browser pointed at an organization and campaign. In the Custom Request Headers box, put

OSDI-API-Token: osdi_rocks

You can browse the OSDI people, aka campaign contact collection in Spoke. Code Branch https://github.com/joshco/Spoke/tree/osdi_contacts

People Signup Helper

I've riffed on the OSDI Person Signup Helper with another attribute "people" which takes an array of people to sign up in one shot. It reuses Larry's validation, so you'll get back status.

POST http://spoke.dev.joshco.org/osdi/org/1/campaigns/1/api/v1/contacts
Content-Type: application/json

{
  "people": [
      "given_name": "loooooLawrence",
      "family_name": "Woodard",
      "phone_numbers": [
        {
          "number_type": "Mobile",
          "number": "+16462321001",
          "sms_capable": true
        }
      ]
[....snip....]

Response with invalid record

{
  "invalid": [
    {
      "first_name": "Scott",
      "last_name": "Williams",
      "email": "scott.williams@fake.osdi.info",
      "cell": null,
      "zip": "10011"
    }
  ],
  "dupes_in_batch": 0,
  "number_submitted": 9,
  "dupes_in_campaign": 8,
  "opted_out": 0,
  "added": 0
} 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment