hellosign-api 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +15 -0
  5. data/CONTRIBUTING.md +42 -0
  6. data/Gemfile +13 -0
  7. data/Guardfile +14 -0
  8. data/LICENSE +21 -0
  9. data/README.md +112 -0
  10. data/Rakefile +16 -0
  11. data/hellosign-api.gemspec +54 -0
  12. data/lib/hello_sign/.error.rb.swp +0 -0
  13. data/lib/hello_sign/api/account.rb +78 -0
  14. data/lib/hello_sign/api/api_app.rb +121 -0
  15. data/lib/hello_sign/api/bulk_send_job.rb +62 -0
  16. data/lib/hello_sign/api/embedded.rb +68 -0
  17. data/lib/hello_sign/api/oauth.rb +95 -0
  18. data/lib/hello_sign/api/signature_request.rb +691 -0
  19. data/lib/hello_sign/api/team.rb +107 -0
  20. data/lib/hello_sign/api/template.rb +227 -0
  21. data/lib/hello_sign/api/unclaimed_draft.rb +328 -0
  22. data/lib/hello_sign/api.rb +31 -0
  23. data/lib/hello_sign/client.rb +372 -0
  24. data/lib/hello_sign/configuration.rb +78 -0
  25. data/lib/hello_sign/error.rb +99 -0
  26. data/lib/hello_sign/resource/account.rb +43 -0
  27. data/lib/hello_sign/resource/api_app.rb +43 -0
  28. data/lib/hello_sign/resource/base_resource.rb +73 -0
  29. data/lib/hello_sign/resource/bulk_send_job.rb +43 -0
  30. data/lib/hello_sign/resource/embedded.rb +43 -0
  31. data/lib/hello_sign/resource/resource_array.rb +56 -0
  32. data/lib/hello_sign/resource/signature_request.rb +43 -0
  33. data/lib/hello_sign/resource/team.rb +43 -0
  34. data/lib/hello_sign/resource/template.rb +43 -0
  35. data/lib/hello_sign/resource/template_draft.rb +44 -0
  36. data/lib/hello_sign/resource/unclaimed_draft.rb +44 -0
  37. data/lib/hello_sign/resource.rb +33 -0
  38. data/lib/hello_sign/version.rb +25 -0
  39. data/lib/hello_sign.rb +50 -0
  40. data/lib/hellosign-ruby-sdk.rb +4 -0
  41. data/spec/fixtures/account.json +15 -0
  42. data/spec/fixtures/api_app.json +16 -0
  43. data/spec/fixtures/api_apps.json +43 -0
  44. data/spec/fixtures/bulk_send_job.json +88 -0
  45. data/spec/fixtures/bulk_send_jobs.json +22 -0
  46. data/spec/fixtures/embedded.json +6 -0
  47. data/spec/fixtures/empty.pdf +0 -0
  48. data/spec/fixtures/error.json +6 -0
  49. data/spec/fixtures/file.json +0 -0
  50. data/spec/fixtures/headers.json +18 -0
  51. data/spec/fixtures/nda.pdf +0 -0
  52. data/spec/fixtures/signature_request.json +45 -0
  53. data/spec/fixtures/signature_requests.json +44 -0
  54. data/spec/fixtures/team.json +15 -0
  55. data/spec/fixtures/template.json +53 -0
  56. data/spec/fixtures/templates.json +59 -0
  57. data/spec/fixtures/token.json +14 -0
  58. data/spec/fixtures/unclaimed_draft.json +6 -0
  59. data/spec/hello_sign/.error_spec.rb.swp +0 -0
  60. data/spec/hello_sign/api/account_spec.rb +42 -0
  61. data/spec/hello_sign/api/api_app_spec.rb +104 -0
  62. data/spec/hello_sign/api/bulk_send_job_spec.rb +53 -0
  63. data/spec/hello_sign/api/embedded_spec.rb +23 -0
  64. data/spec/hello_sign/api/oauth_spec.rb +27 -0
  65. data/spec/hello_sign/api/signature_request_spec.rb +268 -0
  66. data/spec/hello_sign/api/team_spec.rb +101 -0
  67. data/spec/hello_sign/api/template_spec.rb +172 -0
  68. data/spec/hello_sign/api/unclaimed_draft_spec.rb +145 -0
  69. data/spec/hello_sign/client_spec.rb +191 -0
  70. data/spec/hello_sign/error_spec.rb +10 -0
  71. data/spec/hello_sign/resource/base_resource_spec.rb +53 -0
  72. data/spec/hello_sign_spec.rb +57 -0
  73. data/spec/scenarios/uploads_spec.rb +19 -0
  74. data/spec/spec_helper.rb +104 -0
  75. metadata +261 -0
