def performApiCall(self, http_method, path, data=None, params=None): body = self.client.performHttpCall(http_method, path, data, params) try: result = body.json() except Exception as e: raise Error('Unable to decode Mollie response: "%s".' % body) if 'error' in result: error = Error('Error executing API call (%s): %s.' % (result['error']['type'], result['error']['message'])) if 'field' in result['error']: error.field = result['error']['field'] raise error return result
def update(self, resource_id, data): try: data = json.dumps(data) except Exception as e: raise Error('Error encoding parameters into JSON: "%s"' % e.message) return self.rest_update(resource_id, data)
def get(self, mandate_id): if not mandate_id or not mandate_id.startswith( self.RESOURCE_ID_PREFIX): raise Error( 'Invalid mandate ID: "%s". A mandate ID should start with "%s".' % (mandate_id, self.RESOURCE_ID_PREFIX)) return super(Mandates, self).get(mandate_id)
def get(self, subscription_id): if not subscription_id or not subscription_id.startswith( self.RESOURCE_ID_PREFIX): raise Error( 'Invalid subscription ID: "%s". A subscription ID should start with "%s".' % (subscription_id, self.RESOURCE_ID_PREFIX)) return super(Subscriptions, self).get(subscription_id)
def create(self, data): try: data = json.dumps(data) except Exception as e: raise Error('Error encoding parameters into JSON: "%s"' % str(e)) return self.rest_create(data)
def get(self, payment_id): if not payment_id or not payment_id.startswith(self.RESOURCE_ID_PREFIX): raise Error( 'Invalid payment ID: "%s". A payment ID should start with "%s".' % (payment_id, self.RESOURCE_ID_PREFIX) ) return super(Payments, self).get(payment_id)
def get(self, customer_id): if not customer_id or not customer_id.startswith(self.RESOURCE_ID_PREFIX): raise Error( 'Invalid customer ID: "%s". A customer ID should start with "%s".' % (customer_id, self.RESOURCE_ID_PREFIX) ) return super(Customers, self).get(customer_id)