예제 #1
0
    def update_branding(self, branding_id, params):
        """
        Update a existing branding
        @branding_id: Id of the branding to update
        @params: Same params as method create_branding, see above
        @return: A dict with updated branding data
        """
        connection = Connection(self.token)

        connection.add_header('Content-Type', 'application/json')
        connection.set_url(self.production, self.BRANDINGS_ID_URL % branding_id)
        connection.add_params(params)

        return connection.patch_request()
예제 #2
0
    def create_contact(self, email, name):
        """
        Create a new contact
        :param email: user email
        :param name: user name
        """
        params = {'email': email, 'name': name}

        url = self.CONTACTS_URL

        connection = Connection(self.token)
        connection.set_url(self.production, url)
        connection.add_header('Content-Type', 'application/json')
        connection.add_params(params, json_format=True)

        return connection.post_request()
예제 #3
0
    def create_group(self, name):
        """
        Create group
        :param name: Group name
        """
        parameters = {
            'name': name
        }

        url = self.TEAM_GROUPS_URL

        connection = Connection(self.token)
        connection.set_url(self.production, url)
        connection.add_params(parameters)

        return connection.post_request()
예제 #4
0
    def invite_user(self, email, role):
        """
        Send an invitation to email with a link to join your team
        :param email: Email to add to your team
        :param role: Can be admin or member
        """
        parameters = {
            'email': email,
            'role': role
        }

        connection = Connection(self.token)
        connection.set_url(self.production, self.TEAM_USERS_URL)
        connection.add_params(parameters)

        return connection.post_request()
예제 #5
0
    def change_user_role(self, user_id, role):
        """
        Change role of current user
        :param user_id: Id of user
        :param role: Can be admin or member
        """
        parameters = {
            'role': role
        }

        url = self.TEAM_USERS_ID_URL % user_id

        connection = Connection(self.token)
        connection.set_url(self.production, url)
        connection.add_params(parameters)

        return connection.patch_request()
예제 #6
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()
예제 #7
0
    def update_group(self, group_id, name):
        """
        Change group name
        :param group_id: Id of group
        :param name: Group name
        """
        parameters = {
            'name': name
        }

        url = self.TEAM_GROUPS_ID_URL % group_id

        connection = Connection(self.token)
        connection.set_url(self.production, url)
        connection.add_header('Content-Type', 'application/json')
        connection.add_params(parameters)

        return connection.patch_request()
예제 #8
0
    def create_subscription(self, url, events):
        """
        Create subscription
        :param events: Events to subscribe
        :param url: Url to send events
        """
        params = {
            'url': url,
            'events': events
        }

        url = self.SUBSCRIPTIONS_URL

        connection = Connection(self.token)
        connection.set_url(self.production, url)
        connection.add_header('Content-Type', 'application/json')
        connection.add_params(params, json_format=True)

        return connection.post_request()
예제 #9
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()
예제 #10
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()
예제 #11
0
    def update_contact(self, contact_id, email=None, name=None):
        """
        Update a current contact
        :param contact_id: contact id
        :param email: user email
        :param name: user name
        """
        params = {}

        if email is not None:
            params['email'] = email

        if name is not None:
            params['name'] = name

        url = self.CONTACTS_ID_URL % contact_id

        connection = Connection(self.token)
        connection.set_url(self.production, url)
        connection.add_header('Content-Type', 'application/json')
        connection.add_params(params)

        return connection.patch_request()
예제 #12
0
    def update_subscription(self, subscription_id, url=None, events=None):
        """
        Create subscription
        :param subscription_id: Subscription to update
        :param events: Events to subscribe
        :param url: Url to send events
        """
        params = {}

        if url is not None:
            params['url'] = url

        if events is not None:
            params['events'] = events

        url = self.SUBSCRIPTIONS_ID_URL % subscription_id

        connection = Connection(self.token)
        connection.set_url(self.production, url)
        connection.add_header('Content-Type', 'application/json')
        connection.add_params(params)

        return connection.patch_request()
예제 #13
0
    def create_branding(self, params):
        """
        Create a new branding
        @params: An array of params (all params are optional)
            - layout: Default color for all application widgets (hex code)
            - text: Default text color for all application widgets (hex code)
            - application_texts: A dict with the new text values
            - sign_button: Text for sign button
            - send_button: Text for send button
            - decline_button: Text for decline button:
            - decline_modal_title: Title for decline modal (when you click decline button)
            - decline_modal_body: Body for decline modal (when you click decline button)
            - photo: Photo message text, which tells the user that a photo is needed in the current process
            - multi_pages: Header of the document, which tells the user the number of pages to sign
            ex: { 'photo': 'Hey! Take a photo of yourself to validate the process!'}
        """
        connection = Connection(self.token)

        connection.add_header('Content-Type', 'application/json')
        connection.set_url(self.production, self.BRANDINGS_URL)
        connection.add_params(params, json_format=True)

        return connection.post_request()