@@ -0,0 +1,107 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (C) 2014 hellosign.com
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ module HelloSign
24
+ module Api
25
+ # Contains all the API calls for the Team resource.
26
+ # Take a look at our API Documentation on the Team Resource (https://app.hellosign.com/api/reference#Team)
27
+ # for more information about this.
28
+ #
29
+ # @author [hellosign]
30
+
31
+ module Team
32
+
33
+ # Returns member list and information about your Team.
34
+ # If you do not belong to a Team, HelloSign::Error::NotFound will be raised
35
+ #
36
+ # @return [HelloSign::Resource::Team] Current Team
37
+ #
38
+ # @example
39
+ # team = @client.get_team
40
+ def get_team
41
+ HelloSign::Resource::Team.new get('/team')
42
+ end
43
+
44
+ # Creates a new Team and adds you as a member. You must not currently belong to a Team.
45
+ # @option opts [String] name The name of the Team.
46
+ #
47
+ # @return [HelloSign::Resource::Team] a Team
48
+ #
49
+ # @example
50
+ # team = @client.create_team name: 'Team America World Police'
51
+ def create_team(opts)
52
+ HelloSign::Resource::Team.new post('/team/create', body: opts)
53
+ end
54
+
55
+ # Updates the name of your Team.
56
+ # @option opts [String] name The name of your Team.
57
+ #
58
+ # @return [HelloSign::Resource::Team]
59
+ #
60
+ # @example
61
+ # team = @client.update_team name: 'New Team Name'
62
+ def update_team(opts)
63
+ HelloSign::Resource::Team.new post('/team', body: opts)
64
+ end
65
+
66
+ # Deletes your Team. Can only be invoked with a Team with one member (yourself).
67
+ #
68
+ # @return [HTTP::Status] 200 OK
69
+ #
70
+ # @example
71
+ # team = @client.destroy_team
72
+ def destroy_team
73
+ post('/team/destroy')
74
+ end
75
+
76
+ # Adds or invites a user to the Team.
77
+ # If the user does not currently have a HelloSign Account, a new one will be created for them.
78
+ # If the user currently has a paid subscription, they will be emailed an invitation to join the Team.
79
+ # If a user is already a part of a Team, a "team_invite_failed" error will be returned.
80
+ # @option opts [String] account_id The user's Account ID to invite to the Team.
81
+ # @option opts [String] email_address The user's email address to invite to your Team.
82
+ # Note: The account_id prevails if both email_address and acccount_id are provided.
83
+ #
84
+ # @return [HelloSign::Resource::Team] a Team
85
+ #
86
+ # @example
87
+ # team = @client.add_member_to_team email_address: 'george@example.com'
88
+ def add_member_to_team(opts)
89
+ HelloSign::Resource::Team.new post('/team/add_member', body: opts)
90
+ end
91
+
92
+ # Removes a user from the Team. If the user had an outstanding invitation to your Team, the original invitation will expire.
93
+ # @option opts [String] account_id The user's Account ID to remove from the Team.
94
+ # @option opts [String] email_address The user's email address to remove from your Team.
95
+ # @option opts [String] new_owner_email_address The Account's email address to receive all documents, API Apps (if applicable), and API key from removed account. (optional)
96
+ # Note: The account_id prevails if both email_address and acccount_id are provided.
97
+ #
98
+ # @return [HelloSign::Resource::Team] updated Team
99
+ #
100
+ # @example
101
+ # team = @client.remove_member_from_team email_address: 'george@example.com'
102
+ def remove_member_from_team(opts)
103
+ HelloSign::Resource::Team.new post('/team/remove_member', body: opts)
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,227 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (C) 2014 hellosign.com
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ module HelloSign
24
+ module Api
25
+ # Contains all the API calls for the Template resource.
26
+ # Take a look at our API Documentation for Templates (https://app.hellosign.com/api/reference#Template)
27
+ # for more information about this.
28
+ #
29
+ # @author [hellosign]
30
+
31
+ module Template
32
+
33
+ # Retrieves the Template with the given ID.
34
+ # @option opts [String] template_id The ID of the Template to retrieve.
35
+ #
36
+ # @return [HelloSign::Resource::Template] a Template
37
+ #
38
+ # @example
39
+ # template = @client.get_template template_id: 'f57db65d3f933b5316d398057a36176831451a35'
40
+ def get_template(opts)
41
+ HelloSign::Resource::Template.new get("/template/#{opts[:template_id]}")
42
+ end
43
+
44
+ # Deletes the specified Template.
45
+ # @option opts [String] template_id The ID of the Template to delete.
46
+ #
47
+ # @return [HTTP::Status] 200 OK
48
+ #
49
+ # @example
50
+ # template = @client.delete_template template_id: 'f57db65d3f933b5316d398057a36176831451a35'
51
+ def delete_template(opts)
52
+ post("/template/delete/#{opts[:template_id]}")
53
+ end
54
+
55
+ # Retrieves the Templates for the accessible by the current user.
56
+ # @option opts [String] account_id The Account ID to return Templates for. Use "all" for all team members. Defaults to current account. (optional)
57
+ # @option opts [Integer] page Sets the page number of the list to return. Defaults to 1. (optional)
58
+ # @option opts [Integer] page_size Determines the number of Templates returned per page. Defaults to 20. (optional)
59
+ # @option opts [String] query Search terms and/or fields to filter the Templates. (optional)
60
+ #
61
+ # @return [HelloSign::Resource::ResourceArray] a ResourceArray
62
+ #
63
+ # @example
64
+ # templates = @client.get_templates page: 1
65
+ def get_templates(opts={})
66
+ path = '/template/list'
67
+ opts[:query] = create_search_string(opts[:query]) if opts[:query]
68
+ query = create_query_string(opts, [:page, :page_size, :query])
69
+ path += query
70
+ HelloSign::Resource::ResourceArray.new get(path, opts), 'templates', HelloSign::Resource::Template
71
+ end
72
+
73
+ # Gives the specified Account access to a Template. The Account must be part of your Team.
74
+ # @option opts [String] template_id The Template ID to give access to.
75
+ # @option opts [String] account_id The Account ID to receive access to the Template.
76
+ # @option opts [String] email_address The email address of the Account to receive access to the Template.
77
+ # Note: The account_id prevails if both email_address and acccount_id are provided.
78
+ #
79
+ # @return [HelloSign::Resource::Template] a Template
80
+ #
81
+ # @example
82
+ # templates = @client.add_user_to_template template_id: 'f57db65d3f933b5316d398057a36176831451a35', email_address: 'george@example.com'
83
+ def add_user_to_template(opts)
84
+ path = "/template/add_user/#{opts[:template_id]}"
85
+ opts.delete(:template_id)
86
+ HelloSign::Resource::Template.new post(path, body: opts)
87
+ end
88
+
89
+ # Removes the specified Account access to the specified Template.
90
+ # @option opts [String] template_id The Template ID to remove access to.
91
+ # @option opts [String] account_id The Account ID to remove access to the Template.
92
+ # @option opts [String] email_address The email address of the Account to remove access to the Template.
93
+ # Note: The account_id prevails if both email_address and acccount_id are provided.
94
+ #
95
+ # @return [HelloSign::Resource::Template] a Template
96
+ #
97
+ # @example
98
+ # templates = @client.remove_user_from_template template_id: 'f57db65d3f933b5316d398057a36176831451a35', email_address: 'george@example.com'
99
+ def remove_user_from_template(opts)
100
+ path = "/template/remove_user/#{opts[:template_id]}"
101
+ opts.delete(:template_id)
102
+ HelloSign::Resource::Template.new post(path, body: opts)
103
+ end
104
+
105
+ # Creates a new Embedded Template draft object that can be launched in an iFrame using the claim_url.
106
+ # @option opts [Boolean] test_mode Indicates if this is a test Template draft. SignatureRequests using this Template will not be legally binding if set to 1. Defaults to 0. (optional)
107
+ # @option opts [String] client_id The API App Client ID associated with the Template draft. (optional)
108
+ # @option opts [Array<String>] files Specified file path(s) to upload file(s) to send for signature. Currently we only support use of either the files parameter or file_urls parameter, not both.
109
+ # @option opts [Array<String>] file_urls URL(s) for HelloSign to download the file(s) to send for signature. Currently we only support use of either the files parameter or file_urls parameter, not both.
110
+ # @option opts [String] title The default Template title. (optional)
111
+ # @option opts [String] subject The default Template title alias. (optional)
112
+ # @option opts [String] message The default message in the email that will be sent to the signer(s). (optional)
113
+ # @option opts [Array<Hash>] signers List of signers displayed when the Template is used to create a SignatureRequest
114
+ # * name (String) Signer role name
115
+ # * order (Integer) The order the signer role is required to sign in. (optional)
116
+ # @option opts [Array<Hash>] attachments Sets a list of attachments signers can upload
117
+ # * name (String) Attachment name
118
+ # * instructions (String) Instructions for uploading the attachment. (optional)
119
+ # * signer_index (Integer) The signer's unique number.
120
+ # * required (Boolean) Determines if the signer is required to upload this attachment. Defaults to 0. (Optional)
121
+ # @option opts [Array<Hash>] cc_roles The CC roles that must be assigned when using the Template to create a SignatureRequest. (optional)
122
+ # @option opts [String<Array><Hash>] merge_fields List of fields that can be pre-populated by your application when using the Template to send a SignatureRequest. (optional)
123
+ # * name (String) Merge field name
124
+ # * type (String) Field type - either "text" or "checkbox"
125
+ # @option opts [Boolean] skip_me_now Sets the "Me (Now)" option for the Template preparer. Defaults to 0. (optional)
126
+ # @option opts [Boolean] use_preexisting_fields Sets the detection of predefined PDF fields. Defaults to 0. (optional)
127
+ # @option opts [Hash] metadata Key-value data attached to the Template and all SignatureRequests created from the Template. (optional)
128
+ # @option opts [Boolean] allow_reassign Sets the ability for signers to reassign the SignatureRequest to other signers. Defaults to 0. (optional)
129
+ #
130
+ # @return [HelloSign::Resource::Template] a Template
131
+ #
132
+ # @example
133
+ # template_draft = @client.create_embedded_template_draft(
134
+ # test_mode: 1,
135
+ # subject: 'The NDA we talked about',
136
+ # requester_email_address: 'requester@example.com',
137
+ # message: 'Please sign this NDA and then we can discuss more. Let me know if you have any questions.',
138
+ # signer_roles: [
139
+ # {
140
+ # name: 'Manager',
141
+ # order: 0
142
+ # },
143
+ # {
144
+ # name: 'Client',
145
+ # order: 1
146
+ # }
147
+ # ],
148
+ # attachments: [{
149
+ # name: 'Passport',
150
+ # instructions: 'Upload your US Passport',
151
+ # signer_index: 0,
152
+ # required: true
153
+ # },
154
+ # {
155
+ # name: 'Driver's License',
156
+ # instructions: 'Upload your CA Driver's License',
157
+ # signer_index: 1,
158
+ # required: false
159
+ # }
160
+ # ],
161
+ # cc_roles: ['HRManager'],
162
+ # files: ['NDA.pdf', 'AppendixA.pdf'],
163
+ # merge_fields: '[
164
+ # {
165
+ # name: 'contract_id',
166
+ # type: 'text'
167
+ # },
168
+ # {
169
+ # name: 'purchase_price',
170
+ # order: 'text'
171
+ # }
172
+ # ]'
173
+ # )
174
+ def create_embedded_template_draft(opts)
175
+ opts[:client_id] ||= self.client_id
176
+ prepare_files opts
177
+ prepare_signer_roles opts
178
+ prepare_attachments opts
179
+ HelloSign::Resource::TemplateDraft.new post("/template/create_embedded_draft", body: opts)
180
+ end
181
+
182
+ # Downloads the original files of a specified Template.
183
+ # @option opts [String] template_id The Template ID to retrieve.
184
+ # @option opts [String] file_type Determines the format of the file - either 'pdf' or 'zip' depending on the file type desired. Defaults to pdf. (optional)
185
+ # @option opts [Boolean] get_url Response contains a URL link to the file if set to true. Links are only available for PDFs and have a TTL of 3 days. Defaults to false. (optional)
186
+ #
187
+ # @return a PDF or Zip
188
+ #
189
+ # @example
190
+ # file = @client.get_template_files template_id: 'f57db65d3f933b5316d398057a36176831451a35', file_type: 'zip'
191
+ def get_template_files(opts)
192
+ path = "/template/files/#{opts[:template_id]}"
193
+ if opts[:file_type]
194
+ path = path + "?file_type=#{opts[:file_type]}"
195
+ end
196
+ if opts[:get_url]
197
+ separator = opts[:file_type].nil? ? '?' : '&'
198
+ path = path + "#{separator}get_url=#{opts[:get_url]}"
199
+ end
200
+
201
+ get(path)
202
+ end
203
+
204
+ # Overlays a new file with the overlay of the specified Template.
205
+ # @option opts [String] template_id The Template ID to update.
206
+ # @option opts [Array<String>] files Specified file path(s) to upload file(s) to send for signature. Currently we only support use of either the files parameter or file_urls parameter, not both.
207
+ # @option opts [Array<String>] file_urls URL(s) for HelloSign to download the file(s) to send for signature. Currently we only support use of either the files parameter or file_urls parameter, not both.
208
+ # @option opts [String] subject The updated default Template title alias. (optional)
209
+ # @option opts [String] message The updated default message in the email that will be sent to the signer(s). (optional)
210
+ # @option opts [String] client_id The API App Client ID associated with the Template. (optional)
211
+ # @option opts [Boolean] test_mode Indicates if this is a test Template. SignatureRequests using this Template will not be legally binding if set to 1. Defaults to 0. (optional)
212
+ #
213
+ # @return a Template ID
214
+ #
215
+ # @example
216
+ # templates = @client.update_template_files template_id: 'f57db65d3f933b5316d398057a36176831451a35', file: '@NDA.pdf'
217
+ #
218
+ def update_template_files(opts)
219
+ template_id = opts.delete(:template_id)
220
+ path = "/template/update_files/#{template_id}"
221
+ prepare_files opts
222
+
223
+ HelloSign::Resource::Template.new post(path, body: opts)
224
+ end
225
+ end
226
+ end
227
+ end
@@ -0,0 +1,328 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (C) 2014 hellosign.com
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ module HelloSign
24
+ module Api
25
+ # Contains all the API calls for the UnclaimedDraft resource.
26
+ # Take a look at our API documentation for creating UnclaimedDrafts (https://app.hellosign.com/api/reference#UnclaimedDraft)
27
+ # for more information about this.
28
+ #
29
+ # @author [hellosign]
30
+
31
+ module UnclaimedDraft
32
+
33
+ # Creates a new UnclaimedDraft that can be claimed using the claim_url.
34
+ # The first authenticated user to access the claim_url claims the Draft and will be shown either the "Sign and send" or the "Request signature" page with the Draft loaded.
35
+ # Subsequent access to the claim_url will result in a 404 not found error.
36
+ # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. Defaults to 0. (optional)
37
+ # @option opts [Array<String>] files Specifies the file path(s) to send for the SignatureRequest.
38
+ # @option opts [Array<String>] file_urls Specifies the URL(s) for the file(s) to send for the SignatureRequest.
39
+ # @option opts [String] type The type of UnclaimedDraft to create. Use "send_document" to create a claimable file, and "request_signature" for a claimable SignatureRequest.
40
+ # * For "send_document," only the file parameter is required.
41
+ # * For "request_signature," then signer name and email_address are required.
42
+ # @option opts [String] subject The subject in the email that will be sent to the signer(s). (optional)
43
+ # @option opts [String] message The custom message in the email that will be sent to the signer(s). (optional)
44
+ # @option opts [Array<Hash>] signers Sets a list of signers, each item is a Hash with these keys:
45
+ # * name (String) Signer's name
46
+ # * email_address (String) Signer's email address
47
+ # * order (Integer) The order the signers are required to sign in (optional)
48
+ # @option opts [Array<Hash>] attachments Sets a list of attachments signers can upload
49
+ # * name (String) Attachment name
50
+ # * instructions (String) Instructions for uploading the attachment. (optional)
51
+ # * signer_index (Integer) The signer's unique number.
52
+ # * required (Boolean) Determines if the signer is required to upload this attachment. Defaults to 0. (Optional)
53
+ # @option opts [Array<Hash>] custom_fields An array of custom merge fields, representing those present on the document with Text Tags or form_fields_per_document (optional)
54
+ # * name (String) Custom field name or "Field Label"
55
+ # * value (String) The value of the field. This data will appear on the SignatureRequest.
56
+ # @option opts [Array<String>] cc_email_addresses The email addresses that should be CCed on the SignatureRequest. (optional)
57
+ # @option opts [String] signing_redirect_url Redirects the signer(s) to this URL after completing the SignatureRequest. (optional)
58
+ # @option opts [Boolean] use_text_tags Indicates whether the SignatureRequest should have Text Tags enabled. Defaults to 0. (optional)
59
+ # @option opts [Boolean] hide_text_tags Indicates whether the Text Tags should be removed automatically. Note that this is not the preferred method. Defaults to 0. (optional)
60
+ # @option opts [Boolean] use_preexisting_fields Sets the detection of predefined PDF fields. Defaults to 0. (optional)
61
+ # @option opts [Hash] metadata Key-value data attached to the SignatureRequest. (optional)
62
+ # @option opts [Boolean] allow_decline Allows signers to decline the SignatureRequest. Defaults to 0. (optional)
63
+ # @option opts [Boolean] allow_reassign Allows signers to reassign the SignatureRequest to another signer. Defaults to 0. (optional)
64
+ # @option opts [Array<Hash>] form_fields_per_document The fields that should appear on the document. (optional)
65
+ # @option opts [Hash] signing_options Specifies the types allowed for creating a signature. (optional)
66
+ #
67
+ # @return [HelloSign::Resource::UnclaimedDraft] an UnclaimedDraft
68
+ #
69
+ # @example type: send_document
70
+ # unclaimed_draft = @client.create_unclaimed_draft(
71
+ # test_mode: 1,
72
+ # files: ['NDA.pdf', 'AppendixA.pdf']
73
+ # )
74
+ #
75
+ # @example type: request_signature
76
+ # unclaimed_draft = @client.create_unclaimed_draft(
77
+ # test_mode: 1,
78
+ # type: 'request_signature',
79
+ # subject: 'The NDA we talked about',
80
+ # message: 'Please sign this NDA and then we can discuss more. Let me know if you have any questions.',
81
+ # metadata: {
82
+ # client_id: '1234',
83
+ # custom_text: 'NDA #9'
84
+ # },
85
+ # signers: [
86
+ # {
87
+ # email_address: 'jack@example.com',
88
+ # name: 'Jack',
89
+ # order: 0
90
+ # },
91
+ # {
92
+ # email_address: 'jill@example.com',
93
+ # name: 'Jill',
94
+ # order: 1
95
+ # }
96
+ # ],
97
+ # attachments: [{
98
+ # name: 'Passport',
99
+ # instructions: 'Upload your US Passport',
100
+ # signer_index: 0,
101
+ # required: true
102
+ # },
103
+ # {
104
+ # name: 'Driver's License',
105
+ # instructions: 'Upload your CA Driver's License',
106
+ # signer_index: 1,
107
+ # required: false
108
+ # }
109
+ # ],
110
+ # cc_email_addresses: ['lawyer@example.com', 'lawyer@example2.com'],
111
+ # files: ['NDA.pdf', 'AppendixA.pdf'],
112
+ # signing_options: {
113
+ # draw: true,
114
+ # type: true,
115
+ # upload: false,
116
+ # phone: true,
117
+ # default: 'phone'
118
+ # }
119
+ # )
120
+ #
121
+ def create_unclaimed_draft opts
122
+ prepare_files opts
123
+ prepare_signers opts
124
+ prepare_form_fields opts
125
+ prepare_custom_fields opts
126
+ prepare_attachments opts
127
+
128
+ HelloSign::Resource::UnclaimedDraft.new post('/unclaimed_draft/create', body: opts)
129
+ end
130
+
131
+ # Creates a new Embedded UnclaimedDraft that can be opened in an embedded iFrame.
132
+ # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. Defaults to 0. (optional)
133
+ # @option opts [String] client_id The API App Client ID associated with this Embedded UnclaimedDraft.
134
+ # @option opts [Array<String>] files Use files to indicate the uploaded file(s) to send for signature. Currently we only support use of either the files parameter or file_urls parameter, not both.
135
+ # @option opts [Array<String>] file_urls Use file_urls to have HelloSign download the file(s) to send for signature. Currently we only support use of either the files parameter or file_urls parameter, not both.
136
+ # @option opts [String] requester_email_address The email address of the requester, if "request_signature" type.
137
+ # @option opts [String] type The type of UnclaimedDraft to create. Use "send_document" to create a claimable file, and "request_signature" for a claimable signature request.
138
+ # * For "send_document," only the file parameter is required.
139
+ # * For "request_signature," then signer name and email_address are required.
140
+ # @option opts [String] subject Sets the subject in the email sent to the signer(s). (optional)
141
+ # @option opts [String] message Sets the message in the email sent to the signer(s). (optional)
142
+ # @option opts [Array<Hash>] signers Sets a list of signers, each item is a Hash with these keys:
143
+ # * name (String) Signer's name
144
+ # * email_address (String) Signer's email address
145
+ # * order (Integer) The order the signers are required to sign in (optional)
146
+ # @option opts [Array<Hash>] attachments Sets a list of attachments signers can upload
147
+ # * name (String) Attachment name
148
+ # * instructions (String) Instructions for uploading the attachment. (optional)
149
+ # * signer_index (Integer) The signer's unique number.
150
+ # * required (Boolean) Determines if the signer is required to upload this attachment. Defaults to 0. (Optional)
151
+ # @option opts [Array<String>] cc_email_addresses The email addresses that should be CCed on the SignatureRequest. (optional)
152
+ # @option opts [String] signing_redirect_url Redirects the signer(s) to this URL after completing the SignatureRequest. (optional)
153
+ # @option opts [Array<Hash>] custom_fields An array of custom merge fields, representing those present on the document with Text Tags or form_fields_per_document (optional)
154
+ # * name (String) Custom field name or "Field Label"
155
+ # * value (String) The value of the field. This data will appear on the SignatureRequest.
156
+ # @option opts [Boolean] use_text_tags Indicates whether the SignatureRequest should have Text Tags enabled. Defaults to 0. (optional)
157
+ # @option opts [Boolean] hide_text_tags Indicates whether the Text Tags should be removed automatically. Note that this is not the preferred method. Defaults to 0. (optional)
158
+ # @option opts [Boolean] use_preexisting_fields Sets the detection of predefined PDF fields. Defaults to 0. (optional)
159
+ # @option opts [Boolean] is_for_embedded_signing Enable the UnclaimedDraft to be used for an Embedded SignatureRequest. Defaults to 0. (optional)
160
+ # @option opts [Boolean] skip_me_now Disables the "Me (Now)" option for the preparer. Not available for type "send_document." Defaults to 0. (optional)
161
+ # @option opts [Hash] metadata Key-value data attached to the SignatureRequest. (optional)
162
+ # @option opts [Boolean] allow_decline Allows signers to decline the SignatureRequest. Defaults to 0. (optional)
163
+ # @option opts [Boolean] allow_reassign Allows signers to reassign the SignatureRequest to another signer. Defaults to 0. (optional)
164
+ # @option opts [Array<Hash>] form_fields_per_document The fields that should appear on the document. (optional)
165
+ # @option opts [Hash] signing_options Specifies the types allowed for creating a signature. (optional)
166
+ #
167
+ # @return [HelloSign::Resource::UnclaimedDraft] an UnclaimedDraft
168
+ #
169
+ # @example type: request_signature
170
+ # unclaimed_draft = @client.create_embedded_unclaimed_draft(
171
+ # test_mode: 1,
172
+ # type: 'request_signature',
173
+ # subject: 'The NDA we talked about',
174
+ # requester_email_address: 'requester@example.com',
175
+ # message: 'Please sign this NDA and then we can discuss more. Let me know if you have any questions.',
176
+ # metadata: {
177
+ # client_id: '1234',
178
+ # custom_text: 'NDA #9'
179
+ # },
180
+ # signers: [
181
+ # {
182
+ # email_address: 'jack@example.com',
183
+ # name: 'Jack',
184
+ # order: 0
185
+ # },
186
+ # {
187
+ # email_address: 'jill@example.com',
188
+ # name: 'Jill',
189
+ # order: 1
190
+ # }
191
+ # ],
192
+ # attachments: [{
193
+ # name: 'Passport',
194
+ # instructions: 'Upload your US Passport',
195
+ # signer_index: 0,
196
+ # required: true
197
+ # },
198
+ # {
199
+ # name: 'Driver's License',
200
+ # instructions: 'Upload your CA Driver's License',
201
+ # signer_index: 1,
202
+ # required: false
203
+ # }
204
+ # ],
205
+ # cc_email_addresses: ['lawyer@example.com', 'lawyer@example2.com'],
206
+ # files: ['NDA.pdf', 'AppendixA.pdf'],
207
+ # signing_options: {
208
+ # draw: true,
209
+ # type: true,
210
+ # upload: false,
211
+ # phone: true,
212
+ # default: 'phone'
213
+ # }
214
+ # )
215
+ def create_embedded_unclaimed_draft(opts)
216
+ opts[:client_id] ||= self.client_id
217
+ prepare_files opts
218
+ prepare_signers opts
219
+ prepare_form_fields opts
220
+ prepare_custom_fields opts
221
+ prepare_attachments opts
222
+
223
+ HelloSign::Resource::UnclaimedDraft.new post('/unclaimed_draft/create_embedded', body: opts)
224
+ end
225
+
226
+ # Creates a new Embedded UnclaimedDraft from a Template that can be opened in an embedded iFrame.
227
+ # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. Defaults to 0. (optional)
228
+ # @option opts [String] client_id The API App Client ID associated with the UnclaimedDraft.
229
+ # @option opts [String] template_id The Template ID to use when creating the UnclaimedDraft.
230
+ # * Use template_ids[%i%] if using multiple templates, replacing %i% with an integer to indicate the order of the Templates
231
+ # @option opts [String] requester_email_address The email address of the requester, if "request_signature" type.
232
+ # @option opts [String] title Assigns a title to the SignatureRequest. (optional)
233
+ # @option opts [String] subject Sets the subject in the email sent to the signer(s). (optional)
234
+ # @option opts [String] message Sets the message in the email sent to the signer(s). (optional)
235
+ # @option opts [Array<Hash>] signers List of signers
236
+ # * role (String) The signer role indicated on the Template.
237
+ # * name (String) Signer's name
238
+ # * email_address (String) Signer's email address
239
+ # @option opts [Array<Hash>] ccs The individual(s) to be CC'd on the SignatureRequest. Required when a CC role exists for the Template.
240
+ # * role (String) The CC role indicated on the Template. Note that the role name is case sensitive.
241
+ # * email_address (String) CC Recipient's email address
242
+ # @option opts [String] signing_redirect_url Redirects the signer(s) to this URL after completing the SignatureRequest. (optional)
243
+ # @option opts [String] requesting_redirect_url Redirects the requester to this URL after sending a SignatureRequest. (optional)
244
+ # @option opts [Hash] metadata Key-value data attached to the SignatureRequest. (optional)
245
+ # @option opts [Array<Hash>] custom_fields An array of custom merge fields, representing those present in the Template. (optional)
246
+ # * name (String) Custom field name or "Field Label"
247
+ # * value (String) The value of the field. This data will appear on the SignatureRequest.
248
+ # @option opts [Array<String>] files Specifies the file path(s) to append to the SignatureRequest. (optional)
249
+ # @option opts [Array<String>] file_urls Specifies the URL(s) for the file(s) to append to the SignatureRequest. (optional)
250
+ # @option opts [Boolean] skip_me_now Disables the "Me (Now)" option for the preparer. Not available for type "send_document." Defaults to 0. (optional)
251
+ # @option opts [Boolean] allow_decline Allows signers to decline the SignatureRequest. Defaults to 0. (optional)
252
+ # @option opts [Boolean] allow_reassign Allows signers to reassign the SignatureRequest to another signer. Defaults to 0. (optional)
253
+ # @option opts [Hash] signing_options Specifies the types allowed for creating a signature. (optional)
254
+ #
255
+ # @return [HelloSign::Resource::UnclaimedDraft] an UnclaimedDraft
256
+ #
257
+ # @example type: request_signature
258
+ # unclaimed_draft = @client.create_embedded_unclaimed_draft_with_template(
259
+ # test_mode: 1,
260
+ # subject: 'The NDA we talked about',
261
+ # template_id: 'c26b8a16784a872da37ea946b9ddec7c1e11dff6',
262
+ # requester_email_address: 'requester@example.com',
263
+ # message: 'Please sign this NDA and then we can discuss more. Let me know if you have any questions.',
264
+ # files: ['NDA.pdf', 'AppendixA.pdf'],
265
+ # metadata: {
266
+ # client_id: '1234',
267
+ # custom_text: 'NDA #9'
268
+ # },
269
+ # signers: [
270
+ # {
271
+ # email_address: 'george@example.com',
272
+ # name: 'George',
273
+ # role: 'Client'
274
+ # }
275
+ # ],
276
+ # ccs: [
277
+ # {
278
+ # email_address:'accounting@example.com',
279
+ # role: 'Accounting'
280
+ # }
281
+ # ],
282
+ # custom_fields: {
283
+ # Cost: '$20,000'
284
+ # },
285
+ # signing_options: {
286
+ # draw: true,
287
+ # type: true,
288
+ # upload: false,
289
+ # phone: true,
290
+ # default: 'phone'
291
+ # }
292
+ # )
293
+ def create_embedded_unclaimed_draft_with_template(opts)
294
+ opts[:client_id] ||= self.client_id
295
+ prepare_signers opts
296
+ prepare_custom_fields opts
297
+ prepare_ccs opts
298
+ prepare_templates opts
299
+ prepare_files opts
300
+
301
+ HelloSign::Resource::UnclaimedDraft.new post('/unclaimed_draft/create_embedded_with_template', body: opts)
302
+ end
303
+
304
+ # Creates a new SignatureRequest from an Embedded UnclaimedDraft.
305
+ # @option opts [String] signature_request_id The SignatureRequest ID to edit and resend.
306
+ # @option opts [String] client_id The API App Client ID associated with the UnclaimedDraft.
307
+ # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. Defaults to 0. (optional)
308
+ # @option opts [String] requesting_redirect_url Redirects the requester to this URL after sending a SignatureRequest. (optional)
309
+ # @option opts [String] signing_redirect_url Redirects the signer(s) to this URL after completing the SignatureRequest. (optional)
310
+ # @option opts [Boolean] is_for_embedded_signing Enable the UnclaimedDraft to be used for an Embedded SignatureRequest. Defaults to 0. (optional)
311
+ #
312
+ # @return [HelloSign::Resource::UnclaimedDraft] an UnclaimedDraft
313
+ #
314
+ # @example
315
+ # unclaimed_draft = @client.edit_and_resend_unclaimed_draft(
316
+ # signature_request_id: '75cdf7dc8b323d43b347e4a3614d1f822bd09491',
317
+ # test_mode: 1,
318
+ # client_id: 'b6b8e7deaf8f0b95c029dca049356d4a2cf9710a',
319
+ # )
320
+ def edit_and_resend_unclaimed_draft(opts)
321
+ signature_request_id = opts.delete(:signature_request_id)
322
+ path = "/unclaimed_draft/edit_and_resend/#{signature_request_id}"
323
+
324
+ HelloSign::Resource::UnclaimedDraft.new post(path, body: opts)
325
+ end
326
+ end
327
+ end
328
+ end