コード例 #1
0
ファイル: objects.py プロジェクト: Invoiced/invoiced-python
    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'])
コード例 #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'])
コード例 #3
0
ファイル: objects.py プロジェクト: megahall/invoiced-python
    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'])
コード例 #4
0
ファイル: objects.py プロジェクト: megahall/invoiced-python
    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'])
コード例 #5
0
ファイル: objects.py プロジェクト: megahall/invoiced-python
    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'])
コード例 #6
0
ファイル: test_util.py プロジェクト: wooyek/invoiced-python
    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)
コード例 #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
コード例 #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
コード例 #9
0
ファイル: test_util.py プロジェクト: Invoiced/invoiced-python
    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)
コード例 #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
コード例 #11
0
ファイル: objects.py プロジェクト: Invoiced/invoiced-python
    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