def delete(self, resource_id, **kwargs): ''' Delete a previously created beneficiary and returns a hash containing the details of the deleted beneficiary. ''' return Beneficiary( self, **self.post('/v2/beneficiaries/' + resource_id + '/delete', kwargs))
def validate(self, **kwargs): ''' Validates Beneficiary details without creating one. Some of the optional parameters may be required depending on the requirements of the currency and the country. Please use the /v2/reference/beneficiary_required_details call to know which fields are required. ''' return Beneficiary(self, **self.post('/v2/beneficiaries/validate', kwargs))
def find(self, **kwargs): ''' Return an array containing json structures of details of the accounts matching the search criteria for the logged in user. ''' response = self.get('/v2/beneficiaries/find', query=kwargs) data = [ Beneficiary(self, **fields) for fields in response['beneficiaries'] ] return PaginatedCollection(data, response['pagination'])
def update(self, resource_id, **kwargs): ''' Updates an existing beneficiary and returns a json structure containing the details of the beneficiary. The same rules for parameters apply as for the create request. For more detailed information please see our payment guide: http://help.currencycloud.com/world/faq/#mandatory-payment-information ''' return Beneficiary( self, **self.post('/v2/beneficiaries/' + resource_id, kwargs))
def test_authentication_can_use_just_a_token(self): currencycloud.login_id = None currencycloud.api_key = None currencycloud.token = TestAuthentication.session_token session = currencycloud.session(authenticate=False) with Betamax(session.requests_session) as betamax: betamax.use_cassette('authentication/can_use_just_a_token') response = Beneficiary.find() assert response is not None
def test_authentication_handles_session_timeout(self): currencycloud.token = '3907f05da86533710efc589d58f51f45' # WARNING! # we need to disable recording becouse this cassette # generates incompatible files among different Python versions! # session = currencycloud.session(authenticate=False) # with Betamax(session.requests_session) as betamax: # betamax.use_cassette('authentication/handles_session_timeout', match_requests_on=['uri', 'method', 'headers']) # noqa response = Beneficiary.find() assert response is not None
def test_error_is_raised_when_a_resource_is_not_found(self): session = currencycloud.session(authenticate=False) with Betamax(session.requests_session) as betamax: betamax.use_cassette( 'error/is_raised_when_a_resource_is_not_found') error = None try: Beneficiary.retrieve('081596c9-02de-483e-9f2a-4cf55dcdf98c') raise Exception("Should have failed") except NotFoundError as e: error = e assert error.code == 'beneficiary_not_found' assert error.raw_response is not None assert error.status_code == 404 assert len(error.messages) == 1 error_message = error.messages[0] assert error_message.field == 'id' assert error_message.code == 'beneficiary_not_found' assert error_message.message == 'Beneficiary was not found for this id' # noqa assert not error_message.params
def create(self, **kwargs): ''' Creates a new beneficiary and returns a hash containing the details of the new beneficiary. Some of the optional parameters may be required depending on the requirements of the currency and the country. Please use the /v2/reference/beneficiary_required_details call to know which fields are required. Information that is required for your payment depends on the payment type (local or standard/SWIFT payment), originating country, payer country, payer legal entity type, beneficiary country, beneficiary entity type and payment destination country. For more detailed information please see our payment guide: http://help.currencycloud.com/world/faq/#mandatory-payment-information ''' return Beneficiary(self, **self.post('/v2/beneficiaries/create', kwargs))
def retrieve(self, resource_id, **kwargs): '''Returns a json structure containing the details of the requested beneficiary.''' return Beneficiary( self, **self.get('/v2/beneficiaries/' + resource_id, query=kwargs))