Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions ringcentral/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ def create_request(self, method='', url='', query_params=None, body=None, header
url = url + ('&' if url.find('?') > 0 else '?') + query

content_type = None
accept = None


if headers is None:
headers = {}

Expand All @@ -86,16 +85,12 @@ def create_request(self, method='', url='', query_params=None, body=None, header
if key.lower().find('content-type') >= 0:
content_type = value
if key.lower().find('accept') >= 0:
accept = value
headers['Accept'] = value

if content_type is None:
content_type = 'application/json'
headers['Content-Type'] = content_type

if accept is None:
accept = 'application/json'
headers['Accept'] = accept

if content_type.lower().find('application/json') >= 0:
body = json.dumps(body) if body else None
elif content_type.lower().find('application/x-www-form-urlencoded') >= 0:
Expand Down
10 changes: 5 additions & 5 deletions ringcentral/platform/platform_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def test_login_code(self, mock):
sdk.platform().login(code='foo')
text = str(mock.request_history[-1].text)
if sys.version_info[0] == 3:
self.assertEqual(text, 'grant_type=authorization_code&redirect_uri=mock%3A%2F%2Fwhatever-redirect&code=foo')
self.assertEqual(text, 'grant_type=authorization_code&redirect_uri=https%3A%2F%2Fwhatever-redirect&code=foo')
else:
self.assertEqual(text, 'code=foo&grant_type=authorization_code&redirect_uri=mock%3A%2F%2Fwhatever-redirect')
self.assertEqual(text, 'code=foo&grant_type=authorization_code&redirect_uri=https%3A%2F%2Fwhatever-redirect')

def test_login_fail(self, mock):
sdk = self.get_sdk(mock)
Expand Down Expand Up @@ -123,7 +123,7 @@ def test_logout(self, mock):
def test_api_url(self, mock):
sdk = self.get_sdk(mock)

exp1 = 'mock://whatever/restapi/v1.0/account/~/extension/~?_method=POST&access_token=ACCESS_TOKEN'
exp1 = 'https://whatever/restapi/v1.0/account/~/extension/~?_method=POST&access_token=ACCESS_TOKEN'
act1 = sdk.platform().create_url('/account/~/extension/~', add_server=True, add_method='POST', add_token=True)
self.assertEqual(exp1, act1)

Expand All @@ -134,12 +134,12 @@ def test_api_url(self, mock):

def test_api_url_custom_prefixes(self, mock):
sdk = self.get_sdk(mock)
exp = 'mock://whatever/scim/v2/foo'
exp = 'https://whatever/scim/v2/foo'
url = '/scim/v2/foo'
act = sdk.platform().create_url(url, add_server=True)
self.assertEqual(exp, act)

exp = 'mock://whatever/analytics/phone/foo'
exp = 'https://whatever/analytics/phone/foo'
url = '/analytics/phone/foo'
act = sdk.platform().create_url(url, add_server=True)
self.assertEqual(exp, act)
Expand Down
4 changes: 2 additions & 2 deletions ringcentral/sdk_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

class TestSDK(TestCase):
def test_instance(self):
sdk = SDK('whatever', 'whatever', 'mock://whatever')
self.assertEqual(sdk.platform().create_url('/foo', add_server=True), 'mock://whatever/restapi/v1.0/foo')
sdk = SDK('whatever', 'whatever', 'https://whatever')
self.assertEqual(sdk.platform().create_url('/foo', add_server=True), 'https://whatever/restapi/v1.0/foo')


if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions ringcentral/test/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, method_name=None):

def get_sdk(self, mock):

sdk = SDK('whatever', 'whatever', 'mock://whatever', redirect_uri='mock://whatever-redirect')
sdk = SDK('whatever', 'whatever', 'https://whatever', redirect_uri='https://whatever-redirect')

self.authentication_mock(mock)
sdk.platform().login('18881112233', None, 'password')
Expand All @@ -44,7 +44,7 @@ def get_sdk(self, mock):
def add(self, mock, method, url, body, status=200):
mock.register_uri(
method=method,
url='mock://whatever' + url,
url='https://whatever' + url,
text=json.dumps(body),
headers={'Content-Type': 'application/json'},
status_code=status
Expand Down