def test_get(self): request = HSRequest(self.client.auth) response = request.get(url='http://httpbin.org/get', headers={'Custom-Header': 'Nothing'}, parameters={'param': 'Nothing'}, get_json=False) self.assertEquals(response.status_code, 200) response = request.get(url='http://httpbin.org/get', get_json=True) self.assertEquals(isinstance(response, dict), True) response = request.get(url='https://httpbin.org/get', headers={'Custom-Header': 'Nothing'}, parameters={'param': 'Nothing'}, get_json=False) self.assertEquals(response.status_code, 200) response = request.get(url='https://httpbin.org/get', get_json=True) self.assertEquals(isinstance(response, dict), True) try: response = request.get(url='https://www.hellosign.com/oauth/token', get_json=True) except BadRequest, e: self.assertEquals('400 error' in str(e), True)
def test_call(self): auth = HSAccessTokenAuth(access_token="at_test", access_token_type="att_test") request = HSRequest(auth) response = request.get(url='http://httpbin.org/headers') self.assertEquals(response['headers']['Authorization'], 'at_test att_test')
def get_reusable_form(self, reusable_form_id): """Gets a ReusableForm which includes a list of Accounts that can access it Args: reusable_form_id (str): The id of the ReusableForm to retrieve Returns: A ReusableForm object specified by the id parameter """ request = HSRequest(self.auth) response = request.get(self.REUSABLE_FORM_GET_URL + reusable_form_id) return ReusableForm(response["reusable_form"])
def get_team_info(self): """Gets your Team and a list of its members Returns information about your Team as well as a list of its members. If you do not belong to a Team, a 404 error with an error_name of "not_found" will be returned. Returns: A Team object """ request = HSRequest(self.auth) response = request.get(self.TEAM_INFO_URL) return Team(response["team"])
def get_signature_request(self, signature_request_id): """Get a signature request by its ID Args: signature_request_id (str): The id of the SignatureRequest to retrieve Returns: A SignatureRequest object """ request = HSRequest(self.auth) response = request.get( self.SIGNATURE_REQUEST_INFO_URL + signature_request_id) return SignatureRequest(response["signature_request"])
def get_signature_request_list(self): """Get a list of SignatureRequest that you can access This includes SignatureRequests you have sent as well as received, but not ones that you have been CCed on. Returns: A list of SignatureRequest objects """ sr_list = [] request = HSRequest(self.auth) response = request.get(self.SIGNATURE_REQUEST_LIST_URL) for signature_request in response["signature_requests"]: sr_list.append(SignatureRequest(signature_request)) return sr_list
def get_embeded_object(self, signature_id): """Retrieves a embedded signing object Retrieves an embedded object containing a signature url that can be opened in an iFrame Args: signature_id (str): The id of the signature to get a signature url for Returns: An Embedded object specified by signature_id """ request = HSRequest(self.auth) response = request.get(self.EMBEDDED_OBJECT_GET_URL + signature_id) return Embedded(response["embedded"])
def get_reusable_form_list(self, page=1): """Lists your ReusableForms Args: page (int, optional): Which page number of the ReusableForm List to return. Defaults to 1. Returns: A list the ReusableForms that are accessible by you """ rf_list = [] request = HSRequest(self.auth) response = request.get( self.REUSABLE_FORM_GET_LIST_URL, parameters={"page": page}) for reusable_form in response["reusable_forms"]: rf_list.append(ReusableForm(reusable_form)) return rf_list
def get_account_info(self): """Get current account information The information then will be saved in `self.account` so that you can access the information like this: >>> hsclient = HSClient() >>> hsclient.get_account_info() >>> print hsclient.account.email_address Returns: True if the information fetched successfully, False otherwise """ request = HSRequest(self.auth) try: response = request.get(self.ACCOUNT_INFO_URL) self.account.json_data = response["account"] except HTTPError: return False return True
def test_get(self): request = HSRequest(self.client.auth) response = request.get(url='https://www.hellosign.com/', get_json=False) self.assertEquals(response.status_code, 200)
def test_not_found(self): request = HSRequest(self.client.auth) try: request.get(url=HSClient.API_URL + "/not/found") except NotFound: pass
def test_not_authorized(self): request = HSRequest(HTTPBasicAuth("test", '')) try: request.get(HSClient.ACCOUNT_INFO_URL) except Unauthorized: pass