Skip to content

Commit

Permalink
Fix 400 in delete API, add body in request
Browse files Browse the repository at this point in the history
  • Loading branch information
SushilMallRC committed May 3, 2024
1 parent a86b8f7 commit e513268
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ringcentral/platform/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ def patch(self, url, body=None, query_params=None, headers=None, skip_auth_check
request = self._client.create_request('PATCH', url, query_params=query_params, headers=headers, body=body)
return self.send_request(request, skip_auth_check=skip_auth_check)

def delete(self, url, query_params=None, headers=None, skip_auth_check=False):
request = self._client.create_request('DELETE', url, query_params=query_params, headers=headers)
def delete(self, url, body=None, query_params=None, headers=None, skip_auth_check=False):
request = self._client.create_request('DELETE', url, query_params=query_params, headers=headers, body=body)
return self.send_request(request, skip_auth_check=skip_auth_check)

def _request_token(self, path='', body=None):
Expand Down
15 changes: 13 additions & 2 deletions ringcentral/platform/platform_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_login_fail(self, mock):
sdk.platform().login()
except Exception as e:
self.assertTrue( e )

def test_login_code_redirect(self, mock):
sdk = self.get_sdk(mock)
self.logout_mock(mock)
Expand Down Expand Up @@ -140,7 +140,18 @@ def test_api_url_custom_prefixes(self, mock):
url = '/analytics/phone/foo'
act = sdk.platform().create_url(url, add_server=True)
self.assertEqual(exp, act)


def test_delete_with_body(self,mock):
sdk = self.get_sdk(mock)
self.delete_mock_with_body(mock)
res = sdk.platform().delete(url='/restapi/v2/accounts/~/extensions',body={"keepAssetsInInventory": True,"records": [{"id": "123"}]})
self.assertTrue(mock.called)

def test_delete_without_body(self, mock):
sdk = self.get_sdk(mock)
self.delete_mock_without_body(mock)
sdk.platform().delete(url='/restapi/v2/accounts/~/extensions')
self.assertTrue(mock.called)

if __name__ == '__main__':
unittest.main()
6 changes: 6 additions & 0 deletions ringcentral/test/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,9 @@ def subscription_mock(self, mock, expires_in=54000, filters=None, id=None):
'status': 'Active',
'uri': 'https://platform.ringcentral.com/restapi/v1.0/subscription/foo-bar-baz'
})

def delete_mock_with_body(self,mock):
return self.add(mock, 'DELETE', '/restapi/v2/accounts/~/extensions', {"keepAssetsInInventory": True,"records": [{"id": "123"}]})

def delete_mock_without_body(self,mock):
return self.add(mock, 'DELETE', '/restapi/v2/accounts/~/extensions', body=None)

0 comments on commit e513268

Please sign in to comment.