Skip to content
This repository was archived by the owner on Oct 17, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ We're excited you're considering contributing to our project! Your patches are e

* Make sure you have a [GitHub account](https://github.com/signup/free)
* Make sure you have a [HelloSign account](http://www.hellosign.com)
* Submit a new [issue ticket](https://github.com/HelloFax/hellosign-java-sdk/issues), assuming one does not already exist.
* Submit a new [issue ticket](https://github.com/hellosign/hellosign-python-sdk), assuming one does not already exist.
* Clearly describe the issue including steps to reproduce when it is a bug.
* Make sure to include the version you are using which has the issue (and confirm that the issue you are having has not been fixed in a later version)
* Fork the repository on GitHub
Expand All @@ -27,7 +27,7 @@ always necessary to create a new issue ticket.
## Submitting Changes

* Push your changes to your fork of the repository.
* Submit a pull request to the repository in the HelloFax organization.
* Submit a pull request to the repository in the HelloSign organization.
* Update your issue ticket to mark that you have submitted code and are ready for it to be reviewed (Status: Ready for Merge).
* Include a link to the pull request in the ticket.
* The HelloSign dev team looks at Pull Requests on a regular basis.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pip install hellosign-python-sdk

Install from code:
````sh
git clone https://github.com/HelloFax/hellosign-python-sdk.git
git clone https://github.com/HelloSign/hellosign-python-sdk.git
cd hellosign-python-sdk
python setup.py install
````
Expand Down Expand Up @@ -213,7 +213,7 @@ draft = client.create_embedded_unclaimed_draft(
claim_url = draft.claim_url
````

More information about the asscociated front-end code can be found [here](https://www.hellosign.com/api/embeddedRequestingWalkthrough#ClientSideRequesting)
More information about the associated front-end code can be found [here](https://app.hellosign.com/api/embeddedRequestingWalkthrough#EmbeddedRequestingClientSide)

Once the user edits the draft in the embedded iFrame and sends the signature request your app callback will receive a `signature_request_sent` event containing a `SignatureRequest` object. If we had used `is_for_embedded_signing=True`, we would want to get the signature ids out of the `SignatureRequest` from that event and fetch the signature urls at this point. In your event callback handler, you will need to do something like this:

Expand Down
1,247 changes: 908 additions & 339 deletions hellosign_sdk/hsclient.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion hellosign_sdk/resource/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .account import Account
from .apiapp import ApiApp
from .embedded import Embedded
from .signature import Signature
from .signature_request import SignatureRequest
Expand All @@ -8,4 +9,4 @@
from .resource_list import ResourceList
from .resource import Resource

__all__ = [Account, Embedded, Signature, SignatureRequest, Team, Template, UnclaimedDraft, Resource, ResourceList]
__all__ = [Account, ApiApp, Embedded, Signature, SignatureRequest, Team, Template, UnclaimedDraft, Resource, ResourceList]
8 changes: 4 additions & 4 deletions hellosign_sdk/resource/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

#
# The MIT License (MIT)
#
#
# Copyright (C) 2014 hellosign.com
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
Expand Down Expand Up @@ -47,8 +47,8 @@ class Account(Resource):

callback_url (str): The URL that HelloSign events will be POSTed to

role_code (str): The membership role for the team.
a = Admin,
role_code (str): The membership role for the team.
a = Admin,
m = Member
d = Developer

Expand Down
95 changes: 95 additions & 0 deletions hellosign_sdk/resource/apiapp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
from .resource import Resource

#
# The MIT License (MIT)
#
# Copyright (C) 2014 hellosign.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#


class ApiApp(Resource):
''' Contains information about an API App.

Attributes:
client_id (str): The API App's Client ID

created_at (int): Unix timestamp of when the API App was created

name (str): The name of the API App

domain (str): The domain name associated with the API App

callback_url (str) : The URL that HelloSign events will be POSTed to

is_approved (bool): Indicates if the API App is approved

owner_account (dict): Information about the API App owner

account_id (str): The id of the Account

email_address (str): The email address associated with the Account

options (dict): Options that override the Account settings

can_insert_everywhere (bool): Denotes if signers can "Insert Everywhere" when
signing a document

oauth (dict): Information about the API App's OAuth properties. Null if OAuth is
not configured for the API App.

callback_url (str): The URL that HelloSign OAuth events will be POSTed to

secret (str): The API App's OAuth secret

scopes (list): List of the API App's OAuth scopes

charges_users (bool): Indicates whether the API App or the authorized user
is billed for OAuth requests.

white_labeling_options (dict): Customization options for the API App's signer page

Examples:
To print the client_id

>>> from hsclient import HSClient
>>> client = HSClient()
>>> app = client.get_api_app_info()
>>> print app.client_id

'''

def __init__(self, jsonstr=None, key=None, warnings=None):
''' Initialization of the object

Args:
jsonstr (str): a raw JSON string that is returned by a request.
We store all the data in `self.json_data` and use `__getattr__`
and `__setattr__` to make the data accessible like attributes
of the object
key (str): Optional key to use with jsonstr. If `key` exists, we'll
load the data of `jsonstr[key]` instead of the whole `jsonstr`
warnings (list): List of associated warnings
'''
super(ApiApp, self).__init__(jsonstr, key, warnings)

def __str__(self):
''' Return a string representation of this Account '''
return 'ApiApp %s (%s)' % (self.name, self.client_id)
7 changes: 4 additions & 3 deletions hellosign_sdk/resource/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#
# The MIT License (MIT)
#
#
# Copyright (C) 2014 hellosign.com
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
Expand All @@ -24,10 +24,11 @@
# SOFTWARE.
#


class Resource(object):

''' An abstract class to represent some objects used by our SDK such as
Account, SignatureRequest, Template, Team, UnclaimedDraft, Embedded.
Account, ApiApp, SignatureRequest, Template, Team, UnclaimedDraft, Embedded.
These objects share the same way of storing data.

Information and settings are stored physically in `self.json_data`, and
Expand Down
7 changes: 4 additions & 3 deletions hellosign_sdk/resource/resource_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#
# The MIT License (MIT)
#
#
# Copyright (C) 2014 hellosign.com
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
Expand All @@ -30,7 +30,8 @@ class ResourceList(list):

items_keys = {
'SignatureRequest': 'signature_requests',
'Template': 'templates'
'Template': 'templates',
'ApiApp': 'api_apps'
}

page = 0
Expand Down
30 changes: 24 additions & 6 deletions hellosign_sdk/utils/hsformat.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# The MIT License (MIT)
#
#
# Copyright (C) 2014 hellosign.com
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
Expand Down Expand Up @@ -59,6 +59,15 @@ def format_file_url_params(file_urls):
file_urls_payload["file_url[" + str(idx) + "]"] = fileurl
return file_urls_payload

@staticmethod
def format_logo_params(logo):
'''
Utility method for formatting custom logo parameters for API Apps
'''
logo_payload = {}
logo_payload["custom_logo_file"] = open(logo, 'rb')
return logo_payload

@staticmethod
def format_param_list(listed_params, output_name):
'''
Expand All @@ -82,13 +91,13 @@ def format_dict_list(list_of_dicts, output_name, key=None):
and outputs:
signers[0][name] : val1
signers[0][email] : val2
...
...

Args:
list_of_dicts (list of dicts) - the list to format

output_name (str) - the parameter name to prepend to each key

key (str, optional) - Used for substituting a key present in the dictionaries for the index. The above might become signers['Lawyer']['name'] instead of using a numerical index if the key "role_name" was specified.

'''
Expand Down Expand Up @@ -126,7 +135,16 @@ def format_custom_fields(list_of_custom_fields):
output_payload["custom_fields[" + key + "]"] = value
return output_payload

@staticmethod
def format_signing_options(listed_params):
'''
Utility method for formatting signing options for api consumption
Args:
listed_params (list of values) - the list to format
'''
return listed_params

@staticmethod
def strip_none_values(dictionary):
if dictionary:
return dict((key, value) for (key, value) in dictionary.items() if value)
return dict((key, value) for (key, value) in dictionary.items() if value)
36 changes: 29 additions & 7 deletions hellosign_sdk/utils/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

#
# The MIT License (MIT)
#
#
# Copyright (C) 2014 hellosign.com
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
Expand Down Expand Up @@ -111,7 +111,7 @@ def get_file(self, url, path_or_file=None, headers=None, filename=None):
return True

def get(self, url, headers=None, parameters=None, get_json=True):
''' Send a GET request with custome headers and parameters
''' Send a GET request with custom headers and parameters

Args:
url (str): URL to send the request to
Expand Down Expand Up @@ -166,9 +166,31 @@ def post(self, url, data=None, files=None, headers=None, get_json=True):

response = requests.post(url, headers=self.headers, data=data, auth=self.auth, files=files, verify=self.verify_ssl)
json_response = self._process_json_response(response)

return json_response if get_json is True else response

def delete(self, url, headers=None):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete what?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one's just adding a generic delete function to be able to make these kinds of requests since this SDK's only been able to make get and post requests before

Copy link
Copy Markdown

@michaelnlindsay michaelnlindsay Nov 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, would it be worth adding some guidance in comments about what object types can be deleted?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call! i added some detail to the comments

''' Make POST request to a url to delete an API App or Template

Args:
url (str): URL to send the request to
headers (str, optional): custom headers

Returns:
None

'''

if self.debug:
print("POST: %s, headers=%s" % (url, headers))

self.headers = self._get_default_headers()
if headers is not None:
self.headers.update(headers)

response = requests.delete(url, headers=self.headers, auth=self.auth, verify=self.verify_ssl)

return response

#### HELPERS ########################################

Expand Down Expand Up @@ -200,7 +222,7 @@ def _process_json_response(self, response):
''' Process a given response '''

json_response = self._get_json_response(response)

if self.response_callback is not None:
json_response = self.response_callback(json_response)
response._content = json.dumps(json_response)
Expand All @@ -225,7 +247,7 @@ def _check_error(self, response, json_response=None):

Returns:
True if status code is not error code

'''

# If status code is 4xx or 5xx, that should be an error
Expand All @@ -246,7 +268,7 @@ def _check_warnings(self, json_response):

Args:
json_response (dict): JSON response

'''

self.warnings = None
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def readme():

setup(
name='hellosign-python-sdk',
version='3.8.7',
version='3.8.8',
description="A Python wrapper for the HelloSign API (http://www.hellosign.com/api)",
long_description=readme(),
classifiers=[
Expand All @@ -20,7 +20,7 @@ def readme():
'Programming Language :: Python :: 2.7'
],
keywords='hellosign python sdk',
url='https://github.com/HelloFax/hellosign-python-sdk',
url='https://github.com/hellosign/hellosign-python-sdk',
author='HelloSign',
author_email='apisupport@hellosign.com',
license='MIT',
Expand Down