hellosign / hellosign-python-sdk

A Python SDK for HelloSign's API
MIT License
29 stars 48 forks source link

send_with_template endpoint should add file[] or file_url[] as supported params #43

Closed alexmac05 closed 4 years ago

alexmac05 commented 6 years ago

re: @api.hellosign.com/v3/signature_request/send_with_template endpoint https://app.hellosign.com/api/reference#send_with_template Needs to be expanded to include the ability to also send a this parameter:

file[] or file_url[] optional Append additional files to the signature request. HelloSign will parse the files for text tags. Text tags for signers not on the template will be ignored.

Use file[] to pass the uploaded file(s). Use file_url[] to have HelloSign download the file(s). We currently only support use of either the file[] parameter or file_url[] parameter, not both.

NOTE: internal issue AS-97

alexmac05 commented 6 years ago

Workaround:

import requests

buildTheRequest = 'https://' + apikey + ':@api.hellosign.com/v3/signature_request/send_with_template' ndafile = {'file[0]': open('NDA.pdf', 'rb')} data = { 'template_id': 'XXXXXXXXXX', 'subject': 'workaround', 'allow_decline': '1', 'message': 'workaround', 'signers[Client][name]': 'George', 'signers[Client][email_address]': 'example@example.com', 'custom_fields': '[{"name":"newline", "value":"$20,000", "editor":"Client", "required":true}]', 'test_mode': '1'

'file_url': 'https://i.ytimg.com/vi/JPA_rzHDy6o/maxresdefault.jpg'

    }

print(buildTheRequest) r = requests.post(buildTheRequest, data, files=ndafile) print(r.text) stringData = r.text result = json.loads(stringData) print(result)

alexmac05 commented 6 years ago

To add multiple files: ndafile = {'file[0]': open('NDA.pdf', 'rb'), 'file[1]': open('NDA2.pdf', 'rb') }

alexmac05 commented 6 years ago

buildTheRequest = 'https://' + apikey + ':@api.hellosign.com/v3/signature_request/send_with_template'

ndafile = {'file[0]': open('NDA.pdf', 'rb'), 'file[1]': open('NDA2.pdf', 'rb') }

    data = {
        'template_id': 'dd1532dc8e14925eeb536bd933edd9e957ae5336',
        'subject': 'ticket214090',
        'allow_decline': '1',
        'message': 'ticket214090',
        'signers[Client][name]': 'George',
        'signers[Client][email_address]': 'example@example.com',
        'custom_fields': '[{"name":"newline", "value":"$20,000", "editor":"Client", "required":true}]',
        'test_mode': '1'
    }
    print(buildTheRequest)

    r = requests.post(buildTheRequest, data, files=ndafile)
    print(r.text)
    stringData = r.text

    result = json.loads(stringData)
    print(result)