Пример #1
0
 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
Пример #2
0
 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
Пример #3
0
 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)
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
 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)
Пример #8
0
 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)