Beispiel #1
0
    def create_email(self, files, recipients, subject, body, params={}):
        """
        Create a new certified email

        @files
             Files to send
                ex: ['/documents/internet_contract.pdf', ... ]
        @recipients
            A dictionary with the email and fullname of the person you want to sign.
            If you wanna send only to one person:
               - [{"email": "*****@*****.**", "fullname": "John"}]
            For multiple recipients, yo need to submit a list of dicts:
               - [{"email": "*****@*****.**", "fullname": "John"}, {"email":"*****@*****.**", "fullname": "Bob"}]
        @subject
            Email subject
        @body
            Email body
        @params
        """
        parameters = {}

        parser = Parser()

        documents = {}

        parser.fill_array(documents, files, 'files')

        recipients = recipients if isinstance(recipients, list) else [recipients]

        index = 0
        for recipient in recipients:
            parser.fill_array(parameters, recipient, 'recipients[%i]' % index)

            index += 1

        parser.fill_array(parameters, params, '')

        parameters['subject'] = subject
        parameters['body'] = body

        connection = Connection(self.token)
        connection.set_url(self.production, self.EMAILS_URL)
        connection.add_params(parameters)
        connection.add_files(documents)

        return connection.post_request()
Beispiel #2
0
    def create_SMS(self, files, recipients, body, params={}):
        """
        Create a new certified sms

        @files
             Files to send
                ex: ['/documents/internet_contract.pdf', ... ]
        @recipients
            A dictionary with the phone and name of the person you want to sign. Phone must be always with prefix
            If you wanna send only to one person:
               - [{"phone": "34123456", "name": "John"}]
            For multiple recipients, yo need to submit a list of dicts:
               - [{"email": "34123456, "name": "John"}, {"email":"34654321", "name": "Bob"}]
        @body
            Email body
        @params
        """
        parameters = {}

        parser = Parser()

        documents = {}

        parser.fill_array(documents, files, 'files')

        recipients = recipients if isinstance(recipients, list) else [recipients]

        index = 0
        for recipient in recipients:
            parser.fill_array(parameters, recipient, 'recipients[%i]' % index)

            index += 1

        parser.fill_array(parameters, params, '')

        parameters['body'] = body

        connection = Connection(self.token)
        connection.set_url(self.production, self.SMS_URL)
        connection.add_params(parameters)
        connection.add_files(documents)

        return connection.post_request()
Beispiel #3
0
    def create_signature(self, files, recipients, params):
        """
        Create a new Signature request.
        @files
            Files to send
                ex: ['/documents/internet_contract.pdf', ... ]
        @recipients
            A dictionary with the email and fullname of the person you want to sign.
            If you wanna send only to one person:
               - [{"email": "*****@*****.**", "fullname": "John"}]
            For multiple recipients, yo need to submit a list of dicts:
               - [{"email": "*****@*****.**", "fullname": "John"}, {"email":"*****@*****.**", "fullname": "Bob"}]
        @params: An array of params
        """
        parameters = {}

        parser = Parser()

        recipients = recipients if isinstance(recipients, list) else [recipients]

        index = 0
        for recipient in recipients:
            parser.fill_array(parameters, recipient, 'recipients[%i]' % index)

            index += 1

        parser.fill_array(parameters, params, '')

        documents = {}

        files = files if isinstance(files, list) else [files]

        parser.fill_array(documents, files, 'files')

        connection = Connection(self.token)
        connection.set_url(self.production, self.SIGNS_URL)
        connection.add_params(parameters)
        connection.add_files(documents)

        return connection.post_request()