groupdocs 0.3.11 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +150 -0
- data/README.md +6 -58
- data/Rakefile +1 -1
- data/examples/README.md +13 -0
- data/examples/annotations/Gemfile +5 -0
- data/examples/annotations/app.rb +67 -0
- data/groupdocs.gemspec +3 -3
- data/lib/groupdocs.rb +11 -2
- data/lib/groupdocs/api/entity.rb +17 -1
- data/lib/groupdocs/api/helpers/path_helper.rb +10 -10
- data/lib/groupdocs/api/helpers/rest_helper.rb +7 -2
- data/lib/groupdocs/api/helpers/url_helper.rb +2 -4
- data/lib/groupdocs/api/request.rb +2 -4
- data/lib/groupdocs/datasource.rb +2 -2
- data/lib/groupdocs/datasource/field.rb +1 -1
- data/lib/groupdocs/document.rb +6 -18
- data/lib/groupdocs/document/annotation.rb +25 -2
- data/lib/groupdocs/document/annotation/reply.rb +6 -10
- data/lib/groupdocs/document/change.rb +1 -1
- data/lib/groupdocs/document/field.rb +1 -1
- data/lib/groupdocs/document/metadata.rb +1 -1
- data/lib/groupdocs/document/rectangle.rb +1 -1
- data/lib/groupdocs/document/view.rb +1 -1
- data/lib/groupdocs/job.rb +51 -8
- data/lib/groupdocs/questionnaire.rb +2 -2
- data/lib/groupdocs/questionnaire/execution.rb +1 -1
- data/lib/groupdocs/questionnaire/page.rb +1 -1
- data/lib/groupdocs/questionnaire/question.rb +1 -1
- data/lib/groupdocs/questionnaire/question/answer.rb +1 -1
- data/lib/groupdocs/signature.rb +134 -0
- data/lib/groupdocs/signature/contact.rb +141 -0
- data/lib/groupdocs/signature/envelope.rb +376 -0
- data/lib/groupdocs/signature/envelope/log.rb +22 -0
- data/lib/groupdocs/signature/field.rb +253 -0
- data/lib/groupdocs/signature/field/location.rb +72 -0
- data/lib/groupdocs/signature/form.rb +202 -0
- data/lib/groupdocs/signature/list.rb +93 -0
- data/lib/groupdocs/signature/recipient.rb +47 -0
- data/lib/groupdocs/signature/role.rb +84 -0
- data/lib/groupdocs/signature/shared.rb +6 -0
- data/lib/groupdocs/signature/shared/document_methods.rb +98 -0
- data/lib/groupdocs/signature/shared/entity_fields.rb +94 -0
- data/lib/groupdocs/signature/shared/entity_methods.rb +145 -0
- data/lib/groupdocs/signature/shared/field_methods.rb +282 -0
- data/lib/groupdocs/signature/shared/recipient_methods.rb +63 -0
- data/lib/groupdocs/signature/shared/resource_methods.rb +65 -0
- data/lib/groupdocs/signature/template.rb +104 -0
- data/lib/groupdocs/storage/file.rb +69 -62
- data/lib/groupdocs/storage/folder.rb +54 -88
- data/lib/groupdocs/storage/package.rb +1 -1
- data/lib/groupdocs/subscription.rb +113 -0
- data/lib/groupdocs/subscription/limit.rb +24 -0
- data/lib/groupdocs/user.rb +22 -2
- data/lib/groupdocs/version.rb +1 -1
- data/spec/groupdocs/api/entity_spec.rb +14 -0
- data/spec/groupdocs/api/helpers/path_helper_spec.rb +6 -19
- data/spec/groupdocs/api/helpers/rest_helper_spec.rb +9 -0
- data/spec/groupdocs/api/request_spec.rb +2 -7
- data/spec/groupdocs/datasource_spec.rb +3 -7
- data/spec/groupdocs/document/annotation/reply_spec.rb +11 -20
- data/spec/groupdocs/document/annotation_spec.rb +35 -31
- data/spec/groupdocs/document/field_spec.rb +1 -4
- data/spec/groupdocs/document/rectangle_spec.rb +10 -22
- data/spec/groupdocs/document_spec.rb +7 -27
- data/spec/groupdocs/job_spec.rb +43 -0
- data/spec/groupdocs/questionnaire/question_spec.rb +2 -6
- data/spec/groupdocs/questionnaire_spec.rb +3 -7
- data/spec/groupdocs/signature/contact_spec.rb +129 -0
- data/spec/groupdocs/signature/envelope/log_spec.rb +23 -0
- data/spec/groupdocs/signature/envelope_spec.rb +296 -0
- data/spec/groupdocs/signature/field/location_spec.rb +73 -0
- data/spec/groupdocs/signature/field_spec.rb +264 -0
- data/spec/groupdocs/signature/form_spec.rb +174 -0
- data/spec/groupdocs/signature/list_spec.rb +92 -0
- data/spec/groupdocs/signature/recipient_spec.rb +37 -0
- data/spec/groupdocs/signature/role_spec.rb +100 -0
- data/spec/groupdocs/signature/template_spec.rb +82 -0
- data/spec/groupdocs/signature_spec.rb +117 -0
- data/spec/groupdocs/storage/file_spec.rb +76 -61
- data/spec/groupdocs/storage/folder_spec.rb +43 -90
- data/spec/groupdocs/storage/package_spec.rb +1 -2
- data/spec/groupdocs/subscription/limit_spec.rb +24 -0
- data/spec/groupdocs/subscription_spec.rb +85 -0
- data/spec/groupdocs/user_spec.rb +27 -18
- data/spec/groupdocs_spec.rb +11 -0
- data/spec/spec_helper.rb +10 -1
- data/spec/support/files/envelope.zip +0 -0
- data/spec/support/json/annotation_access_set.json +11 -0
- data/spec/support/json/contact_add.json +12 -0
- data/spec/support/json/contacts_get.json +19 -0
- data/spec/support/json/contacts_import.json +8 -0
- data/spec/support/json/envelope_get.json +46 -0
- data/spec/support/json/envelope_logs.json +16 -0
- data/spec/support/json/envelopes_all.json +48 -0
- data/spec/support/json/envelopes_resources.json +31 -0
- data/spec/support/json/form_get.json +21 -0
- data/spec/support/json/forms_all.json +23 -0
- data/spec/support/json/job_get.json +30 -0
- data/spec/support/json/list_add.json +12 -0
- data/spec/support/json/lists_get.json +19 -0
- data/spec/support/json/signature_create.json +12 -0
- data/spec/support/json/signature_field_add.json +25 -0
- data/spec/support/json/signature_fields_get.json +27 -0
- data/spec/support/json/signature_roles_get.json +17 -0
- data/spec/support/json/signatures_get.json +19 -0
- data/spec/support/json/subscription_plan_get.json +9 -0
- data/spec/support/json/subscription_plans_get.json +17 -0
- data/spec/support/json/template_get.json +35 -0
- data/spec/support/json/template_get_documents.json +15 -0
- data/spec/support/json/template_get_recipients.json +20 -0
- data/spec/support/json/templates_all.json +37 -0
- data/spec/support/json/user_users_get.json +27 -0
- data/spec/support/shared_examples/signature/shared/document_methods.rb +68 -0
- data/spec/support/shared_examples/signature/shared/entity_fields.rb +89 -0
- data/spec/support/shared_examples/signature/shared/entity_methods.rb +116 -0
- data/spec/support/shared_examples/signature/shared/field_methods.rb +188 -0
- data/spec/support/shared_examples/signature/shared/recipient_methods.rb +42 -0
- data/spec/support/shared_examples/signature/shared/resource_methods.rb +46 -0
- metadata +139 -29
- data/lib/groupdocs/extensions.rb +0 -1
- data/lib/groupdocs/extensions/lookup.rb +0 -52
- data/spec/support/shared_examples/extensions/lookup.rb +0 -57
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
module GroupDocs
|
|
2
|
+
class Signature
|
|
3
|
+
#
|
|
4
|
+
# Envelope and template entities share the same set of field methods.
|
|
5
|
+
#
|
|
6
|
+
# @see GroupDocs::Signature::Envelope
|
|
7
|
+
# @see GroupDocs::Signature::Template
|
|
8
|
+
#
|
|
9
|
+
module FieldMethods
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
# Returns an array of fields for document and recipient.
|
|
13
|
+
#
|
|
14
|
+
# @example Get fields from template
|
|
15
|
+
# template = GroupDocs::Signature::Template.get!("g94h5g84hj9g4gf23i40j")
|
|
16
|
+
# document = template.documents!.first
|
|
17
|
+
# recipient = template.recipients!.first
|
|
18
|
+
# template.fields! document, recipient
|
|
19
|
+
#
|
|
20
|
+
# @example Get fields from envelope
|
|
21
|
+
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
|
22
|
+
# document = envelope.documents!.first
|
|
23
|
+
# recipient = envelope.recipients!.first
|
|
24
|
+
# envelope.fields! document, recipient
|
|
25
|
+
#
|
|
26
|
+
# @param [GroupDocs::Document] document
|
|
27
|
+
# @param [GroupDocs::Signature::Recipient] recipient
|
|
28
|
+
# @param [Hash] access Access credentials
|
|
29
|
+
# @option access [String] :client_id
|
|
30
|
+
# @option access [String] :private_key
|
|
31
|
+
# @raise [ArgumentError] if document is not GroupDocs::Document
|
|
32
|
+
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
|
33
|
+
#
|
|
34
|
+
def fields!(document, recipient, access = {})
|
|
35
|
+
document.is_a?(GroupDocs::Document) or raise ArgumentError,
|
|
36
|
+
"Document should be GroupDocs::Document object, received: #{document.inspect}"
|
|
37
|
+
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
|
38
|
+
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
|
39
|
+
|
|
40
|
+
api = Api::Request.new do |request|
|
|
41
|
+
request[:access] = access
|
|
42
|
+
request[:method] = :GET
|
|
43
|
+
request[:path] = "/signature/{{client_id}}/#{pluralized_class_name}/#{id}/fields"
|
|
44
|
+
end
|
|
45
|
+
api.add_params(document: document.file.guid, recipient: recipient.id)
|
|
46
|
+
json = api.execute!
|
|
47
|
+
|
|
48
|
+
json[:fields].map do |field|
|
|
49
|
+
Signature::Field.new(field)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
#
|
|
54
|
+
# Adds field for document and recipient.
|
|
55
|
+
#
|
|
56
|
+
# @example Add field to template
|
|
57
|
+
# template = GroupDocs::Signature::Template.get!("g94h5g84hj9g4gf23i40j")
|
|
58
|
+
# field = GroupDocs::Signature::Field.get!.detect { |f| f.name == "Signature" }
|
|
59
|
+
# field.location = { location_x: 0.1, location_y: 0.1, page: 1 }
|
|
60
|
+
# document = template.documents!.first
|
|
61
|
+
# recipient = template.recipients!.first
|
|
62
|
+
# template.add_field! field, document, recipient
|
|
63
|
+
#
|
|
64
|
+
# @example Add field to envelope
|
|
65
|
+
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
|
66
|
+
# field = GroupDocs::Signature::Field.get!.detect { |f| f.name == "Signature" }
|
|
67
|
+
# field.location = { location_x: 0.1, location_y: 0.1, page: 1 }
|
|
68
|
+
# document = envelope.documents!.first
|
|
69
|
+
# recipient = envelope.recipients!.first
|
|
70
|
+
# envelope.add_field! field, document, recipient
|
|
71
|
+
#
|
|
72
|
+
# @param [GroupDocs::Signature::Field] field
|
|
73
|
+
# @param [GroupDocs::Document] document
|
|
74
|
+
# @param [GroupDocs::Signature::Recipient] recipient
|
|
75
|
+
# @param [Hash] access Access credentials
|
|
76
|
+
# @option access [String] :client_id
|
|
77
|
+
# @option access [String] :private_key
|
|
78
|
+
# @raise [ArgumentError] if field is not GroupDocs::Signature::Field
|
|
79
|
+
# @raise [ArgumentError] if document is not GroupDocs::Document
|
|
80
|
+
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
|
81
|
+
# @raise [ArgumentError] if field does not specify location
|
|
82
|
+
#
|
|
83
|
+
def add_field!(field, document, recipient, access = {})
|
|
84
|
+
field.is_a?(GroupDocs::Signature::Field) or raise ArgumentError,
|
|
85
|
+
"Field should be GroupDocs::Signature::Field object, received: #{field.inspect}"
|
|
86
|
+
document.is_a?(GroupDocs::Document) or raise ArgumentError,
|
|
87
|
+
"Document should be GroupDocs::Document object, received: #{document.inspect}"
|
|
88
|
+
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
|
89
|
+
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
|
90
|
+
field.location or raise ArgumentError,
|
|
91
|
+
"You have to specify field location, received: #{field.location.inspect}"
|
|
92
|
+
|
|
93
|
+
payload = field.to_hash # field itself
|
|
94
|
+
payload.merge!(field.location.to_hash) # location should added in plain view (i.e. not "location": {...})
|
|
95
|
+
payload.merge!(forceNewField: true) # create new field flag
|
|
96
|
+
|
|
97
|
+
Api::Request.new do |request|
|
|
98
|
+
request[:access] = access
|
|
99
|
+
request[:method] = :POST
|
|
100
|
+
request[:path] = "/signature/{{client_id}}/#{pluralized_class_name}/#{id}/documents/#{document.file.guid}/recipient/#{recipient.id}/field/#{field.id}"
|
|
101
|
+
request[:request_body] = payload
|
|
102
|
+
end.execute!
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
#
|
|
106
|
+
# Modifies document field.
|
|
107
|
+
#
|
|
108
|
+
# @example Modify template field
|
|
109
|
+
# template = GroupDocs::Signature::Template.get!("g94h5g84hj9g4gf23i40j")
|
|
110
|
+
# document = template.documents!.first
|
|
111
|
+
# recipient = template.recipients!.first
|
|
112
|
+
# field = template.fields!(document, recipient).first
|
|
113
|
+
# field.name = "Field"
|
|
114
|
+
# template.modify_field! field, document
|
|
115
|
+
#
|
|
116
|
+
# @example Modify envelope field
|
|
117
|
+
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
|
118
|
+
# document = envelope.documents!.first
|
|
119
|
+
# recipient = envelope.recipients!.first
|
|
120
|
+
# field = envelope.fields!(document, recipient).first
|
|
121
|
+
# field.name = "Field"
|
|
122
|
+
# envelope.modify_field! field, document
|
|
123
|
+
#
|
|
124
|
+
# @param [GroupDocs::Signature::Field] field
|
|
125
|
+
# @param [GroupDocs::Document] document
|
|
126
|
+
# @param [Hash] access Access credentials
|
|
127
|
+
# @option access [String] :client_id
|
|
128
|
+
# @option access [String] :private_key
|
|
129
|
+
# @raise [ArgumentError] if field is not GroupDocs::Signature::Field
|
|
130
|
+
# @raise [ArgumentError] if document is not GroupDocs::Document
|
|
131
|
+
#
|
|
132
|
+
def modify_field!(field, document, access = {})
|
|
133
|
+
field.is_a?(GroupDocs::Signature::Field) or raise ArgumentError,
|
|
134
|
+
"Field should be GroupDocs::Signature::Field object, received: #{field.inspect}"
|
|
135
|
+
document.is_a?(GroupDocs::Document) or raise ArgumentError,
|
|
136
|
+
"Document should be GroupDocs::Document object, received: #{document.inspect}"
|
|
137
|
+
|
|
138
|
+
# prepare payload
|
|
139
|
+
payload = field.to_hash # field itself
|
|
140
|
+
payload.delete(:locations) # remove locations array
|
|
141
|
+
payload.merge!(field.locations.first.to_hash) # location should added in plain view (i.e. not "locations": [{...}])
|
|
142
|
+
|
|
143
|
+
Api::Request.new do |request|
|
|
144
|
+
request[:access] = access
|
|
145
|
+
request[:method] = :PUT
|
|
146
|
+
request[:path] = "/signature/{{client_id}}/#{pluralized_class_name}/#{id}/documents/#{document.file.guid}/field/#{field.id}"
|
|
147
|
+
request[:request_body] = payload
|
|
148
|
+
end.execute!
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
#
|
|
152
|
+
# Deletes field.
|
|
153
|
+
#
|
|
154
|
+
# @example Delete field from template
|
|
155
|
+
# template = GroupDocs::Signature::Template.get!("g94h5g84hj9g4gf23i40j")
|
|
156
|
+
# document = template.documents!.first
|
|
157
|
+
# recipient = template.recipients!.first
|
|
158
|
+
# field = template.fields!(document, recipient).first
|
|
159
|
+
# template.delete_field! field
|
|
160
|
+
#
|
|
161
|
+
# @example Delete field from envelope
|
|
162
|
+
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
|
163
|
+
# document = envelope.documents!.first
|
|
164
|
+
# recipient = envelope.recipients!.first
|
|
165
|
+
# field = envelope.fields!(document, recipient).first
|
|
166
|
+
# envelope.delete_field! field
|
|
167
|
+
#
|
|
168
|
+
# @param [GroupDocs::Signature::Field] field
|
|
169
|
+
# @param [Hash] access Access credentials
|
|
170
|
+
# @option access [String] :client_id
|
|
171
|
+
# @option access [String] :private_key
|
|
172
|
+
# @raise [ArgumentError] if field is not GroupDocs::Signature::Field
|
|
173
|
+
#
|
|
174
|
+
def delete_field!(field, access = {})
|
|
175
|
+
field.is_a?(GroupDocs::Signature::Field) or raise ArgumentError,
|
|
176
|
+
"Field should be GroupDocs::Signature::Field object, received: #{field.inspect}"
|
|
177
|
+
|
|
178
|
+
Api::Request.new do |request|
|
|
179
|
+
request[:access] = access
|
|
180
|
+
request[:method] = :DELETE
|
|
181
|
+
request[:path] = "/signature/{{client_id}}/#{pluralized_class_name}/#{id}/fields/#{field.id}"
|
|
182
|
+
end.execute!
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
#
|
|
186
|
+
# Modifies field location.
|
|
187
|
+
#
|
|
188
|
+
# @example Modify field location in template
|
|
189
|
+
# template = GroupDocs::Signature::Template.get!("g94h5g84hj9g4gf23i40j")
|
|
190
|
+
# document = template.documents!.first
|
|
191
|
+
# recipient = template.recipients!.first
|
|
192
|
+
# field = template.fields!(document, recipient).first
|
|
193
|
+
# location = field.locations.first
|
|
194
|
+
# location.x = 0.123
|
|
195
|
+
# location.y = 0.123
|
|
196
|
+
# location.page = 2
|
|
197
|
+
# template.modify_field_location! location, field, document, recipient
|
|
198
|
+
#
|
|
199
|
+
# @example Modify field location in envelope
|
|
200
|
+
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
|
201
|
+
# document = envelope.documents!.first
|
|
202
|
+
# recipient = envelope.recipients!.first
|
|
203
|
+
# field = envelope.fields!(document, recipient).first
|
|
204
|
+
# location = field.locations.first
|
|
205
|
+
# location.x = 0.123
|
|
206
|
+
# location.y = 0.123
|
|
207
|
+
# location.page = 2
|
|
208
|
+
# envelope.modify_field_location! location, field, document, recipient
|
|
209
|
+
#
|
|
210
|
+
# @param [GroupDocs::Signature::Field::Location] location
|
|
211
|
+
# @param [GroupDocs::Signature::Field] field
|
|
212
|
+
# @param [GroupDocs::Document] document
|
|
213
|
+
# @param [GroupDocs::Signature::Recipient] recipient
|
|
214
|
+
# @param [Hash] access Access credentials
|
|
215
|
+
# @option access [String] :client_id
|
|
216
|
+
# @option access [String] :private_key
|
|
217
|
+
# @raise [ArgumentError] if location is not GroupDocs::Signature::Field::Location
|
|
218
|
+
# @raise [ArgumentError] if field is not GroupDocs::Signature::Field
|
|
219
|
+
# @raise [ArgumentError] if document is not GroupDocs::Document
|
|
220
|
+
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
|
221
|
+
#
|
|
222
|
+
def modify_field_location!(location, field, document, recipient, access = {})
|
|
223
|
+
location.is_a?(GroupDocs::Signature::Field::Location) or raise ArgumentError,
|
|
224
|
+
"Location should be GroupDocs::Signature::Field::Location object, received: #{location.inspect}"
|
|
225
|
+
field.is_a?(GroupDocs::Signature::Field) or raise ArgumentError,
|
|
226
|
+
"Field should be GroupDocs::Signature::Field object, received: #{field.inspect}"
|
|
227
|
+
document.is_a?(GroupDocs::Document) or raise ArgumentError,
|
|
228
|
+
"Document should be GroupDocs::Document object, received: #{document.inspect}"
|
|
229
|
+
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
|
230
|
+
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
|
231
|
+
|
|
232
|
+
Api::Request.new do |request|
|
|
233
|
+
request[:access] = access
|
|
234
|
+
request[:method] = :PUT
|
|
235
|
+
request[:path] = "/signature/{{client_id}}/#{pluralized_class_name}/#{id}/documents/#{document.file.guid}/recipient/#{recipient.id}/fields/#{field.id}/locations/#{location.id}"
|
|
236
|
+
request[:request_body] = location.to_hash
|
|
237
|
+
end.execute!
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
#
|
|
241
|
+
# Deletes field location.
|
|
242
|
+
#
|
|
243
|
+
# @example Delete field location in template
|
|
244
|
+
# template = GroupDocs::Signature::Template.get!("g94h5g84hj9g4gf23i40j")
|
|
245
|
+
# document = template.documents!.first
|
|
246
|
+
# recipient = template.recipients!.first
|
|
247
|
+
# field = template.fields!(document, recipient).first
|
|
248
|
+
# location = field.locations.first
|
|
249
|
+
# template.delete_field_location! location, field
|
|
250
|
+
#
|
|
251
|
+
# @example Delete field location in envelope
|
|
252
|
+
# envelope = GroupDocs::Signature::Envelop.get!("g94h5g84hj9g4gf23i40j")
|
|
253
|
+
# document = envelope.documents!.first
|
|
254
|
+
# recipient = envelope.recipients!.first
|
|
255
|
+
# field = envelope.fields!(document, recipient).first
|
|
256
|
+
# location = field.locations.first
|
|
257
|
+
# envelope.delete_field_location! location, field
|
|
258
|
+
#
|
|
259
|
+
# @param [GroupDocs::Signature::Field::Location] location
|
|
260
|
+
# @param [GroupDocs::Signature::Field] field
|
|
261
|
+
# @param [Hash] access Access credentials
|
|
262
|
+
# @option access [String] :client_id
|
|
263
|
+
# @option access [String] :private_key
|
|
264
|
+
# @raise [ArgumentError] if location is not GroupDocs::Signature::Field::Location
|
|
265
|
+
# @raise [ArgumentError] if field is not GroupDocs::Signature::Field
|
|
266
|
+
#
|
|
267
|
+
def delete_field_location!(location, field, access = {})
|
|
268
|
+
location.is_a?(GroupDocs::Signature::Field::Location) or raise ArgumentError,
|
|
269
|
+
"Location should be GroupDocs::Signature::Field::Location object, received: #{location.inspect}"
|
|
270
|
+
field.is_a?(GroupDocs::Signature::Field) or raise ArgumentError,
|
|
271
|
+
"Field should be GroupDocs::Signature::Field object, received: #{field.inspect}"
|
|
272
|
+
|
|
273
|
+
Api::Request.new do |request|
|
|
274
|
+
request[:access] = access
|
|
275
|
+
request[:method] = :DELETE
|
|
276
|
+
request[:path] = "/signature/{{client_id}}/#{pluralized_class_name}/#{id}/fields/#{field.id}/locations/#{location.id}"
|
|
277
|
+
end.execute!
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
end # FieldMethods
|
|
281
|
+
end # Signature
|
|
282
|
+
end # GroupDocs
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
module GroupDocs
|
|
2
|
+
class Signature
|
|
3
|
+
#
|
|
4
|
+
# Envelope and template entities share the same set of recipient methods.
|
|
5
|
+
#
|
|
6
|
+
# @see GroupDocs::Signature::Envelope
|
|
7
|
+
# @see GroupDocs::Signature::Template
|
|
8
|
+
#
|
|
9
|
+
module RecipientMethods
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
# Returns recipients array.
|
|
13
|
+
#
|
|
14
|
+
# @param [Hash] access Access credentials
|
|
15
|
+
# @option access [String] :client_id
|
|
16
|
+
# @option access [String] :private_key
|
|
17
|
+
# @return [Array<GroupDocs::Signature::Recipient>]
|
|
18
|
+
#
|
|
19
|
+
def recipients!(access = {})
|
|
20
|
+
json = Api::Request.new do |request|
|
|
21
|
+
request[:access] = access
|
|
22
|
+
request[:method] = :GET
|
|
23
|
+
request[:path] = "/signature/{{client_id}}/#{pluralized_class_name}/#{id}/recipients"
|
|
24
|
+
end.execute!
|
|
25
|
+
|
|
26
|
+
json[:recipients].map do |recipient|
|
|
27
|
+
Signature::Recipient.new(recipient)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
#
|
|
32
|
+
# Removes recipient.
|
|
33
|
+
#
|
|
34
|
+
# @example
|
|
35
|
+
# template = GroupDocs::Signature::Template.get!("g94h5g84hj9g4gf23i40j")
|
|
36
|
+
# recipient = template.recipients!.first
|
|
37
|
+
# template.remove_recipient! recipient
|
|
38
|
+
#
|
|
39
|
+
# @example
|
|
40
|
+
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
|
41
|
+
# recipient = envelope.recipients!.first
|
|
42
|
+
# envelope.remove_recipient! recipient
|
|
43
|
+
#
|
|
44
|
+
# @param [GroupDocs::Signature::Recipient] recipient
|
|
45
|
+
# @param [Hash] access Access credentials
|
|
46
|
+
# @option access [String] :client_id
|
|
47
|
+
# @option access [String] :private_key
|
|
48
|
+
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
|
49
|
+
#
|
|
50
|
+
def remove_recipient!(recipient, access = {})
|
|
51
|
+
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
|
52
|
+
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
|
53
|
+
|
|
54
|
+
Api::Request.new do |request|
|
|
55
|
+
request[:access] = access
|
|
56
|
+
request[:method] = :DELETE
|
|
57
|
+
request[:path] = "/signature/{{client_id}}/#{pluralized_class_name}/#{id}/recipients/#{recipient.id}"
|
|
58
|
+
end.execute!
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end # RecipientMethods
|
|
62
|
+
end # Signature
|
|
63
|
+
end # GroupDocs
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
module GroupDocs
|
|
2
|
+
class Signature
|
|
3
|
+
#
|
|
4
|
+
# Envelope and template entities share the same set of resource methods.
|
|
5
|
+
#
|
|
6
|
+
# @see GroupDocs::Signature::Form
|
|
7
|
+
# @see GroupDocs::Signature::Envelope
|
|
8
|
+
# @see GroupDocs::Signature::Template
|
|
9
|
+
#
|
|
10
|
+
module ResourceMethods
|
|
11
|
+
|
|
12
|
+
#
|
|
13
|
+
# Returns a list of resources.
|
|
14
|
+
#
|
|
15
|
+
# @example
|
|
16
|
+
# resources = GroupDocs::Signature::Envelope.resources!
|
|
17
|
+
# resources[:documents]
|
|
18
|
+
# #=> [#<GroupDocs::Document>]
|
|
19
|
+
# resources[:recipients]
|
|
20
|
+
# #=> [#<GroupDocs::Signature::Recipient>]
|
|
21
|
+
# resources[:dates]
|
|
22
|
+
# #=> ["2012-09-25T00:00:00.0000000"]
|
|
23
|
+
#
|
|
24
|
+
# @param [Hash] options Hash of options
|
|
25
|
+
# @option options [Array<Integer>] :status_ids List of status identifiers to filter. Doesn't work for template
|
|
26
|
+
# @param [Hash] access Access credentials
|
|
27
|
+
# @option access [String] :client_id
|
|
28
|
+
# @option access [String] :private_key
|
|
29
|
+
# @return [Hash]
|
|
30
|
+
#
|
|
31
|
+
def resources!(options = {}, access = {})
|
|
32
|
+
class_name = self.name.split('::').last.downcase
|
|
33
|
+
|
|
34
|
+
# filter doesn't work for template
|
|
35
|
+
unless class_name == 'template'
|
|
36
|
+
ids = options.delete(:status_ids)
|
|
37
|
+
options[:statusIds] = ids.join(?,) if ids
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
api = Api::Request.new do |request|
|
|
41
|
+
request[:access] = access
|
|
42
|
+
request[:method] = :GET
|
|
43
|
+
request[:path] = "/signature/{{client_id}}/#{class_name}s/resources"
|
|
44
|
+
end
|
|
45
|
+
api.add_params(options)
|
|
46
|
+
json = api.execute!
|
|
47
|
+
|
|
48
|
+
resources = {}
|
|
49
|
+
json.each do |key, value|
|
|
50
|
+
resources[key] = case key
|
|
51
|
+
when :documents
|
|
52
|
+
value.map { |doc| Document.new(file: Storage::File.new(doc)) }
|
|
53
|
+
when :recipients
|
|
54
|
+
value.map { |recipient| Signature::Recipient.new(recipient) }
|
|
55
|
+
else
|
|
56
|
+
value
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
resources
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end # ResourceMethods
|
|
64
|
+
end # Signature
|
|
65
|
+
end # GroupDocs
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
module GroupDocs
|
|
2
|
+
class Signature::Template < Api::Entity
|
|
3
|
+
|
|
4
|
+
include Signature::DocumentMethods
|
|
5
|
+
include Signature::EntityFields
|
|
6
|
+
include Signature::EntityMethods
|
|
7
|
+
include Signature::FieldMethods
|
|
8
|
+
include Signature::RecipientMethods
|
|
9
|
+
extend Signature::ResourceMethods
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
# Returns a list of all templates.
|
|
13
|
+
#
|
|
14
|
+
# @param [Hash] options Hash of options
|
|
15
|
+
# @option options [Integer] :page Page to start with
|
|
16
|
+
# @option options [Integer] :records How many items to list
|
|
17
|
+
# @param [Hash] access Access credentials
|
|
18
|
+
# @option access [String] :client_id
|
|
19
|
+
# @option access [String] :private_key
|
|
20
|
+
# @return [Array<GroupDocs::Signature::Template>]
|
|
21
|
+
#
|
|
22
|
+
def self.all!(options = {}, access = {})
|
|
23
|
+
api = Api::Request.new do |request|
|
|
24
|
+
request[:access] = access
|
|
25
|
+
request[:method] = :GET
|
|
26
|
+
request[:path] = '/signature/{{client_id}}/templates'
|
|
27
|
+
end
|
|
28
|
+
api.add_params(options)
|
|
29
|
+
json = api.execute!
|
|
30
|
+
|
|
31
|
+
json[:templates].map do |template|
|
|
32
|
+
new(template)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# @attr [Integer] templateExpireTime
|
|
37
|
+
attr_accessor :templateExpireTime
|
|
38
|
+
|
|
39
|
+
# Human-readable accessors
|
|
40
|
+
alias_method :template_expire_time, :templateExpireTime
|
|
41
|
+
alias_method :template_expire_time=, :templateExpireTime=
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# Adds recipient to template.
|
|
45
|
+
#
|
|
46
|
+
# @example
|
|
47
|
+
# roles = GroupDocs::Signature::Role.get!
|
|
48
|
+
# template = GroupDocs::Signature::Template.get!("g94h5g84hj9g4gf23i40j")
|
|
49
|
+
# recipient = GroupDocs::Signature::Recipient.new
|
|
50
|
+
# recipient.nickname = 'John Smith'
|
|
51
|
+
# recipient.role_id = roles.detect { |role| role.name == "Signer" }.id
|
|
52
|
+
# template.add_recipient! recipient
|
|
53
|
+
#
|
|
54
|
+
# @param [GroupDocs::Signature::Recipient] recipient
|
|
55
|
+
# @param [Hash] access Access credentials
|
|
56
|
+
# @option access [String] :client_id
|
|
57
|
+
# @option access [String] :private_key
|
|
58
|
+
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
|
59
|
+
#
|
|
60
|
+
def add_recipient!(recipient, access = {})
|
|
61
|
+
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
|
62
|
+
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
|
63
|
+
|
|
64
|
+
api = Api::Request.new do |request|
|
|
65
|
+
request[:access] = access
|
|
66
|
+
request[:method] = :POST
|
|
67
|
+
request[:path] = "/signature/{{client_id}}/templates/#{id}/recipient"
|
|
68
|
+
end
|
|
69
|
+
api.add_params(nickname: recipient.nickname,
|
|
70
|
+
role: recipient.role_id,
|
|
71
|
+
order: recipient.order)
|
|
72
|
+
api.execute!
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
#
|
|
76
|
+
# Modify recipient of template.
|
|
77
|
+
#
|
|
78
|
+
# @example
|
|
79
|
+
# template = GroupDocs::Signature::Template.get!("g94h5g84hj9g4gf23i40j")
|
|
80
|
+
# recipient = template.recipients!.first
|
|
81
|
+
# recipient.nickname = 'John Smith'
|
|
82
|
+
# template.modify_recipient! recipient
|
|
83
|
+
#
|
|
84
|
+
# @param [GroupDocs::Signature::Recipient] recipient
|
|
85
|
+
# @param [Hash] access Access credentials
|
|
86
|
+
# @option access [String] :client_id
|
|
87
|
+
# @option access [String] :private_key
|
|
88
|
+
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
|
89
|
+
#
|
|
90
|
+
def modify_recipient!(recipient, access = {})
|
|
91
|
+
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
|
92
|
+
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
|
93
|
+
|
|
94
|
+
api = Api::Request.new do |request|
|
|
95
|
+
request[:access] = access
|
|
96
|
+
request[:method] = :PUT
|
|
97
|
+
request[:path] = "/signature/{{client_id}}/templates/#{id}/recipient/#{recipient.id}"
|
|
98
|
+
end
|
|
99
|
+
api.add_params(nickname: recipient.nickname, role: recipient.role_id, order: recipient.order)
|
|
100
|
+
api.execute!
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
end # Signature::Template
|
|
104
|
+
end # GroupDocs
|