Skip to content

Instantly share code, notes, and snippets.

@samedhi
Last active December 6, 2016 23:20
Show Gist options
  • Save samedhi/1dd328c159f934c10443d916479936a9 to your computer and use it in GitHub Desktop.
Save samedhi/1dd328c159f934c10443d916479936a9 to your computer and use it in GitHub Desktop.
Create a new stream
import json
import requests
import subprocess
import sys
BEARER_CMD = 'vault read -field=bearer_token secret/oauth'
BEARER_TOKEN = subprocess.check_output(BEARER_CMD.split(' '))
URL = 'https://oauth-dot-talkiq-integration.appspot.com/stream'
REQUIRED_BODY = {
'call_id': 'f24a47ba-3121-1235-06b0-0cc47a392728',
'parent_call_id': 'c1ed86b6-3125-1235-06b0-0cc47a392728',
'dial_id': -1,
'from_number': '<sip:FreeSWITCH@67.231.9.143>;tag=7pFDy0cUjaS0B>',
'to_number': '<sip:+14804822743@67.231.9.143>',
'remote_party_id': '<sip:+17732894274@67.231.9.143>;party=calling;',
'datetime': "2016-11-30T16:36:15",
'source': 'salesloft',
'method': 'INVITE',
'side': 'calllee',
'numeric_side': 0,
'link': 0,
'user': 'ahRzfnRhbGtpcS1pbnRlZ3JhdGlvbnIvCxIMT3JnYW5pemF0aW9uIg5zYWxlc2xvZnQvODIzMQwLEgRVc2VyIgUyNjc2Ngw'
}
HEADERS = {'Authorization': "Bearer %s" % BEARER_TOKEN,
'Content-Type': 'application/json'}
response = requests.post(URL,
data=json.dumps(REQUIRED_BODY),
headers=HEADERS)
print response.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment