Skip to content

Instantly share code, notes, and snippets.

@tombola
Last active November 4, 2021 12:15
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 tombola/1d5d7b6d54ab24182533649ead5fd50a to your computer and use it in GitHub Desktop.
Save tombola/1d5d7b6d54ab24182533649ead5fd50a to your computer and use it in GitHub Desktop.
Control Shift API - postman collection
{
"info": {
"name": "Control Shift",
"description": "For this collection of requests to authenticate, you will need to add a couple of additional variables to an 'environment' and activate that.\n\n- `CS_REST_CLIENT_ID`\n- `CS_REST_CLIENT_SECRET`",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "CS: Unauth JSON",
"item": [
{
"name": "Petitions (by partnership)",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{CS_URL}}/partnerships/{{CS_PARTNERSHIP_SLUG}}/petitions.json",
"host": ["{{CS_URL}}"],
"path": [
"partnerships",
"{{CS_PARTNERSHIP_SLUG}}",
"petitions.json"
]
}
},
"response": []
},
{
"name": "bulk data columns",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{CS_URL}}/api/bulk_data/schema/columns?table={{CS_TABLE}}",
"host": ["{{CS_URL}}"],
"path": ["api", "bulk_data", "schema", "columns"],
"query": [
{
"key": "table",
"value": "{{CS_TABLE}}"
}
]
}
},
"response": []
}
],
"description": "https://developers.controlshiftlabs.com/#json-api-endpoints\n\nThe JSONP API is a simple way to embed ControlShift petition content in external sites. It's intended for use by a front-end developer embed content on web pages outside of the platform. For example, a developer could:\n\n- Show petitions\n- Allow a user to search for near by petitions\n- List petition categories\n- Show petitions within an effort\n- If a site visitor is logged in, show a users past actions and created petitions",
"auth": {
"type": "noauth"
},
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [""]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [""]
}
}
]
},
{
"name": "CS: Webhooks (ie simulated)",
"item": [
{
"name": "Webhook - signature.created",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"type\": \"signature.created\",\n \"data\": {\n \"id\": 645,\n \"first_name\": \"Jennifer\",\n \"last_name\": \"Goines\",\n \"email\": \"jenny@example.com\",\n \"phone_number\": null,\n \"postcode\": \"23456\",\n \"country\": \"\",\n \"country_without_fallback\": \"\",\n \"join_organisation\": null,\n \"join_partnership\": null,\n \"locale\": \"en\",\n \"token\": \"2919ec5f25d493c19690a21135d7fd902a336927\",\n \"source\": \"facebook\",\n \"bucket\": \"share-campaign-v2\",\n \"utm_source\": \"facebook\",\n \"utm_campaign\": \"share-campaign-v2\",\n \"utm_medium\": \"social\",\n \"utm_content\": \"share-variant-3\",\n \"utm_term\": \"parks\",\n \"user_ip\": \"127.0.0.1\",\n \"user_agent\": \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/43.0.2357.130 Chrome/43.0.2357.130 Safari/537.36\",\n \"from_embed\": null,\n \"confirmed_at\": null,\n \"confirmed_reason\": null,\n \"last_signed_at\": \"2015-08-03T13:30:01Z\",\n \"additional_fields\": {\n },\n \"email_opt_in_type\": {\n \"context\": \"web_form\",\n \"kind\": \"pre_checked_checkbox\",\n \"mailable\": true,\n \"external_id\": \"abcd12345\"\n },\n \"eu_data_processing_consent\": true,\n \"consent_content_version\": {\n \"id\": 123,\n \"external_id\": \"abc345\",\n \"consent_type\": \"explicit\"\n },\n \"member\": {\n \"id\": 747,\n \"created_at\": \"2015-08-03T13:30:01Z\"\n },\n \"petition\": {\n \"url\": \"http://localhost/petitions/don-t-destroy-our-park\",\n \"slug\": \"don-t-destroy-our-park\"\n },\n \"created_at\": \"2015-08-03T13:30:01Z\",\n \"updated_at\": \"2015-08-03T13:30:01Z\",\n \"deleted_at\": null,\n \"unsubscribe_at\": null\n },\n \"jid\": \"1ebf2eb10c3d8939f42dff68\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{LAMBDA_URL}}/controlshift",
"host": ["{{LAMBDA_URL}}"],
"path": ["controlshift"]
}
},
"response": []
},
{
"name": "Webhook - bulk data export completed",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"type\": \"data.full_table_exported\",\n \"data\": {\n \"url\": \"https://agra-data-exports.s3.amazonaws.com/default/petitions_20150803180434.csv?AWSAccessKeyId=XXX&Expires=1438711490&Signature=ABCDE%3D\",\n \"table\": \"petitions\"\n },\n \"jid\": \"cf0f50d7d225e20a188be328\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://127.0.0.1:5000/",
"protocol": "http",
"host": ["127", "0", "0", "1"],
"port": "5000",
"path": [""]
}
},
"response": []
}
],
"description": "In order to test some _Control Shift_ webhooks that would arrive at your app (if configured in integrations), I have provided some requests matching the expected data.\n\nhttps://developers.controlshiftlabs.com/#webhook-endpoints",
"auth": {
"type": "noauth"
},
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [""]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [""]
}
}
]
},
{
"name": "CS: Auth REST",
"item": [
{
"name": "Organization",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{CS_REST_URL}}/organisation",
"host": ["{{CS_REST_URL}}"],
"path": ["organisation"]
}
},
"response": []
},
{
"name": "Email opt in types",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{CS_REST_URL}}/organisation/email_opt_in_types",
"host": ["{{CS_REST_URL}}"],
"path": ["organisation", "email_opt_in_types"]
},
"description": "Get a list of the email opt in types that have been configured for this organisation.\nEmail opt in types represent the way that members have opted in to your email list.\nhttps://developers.controlshiftlabs.com/#authenticated-rest-api-email-opt-in-types"
},
"response": []
},
{
"name": "Member (by email)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = JSON.parse(responseBody);",
"// Set local var",
"// pm.variables.set(\"CS_TEST_MEMBER_ID\", jsonData.member.id);",
"postman.setEnvironmentVariable(\"CS_TEST_MEMBER_ID\", jsonData.member.id);",
"postman.setEnvironmentVariable(\"AN_PERSON_ID\", jsonData.member.external_id);",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{CS_REST_URL}}/members/lookup?email=example@gmail.com",
"host": ["{{CS_REST_URL}}"],
"path": ["members", "lookup"],
"query": [
{
"key": "email",
"value": "{{CS_TEST_MEMBER_EMAIL}}",
"disabled": true
},
{
"key": "email",
"value": "example@gmail.com"
}
]
}
},
"response": []
},
{
"name": "Signature",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = JSON.parse(responseBody);",
"// Set local var",
"// pm.variables.set(\"CS_TEST_MEMBER_ID\", jsonData.member.id);",
"postman.setEnvironmentVariable(\"CS_TEST_MEMBER_ID\", jsonData.member.id);",
"postman.setEnvironmentVariable(\"AN_PERSON_ID\", jsonData.member.external_id);",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{CS_REST_URL}}/members/lookup?email={{CS_TEST_MEMBER_EMAIL}}",
"host": ["{{CS_REST_URL}}"],
"path": ["members", "lookup"],
"query": [
{
"key": "email",
"value": "{{CS_TEST_MEMBER_EMAIL}}"
}
]
}
},
"response": []
},
{
"name": "Member (by ID)",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{CS_REST_URL}}/members/{{CS_TEST_MEMBER_ID}}",
"host": ["{{CS_REST_URL}}"],
"path": ["members", "{{CS_TEST_MEMBER_ID}}"]
}
},
"response": []
},
{
"name": "Member: Unsubscribe",
"request": {
"method": "POST",
"header": [],
"url": {
"raw": "{{CS_REST_URL}}/members/{{CS_TEST_MEMBER_ID}}/update_email_opt_in_type",
"host": ["{{CS_REST_URL}}"],
"path": [
"members",
"{{CS_TEST_MEMBER_ID}}",
"update_email_opt_in_type"
]
},
"description": "Unsubscribes a member with specified id from emails from event hosts and petiton creators. Member will still receive transactional emails, and will be resubscribed if they opt in while signing a new petition or attending a new event, etc."
},
"response": []
},
{
"name": "Member: Update Email Opt In Type",
"request": {
"method": "POST",
"header": [],
"url": {
"raw": "{{CS_REST_URL}}/members/{{CS_TEST_MEMBER_ID}}/unsubscribe",
"host": ["{{CS_REST_URL}}"],
"path": ["members", "{{CS_TEST_MEMBER_ID}}", "unsubscribe"]
},
"description": "Changes the email opt in type for the member with the specified id to the external id in the POST body. This will update the opt in type for all associated signatures, attendee records, user accounts and other data held by ControlShift to the opt in type specified by external_id This feature may be useful for upgrading the recorded consent when new consent for email communications has been collected in external systems Most likely you will be changing historical consents that may no longer be mailable for legal reasons to a new mailable consent type No history is stored recording the original consent type, it is replaced by the new one specified."
},
"response": []
},
{
"name": "Signature (by email)",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{CS_REST_URL}}/petitions/{{CS_PETITION_SLUG}}/signatures/lookup?email=example@gmail.com",
"host": ["{{CS_REST_URL}}"],
"path": [
"petitions",
"{{CS_PETITION_SLUG}}",
"signatures",
"lookup"
],
"query": [
{
"key": "email",
"value": "example@gmail.com"
},
{
"key": "id",
"value": "127422659",
"disabled": true
}
]
}
},
"response": []
},
{
"name": "Petitions",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{CS_REST_URL}}/petitions",
"host": ["{{CS_REST_URL}}"],
"path": ["petitions"]
}
},
"response": []
},
{
"name": "Petitions (by slug)",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{CS_REST_URL}}/petitions/{{CS_PETITION_SLUG}}",
"host": ["{{CS_REST_URL}}"],
"path": ["petitions", "{{CS_PETITION_SLUG}}"]
}
},
"response": []
}
],
"description": "https://developers.controlshiftlabs.com/#authenticated-rest-api\n\nThe Authenticated REST API allows customers to build applications that interact with their own data or securely grant access to third-party app developers without exposing administrative credentials. It is designed to be consumed server-side, in contrast to the JSONP API which is designed for unauthenticated javascript integrations.",
"auth": {
"type": "oauth2",
"oauth2": [
{
"key": "tokenName",
"value": "CS_REST_TOKEN",
"type": "string"
},
{
"key": "challengeAlgorithm",
"value": "S256",
"type": "string"
},
{
"key": "redirect_uri",
"value": "urn:ietf:wg:oauth:2.0:oob",
"type": "string"
},
{
"key": "grant_type",
"value": "client_credentials",
"type": "string"
},
{
"key": "clientSecret",
"value": "{{CS_REST_CLIENT_SECRET}}",
"type": "string"
},
{
"key": "clientId",
"value": "{{CS_REST_CLIENT_ID}}",
"type": "string"
},
{
"key": "authUrl",
"value": "{{CS_URL}}",
"type": "string"
},
{
"key": "addTokenTo",
"value": "header",
"type": "string"
},
{
"key": "client_authentication",
"value": "body",
"type": "string"
},
{
"key": "accessTokenUrl",
"value": "{{CS_URL}}/oauth/token",
"type": "string"
}
]
},
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [""]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [""]
}
}
]
}
],
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [""]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [""]
}
}
],
"variable": [
{
"key": "CS_URL",
"value": ""
},
{
"key": "CS_PARTNERSHIP_SLUG",
"value": ""
},
{
"key": "CS_REST_URL",
"value": "https://<instance-domain/api/v1"
},
{
"key": "CS_PETITION_SLUG",
"value": "the-slug-used-for-petition-url"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment