Example #1
0
    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'])
Example #2
0
    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'])
Example #3
0
    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'])
Example #4
0
    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'])
Example #5
0
    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'])
Example #6
0
    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)
Example #7
0
    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
Example #8
0
    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
Example #9
0
    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)
Example #10
0
    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
Example #11
0
    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