def send(self, **opts): endpoint = self.endpoint()+"/emails" response = self._client.request('POST', endpoint, opts) # build email objects email = Email(self._client) return util.build_objects(email, response['body'])
def send_statement(self, **opts): endpoint = self.endpoint() + "/emails" response = self._client.request('POST', endpoint, opts) # build email objects email = Email(self._client) return util.build_objects(email, response['body'])
def send_statement(self, idempotency_key=None, **params): endpoint = self.endpoint()+"/emails" opts = {'idempotency_key': idempotency_key} response = self._client.request('POST', endpoint, params, opts) # build email objects email = Email(self._client) return util.build_objects(email, response['body'])
def send_letter(self, idempotency_key=None, **opts): endpoint = self.endpoint()+"/letters" opts = {'idempotency_key': idempotency_key} response = self._client.request('POST', endpoint, {}, opts) # build letter objects letter = Letter(self._client) return util.build_objects(letter, response['body'])
def send_sms(self, idempotency_key=None, **opts): endpoint = self.endpoint()+"/text_messages" opts = {'idempotency_key': idempotency_key} response = self._client.request('POST', endpoint, {}, opts) # build text message objects text_message = TextMessage(self._client) return util.build_objects(text_message, response['body'])
def test_build_objects(self): customers = [{'id': 100}, {'id': 101}] objects = util.build_objects(self.client.Customer, customers) self.assertEqual(2, len(objects)) self.assertIsInstance(objects[0], invoiced.Customer) self.assertIsInstance(objects[1], invoiced.Customer) self.assertEqual(objects[0].id, 100) self.assertEqual(objects[1].id, 101)
def list(self, **opts): response = self._client.request("GET", self.endpoint(), opts) # build objects objects = util.build_objects(self, response["body"]) # store the metadata from the list operation metadata = List(response["headers"]["link"], response["headers"]["x-total-count"]) return objects, metadata
def list(self, **opts): response = self._client.request('GET', self.endpoint(), opts) # build objects objects = util.build_objects(self, response['body']) # store the metadata from the list operation metadata = List(response['headers']['link'], response['headers']['x-total-count']) return objects, metadata
def test_build_objects(self): customers = [ {'id': 100}, {'id': 101} ] objects = util.build_objects(self.client.Customer, customers) self.assertEqual(2, len(objects)) self.assertIsInstance(objects[0], invoiced.Customer) self.assertIsInstance(objects[1], invoiced.Customer) self.assertEqual(objects[0].id, 100) self.assertEqual(objects[1].id, 101)
def attachments(self, **opts): response = self._client.request('GET', self.endpoint() + "/attachments", opts) # ensure each attachment has an ID body = response['body'] for attachment in body: if 'id' not in attachment: attachment['id'] = attachment['file']['id'] # build attachment objects attachment = Attachment(self._client) attachments = util.build_objects(attachment, body) # store the metadata from the list operation metadata = List(response['headers']['link'], response['headers']['x-total-count']) return attachments, metadata
def attachments(self, **opts): response = self._client.request('GET', self.endpoint()+"/attachments", opts) # ensure each attachment has an ID body = response['body'] for attachment in body: if 'id' not in attachment: attachment['id'] = attachment['file']['id'] # build attachment objects attachment = Attachment(self._client) attachments = util.build_objects(attachment, body) # store the metadata from the list operation metadata = List(response['headers']['link'], response['headers']['x-total-count']) return attachments, metadata