def capture(self, amount=None): data = None if amount is not None: data = {'amount': amount} response = moyasar.request('POST', self.capture_url(self.id), data) response = json.loads(response.text) moyasar.fill_object(self, response)
def list(cls, data=None): response = moyasar.request('GET', cls.list_url(), data) response = json.loads(response.text) field_name = f'{cls.__name__}s'.lower() resource_list = [] for resource in response[field_name]: resource_list.append(cls(resource)) return resource_list
def update(self, data): response = moyasar.request('PUT', self.update_url(self.id), data) return response
def cancel(self): response = moyasar.request('PUT', self.cancel_url(self.id), None) response = json.loads(response.text) moyasar.fill_object(self, response) return response
def fetch(cls, id): response = moyasar.request('GET', cls.fetch_url(id), None) response = json.loads(response.text) return cls(response)
def test_request_should_return_json_object(): ss.stub_server_request(method='GET', url=moyasar.api_url + '/payments', resource=f.payments, status=200) response = moyasar.request('GET', moyasar.api_url + '/payments', None) assert isinstance(response.json(), dict)
def create(cls, data): response = moyasar.request('POST', cls.create_url(), data) response = json.loads(response.text) return cls(response)
def void(self): response = moyasar.request('POST', self.void_url(self.id)) response = json.loads(response.text) moyasar.fill_object(self, response)