groupdocs 0.3.11 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,22 @@
|
|
1
|
+
module GroupDocs
|
2
|
+
class Signature::Envelope::Log < Api::Entity
|
3
|
+
|
4
|
+
# @attr [String] id
|
5
|
+
attr_accessor :id
|
6
|
+
# @attr [String] date
|
7
|
+
attr_accessor :date
|
8
|
+
# @attr [String] userName
|
9
|
+
attr_accessor :userName
|
10
|
+
# @attr [String] action
|
11
|
+
attr_accessor :action
|
12
|
+
# @attr [String] remoteAddress
|
13
|
+
attr_accessor :remoteAddress
|
14
|
+
|
15
|
+
# Human-readable accessors
|
16
|
+
alias_method :remote_address, :remoteAddress
|
17
|
+
alias_method :remote_address=, :remoteAddress=
|
18
|
+
alias_method :user_name, :userName
|
19
|
+
alias_method :user_name=, :userName=
|
20
|
+
|
21
|
+
end # Signature::Envelope::Log
|
22
|
+
end # GroupDocs
|
@@ -0,0 +1,253 @@
|
|
1
|
+
module GroupDocs
|
2
|
+
class Signature::Field < Api::Entity
|
3
|
+
|
4
|
+
require 'groupdocs/signature/field/location'
|
5
|
+
|
6
|
+
FIELD_TYPES = {
|
7
|
+
signature: 1,
|
8
|
+
single_line: 2,
|
9
|
+
multiline: 3,
|
10
|
+
date: 4,
|
11
|
+
dropdown: 5,
|
12
|
+
checkbox: 6,
|
13
|
+
}
|
14
|
+
|
15
|
+
#
|
16
|
+
# Returns array of predefined lists.
|
17
|
+
#
|
18
|
+
# @param [Hash] options Hash of options
|
19
|
+
# @option options [String] :id Filter by identifier
|
20
|
+
# @param [Hash] access Access credentials
|
21
|
+
# @option access [String] :client_id
|
22
|
+
# @option access [String] :private_key
|
23
|
+
# @return [Array<GroupDocs::Signature::Field>]
|
24
|
+
#
|
25
|
+
def self.get!(options = {}, access = {})
|
26
|
+
api = Api::Request.new do |request|
|
27
|
+
request[:access] = access
|
28
|
+
request[:method] = :GET
|
29
|
+
request[:path] = '/signature/{{client_id}}/fields'
|
30
|
+
end
|
31
|
+
api.add_params(options)
|
32
|
+
json = api.execute!
|
33
|
+
|
34
|
+
json[:fields].map do |field|
|
35
|
+
new(field)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# @attr [String] id
|
40
|
+
attr_accessor :id
|
41
|
+
# @attr [String] templateId
|
42
|
+
attr_accessor :templateId
|
43
|
+
# @attr [String] recipientId
|
44
|
+
attr_accessor :recipientId
|
45
|
+
# @attr [String] signatureFieldId
|
46
|
+
attr_accessor :signatureFieldId
|
47
|
+
# @attr [String] name
|
48
|
+
attr_accessor :name
|
49
|
+
# @attr [Integer] graphSizeW
|
50
|
+
attr_accessor :graphSizeW
|
51
|
+
# @attr [Integer] graphSizeH
|
52
|
+
attr_accessor :graphSizeH
|
53
|
+
# @attr [String] getDataFrom
|
54
|
+
attr_accessor :getDataFrom
|
55
|
+
# @attr [String] regularExpression
|
56
|
+
attr_accessor :regularExpression
|
57
|
+
# @attr [String] fontName
|
58
|
+
attr_accessor :fontName
|
59
|
+
# @attr [String] fontColor
|
60
|
+
attr_accessor :fontColor
|
61
|
+
# @attr [Integer] fontSize
|
62
|
+
attr_accessor :fontSize
|
63
|
+
# @attr [Boolean] fontBold
|
64
|
+
attr_accessor :fontBold
|
65
|
+
# @attr [Boolean] fontItalic
|
66
|
+
attr_accessor :fontItalic
|
67
|
+
# @attr [Boolean] fontUnderline
|
68
|
+
attr_accessor :fontUnderline
|
69
|
+
# @attr [Boolean] isSystem
|
70
|
+
attr_accessor :isSystem
|
71
|
+
# @attr [Boolean] mandatory
|
72
|
+
attr_accessor :mandatory
|
73
|
+
# @attr [Symbol] fieldType
|
74
|
+
attr_accessor :fieldType
|
75
|
+
# @attr [Boolean] acceptableValues
|
76
|
+
attr_accessor :acceptableValues
|
77
|
+
# @attr [String] defaultValue
|
78
|
+
attr_accessor :defaultValue
|
79
|
+
# @attr [String] tooltip
|
80
|
+
attr_accessor :tooltip
|
81
|
+
# @attr [Integer] input
|
82
|
+
attr_accessor :input
|
83
|
+
# @attr [Integer] order
|
84
|
+
attr_accessor :order
|
85
|
+
# @attr [String] textRows
|
86
|
+
attr_accessor :textRows
|
87
|
+
# @attr [String] textColumns
|
88
|
+
attr_accessor :textColumns
|
89
|
+
# @attr [GroupDocs::Signature::Field::Location] location
|
90
|
+
attr_accessor :location
|
91
|
+
# @attr [Array<GroupDocs::Signature::Field::Location>] locations
|
92
|
+
attr_accessor :locations
|
93
|
+
|
94
|
+
# Human-readable accessors
|
95
|
+
alias_method :template_id, :templateId
|
96
|
+
alias_method :template_id=, :templateId=
|
97
|
+
alias_method :recipient_id, :recipientId
|
98
|
+
alias_method :recipient_id=, :recipientId=
|
99
|
+
alias_method :signature_field_id, :signatureFieldId
|
100
|
+
alias_method :signature_field_id=, :signatureFieldId=
|
101
|
+
alias_method :graph_size_w, :graphSizeW
|
102
|
+
alias_method :graph_size_w=, :graphSizeW=
|
103
|
+
alias_method :graph_size_w, :graphSizeW
|
104
|
+
alias_method :graph_size_w=, :graphSizeW=
|
105
|
+
alias_method :graph_size_width, :graphSizeW
|
106
|
+
alias_method :graph_size_width=, :graphSizeW=
|
107
|
+
alias_method :graph_size_h, :graphSizeH
|
108
|
+
alias_method :graph_size_h=, :graphSizeH=
|
109
|
+
alias_method :graph_size_height, :graphSizeH
|
110
|
+
alias_method :graph_size_height=, :graphSizeH=
|
111
|
+
alias_method :get_data_from, :getDataFrom
|
112
|
+
alias_method :get_data_from=, :getDataFrom=
|
113
|
+
alias_method :regular_expression, :regularExpression
|
114
|
+
alias_method :regular_expression=, :regularExpression=
|
115
|
+
alias_method :font_name, :fontName
|
116
|
+
alias_method :font_name=, :fontName=
|
117
|
+
alias_method :font_color, :fontColor
|
118
|
+
alias_method :font_color=, :fontColor=
|
119
|
+
alias_method :font_size, :fontSize
|
120
|
+
alias_method :font_size=, :fontSize=
|
121
|
+
alias_method :font_bold, :fontBold
|
122
|
+
alias_method :font_bold=, :fontBold=
|
123
|
+
alias_method :font_italic, :fontItalic
|
124
|
+
alias_method :font_italic=, :fontItalic=
|
125
|
+
alias_method :font_underline, :fontUnderline
|
126
|
+
alias_method :font_underline=, :fontUnderline=
|
127
|
+
alias_method :is_system, :isSystem
|
128
|
+
alias_method :is_system=, :isSystem=
|
129
|
+
alias_method :acceptable_values, :acceptableValues
|
130
|
+
alias_method :acceptable_values=, :acceptableValues=
|
131
|
+
alias_method :default_value, :defaultValue
|
132
|
+
alias_method :default_value=, :defaultValue=
|
133
|
+
alias_method :text_rows, :textRows
|
134
|
+
alias_method :text_rows=, :textRows=
|
135
|
+
alias_method :text_columns, :textColumns
|
136
|
+
alias_method :text_columns=, :textColumns=
|
137
|
+
|
138
|
+
#
|
139
|
+
# Converts location to GroupDocs::Signature::Field::Location object.
|
140
|
+
#
|
141
|
+
# @param [GroupDocs::Signature::Field::Location, Hash] location
|
142
|
+
#
|
143
|
+
def location=(location)
|
144
|
+
if location
|
145
|
+
@location = (location.is_a?(GroupDocs::Signature::Field::Location) ? location : Signature::Field::Location.new(location))
|
146
|
+
locations ? locations << @location : self.locations = [@location]
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
#
|
151
|
+
# Converts each location to GroupDocs::Signature::Field::Location object.
|
152
|
+
#
|
153
|
+
# @param [Array<GroupDocs::Signature::Field::Location, Hash>] locations
|
154
|
+
#
|
155
|
+
def locations=(locations)
|
156
|
+
if locations
|
157
|
+
@locations = locations.map do |location|
|
158
|
+
if location.is_a?(GroupDocs::Signature::Field::Location)
|
159
|
+
location
|
160
|
+
else
|
161
|
+
Signature::Field::Location.new(location)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
#
|
168
|
+
# Saves field type in machine-readable format.
|
169
|
+
# @param [Symbol, Integer] type
|
170
|
+
#
|
171
|
+
def field_type=(type)
|
172
|
+
if type.is_a?(Symbol)
|
173
|
+
type = FIELD_TYPES[type]
|
174
|
+
end
|
175
|
+
|
176
|
+
@fieldType = type
|
177
|
+
end
|
178
|
+
alias_method :type=, :field_type=
|
179
|
+
|
180
|
+
#
|
181
|
+
# Returns field type in human-readable format.
|
182
|
+
# @return [Symbol]
|
183
|
+
#
|
184
|
+
def field_type
|
185
|
+
FIELD_TYPES.invert[@fieldType]
|
186
|
+
end
|
187
|
+
alias_method :type, :field_type
|
188
|
+
|
189
|
+
#
|
190
|
+
# Creates signature field.
|
191
|
+
#
|
192
|
+
# @example
|
193
|
+
# field = GroupDocs::Signature::Field.new
|
194
|
+
# field.name = 'Field'
|
195
|
+
# field.create!
|
196
|
+
#
|
197
|
+
# @param [Hash] access Access credentials
|
198
|
+
# @option access [String] :client_id
|
199
|
+
# @option access [String] :private_key
|
200
|
+
#
|
201
|
+
def create!(access = {})
|
202
|
+
json = Api::Request.new do |request|
|
203
|
+
request[:access] = access
|
204
|
+
request[:method] = :POST
|
205
|
+
request[:path] = '/signature/{{client_id}}/field'
|
206
|
+
request[:request_body] = to_hash
|
207
|
+
end.execute!
|
208
|
+
|
209
|
+
self.id = json[:field][:id]
|
210
|
+
end
|
211
|
+
|
212
|
+
#
|
213
|
+
# Modifies signature field.
|
214
|
+
#
|
215
|
+
# @example
|
216
|
+
# field = GroupDocs::Signature::Field.get!.first
|
217
|
+
# field.name = 'Field'
|
218
|
+
# field.modify!
|
219
|
+
#
|
220
|
+
# @param [Hash] access Access credentials
|
221
|
+
# @option access [String] :client_id
|
222
|
+
# @option access [String] :private_key
|
223
|
+
#
|
224
|
+
def modify!(access = {})
|
225
|
+
Api::Request.new do |request|
|
226
|
+
request[:access] = access
|
227
|
+
request[:method] = :POST
|
228
|
+
request[:path] = "/signature/{{client_id}}/fields/#{id}"
|
229
|
+
request[:request_body] = to_hash
|
230
|
+
end.execute!
|
231
|
+
end
|
232
|
+
|
233
|
+
#
|
234
|
+
# Deletes signature field.
|
235
|
+
#
|
236
|
+
# @example Remove all created fields
|
237
|
+
# fields = GroupDocs::Signature::Field.get!.select { |field| !field.is_system }
|
238
|
+
# fields.each { |field| field.delete! }
|
239
|
+
#
|
240
|
+
# @param [Hash] access Access credentials
|
241
|
+
# @option access [String] :client_id
|
242
|
+
# @option access [String] :private_key
|
243
|
+
#
|
244
|
+
def delete!(access = {})
|
245
|
+
Api::Request.new do |request|
|
246
|
+
request[:access] = access
|
247
|
+
request[:method] = :DELETE
|
248
|
+
request[:path] = "/signature/{{client_id}}/fields/#{id}"
|
249
|
+
end.execute!
|
250
|
+
end
|
251
|
+
|
252
|
+
end # Signature::Field
|
253
|
+
end # GroupDocs
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module GroupDocs
|
2
|
+
class Signature::Field::Location < Api::Entity
|
3
|
+
|
4
|
+
# @attr [String] id
|
5
|
+
attr_accessor :id
|
6
|
+
# @attr [String] documentId
|
7
|
+
attr_accessor :documentId
|
8
|
+
# @attr [String] fieldId
|
9
|
+
attr_accessor :fieldId
|
10
|
+
# @attr [Integer] page
|
11
|
+
attr_accessor :page
|
12
|
+
# @attr [Float] locationX
|
13
|
+
attr_accessor :locationX
|
14
|
+
# @attr [Float] locationY
|
15
|
+
attr_accessor :locationY
|
16
|
+
# @attr [Float] locationWidth
|
17
|
+
attr_accessor :locationWidth
|
18
|
+
# @attr [Float] locationHeight
|
19
|
+
attr_accessor :locationHeight
|
20
|
+
# @attr [String] fontName
|
21
|
+
attr_accessor :fontName
|
22
|
+
# @attr [String] fontColor
|
23
|
+
attr_accessor :fontColor
|
24
|
+
# @attr [Integer] fontSize
|
25
|
+
attr_accessor :fontSize
|
26
|
+
# @attr [Boolean] fontBold
|
27
|
+
attr_accessor :fontBold
|
28
|
+
# @attr [Boolean] fontItalic
|
29
|
+
attr_accessor :fontItalic
|
30
|
+
# @attr [Boolean] fontUnderline
|
31
|
+
attr_accessor :fontUnderline
|
32
|
+
|
33
|
+
# Human-readable accessors
|
34
|
+
alias_method :document_id, :documentId
|
35
|
+
alias_method :document_id=, :documentId=
|
36
|
+
alias_method :field_id, :fieldId
|
37
|
+
alias_method :field_id=, :fieldId=
|
38
|
+
alias_method :location_x, :locationX
|
39
|
+
alias_method :location_x=, :locationX=
|
40
|
+
alias_method :x, :locationX
|
41
|
+
alias_method :x=, :locationX=
|
42
|
+
alias_method :location_y, :locationY
|
43
|
+
alias_method :location_y=, :locationY=
|
44
|
+
alias_method :y, :locationY
|
45
|
+
alias_method :y=, :locationY=
|
46
|
+
alias_method :location_w, :locationWidth
|
47
|
+
alias_method :location_w=, :locationWidth=
|
48
|
+
alias_method :location_width, :locationWidth
|
49
|
+
alias_method :location_width=, :locationWidth=
|
50
|
+
alias_method :w, :locationWidth
|
51
|
+
alias_method :w=, :locationWidth=
|
52
|
+
alias_method :location_h, :locationHeight
|
53
|
+
alias_method :location_h=, :locationHeight=
|
54
|
+
alias_method :location_height, :locationHeight
|
55
|
+
alias_method :location_height=, :locationHeight=
|
56
|
+
alias_method :h, :locationHeight
|
57
|
+
alias_method :h=, :locationHeight=
|
58
|
+
alias_method :font_name, :fontName
|
59
|
+
alias_method :font_name=, :fontName=
|
60
|
+
alias_method :font_color, :fontColor
|
61
|
+
alias_method :font_color=, :fontColor=
|
62
|
+
alias_method :font_size, :fontSize
|
63
|
+
alias_method :font_size=, :fontSize=
|
64
|
+
alias_method :font_bold, :fontBold
|
65
|
+
alias_method :font_bold=, :fontBold=
|
66
|
+
alias_method :font_italic, :fontItalic
|
67
|
+
alias_method :font_italic=, :fontItalic=
|
68
|
+
alias_method :font_underline, :fontUnderline
|
69
|
+
alias_method :font_underline=, :fontUnderline=
|
70
|
+
|
71
|
+
end # Signature::Field::Location
|
72
|
+
end # GroupDocs
|
@@ -0,0 +1,202 @@
|
|
1
|
+
module GroupDocs
|
2
|
+
class Signature::Form < Api::Entity
|
3
|
+
|
4
|
+
include Signature::EntityMethods
|
5
|
+
extend Signature::ResourceMethods
|
6
|
+
|
7
|
+
STATUSES = {
|
8
|
+
draft: -1,
|
9
|
+
in_progress: 1,
|
10
|
+
completed: 2,
|
11
|
+
archived: 3,
|
12
|
+
}
|
13
|
+
|
14
|
+
#
|
15
|
+
# Returns a list of all forms.
|
16
|
+
#
|
17
|
+
# @param [Hash] options Hash of options
|
18
|
+
# @option options [Integer] :page Page to start with
|
19
|
+
# @option options [Integer] :records How many items to list
|
20
|
+
# @option options [Integer] :status_id Filter by status identifier
|
21
|
+
# @option options [String] :document Filter by document GUID
|
22
|
+
# @option options [String] :date Filter by date
|
23
|
+
# @option options [String] :name Filter by name
|
24
|
+
# @param [Hash] access Access credentials
|
25
|
+
# @option access [String] :client_id
|
26
|
+
# @option access [String] :private_key
|
27
|
+
# @return [Array<GroupDocs::Signature::Envelope>]
|
28
|
+
#
|
29
|
+
def self.all!(options = {}, access = {})
|
30
|
+
status_id = options.delete(:status_id)
|
31
|
+
options[:statusId] = status_id if status_id
|
32
|
+
|
33
|
+
api = Api::Request.new do |request|
|
34
|
+
request[:access] = access
|
35
|
+
request[:method] = :GET
|
36
|
+
request[:path] = '/signature/{{client_id}}/forms'
|
37
|
+
end
|
38
|
+
api.add_params(options)
|
39
|
+
json = api.execute!
|
40
|
+
|
41
|
+
json[:forms].map do |form|
|
42
|
+
new(form)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# @attr [String] id
|
47
|
+
attr_accessor :id
|
48
|
+
# @attr [String] name
|
49
|
+
attr_accessor :name
|
50
|
+
# @attr [String] ownerGuid
|
51
|
+
attr_accessor :ownerGuid
|
52
|
+
# @attr [String] templateGuid
|
53
|
+
attr_accessor :templateGuid
|
54
|
+
# @attr [String] createdTimeStamp
|
55
|
+
attr_accessor :createdTimeStamp
|
56
|
+
# @attr [String] statusDateTime
|
57
|
+
attr_accessor :statusDateTime
|
58
|
+
# @attr [Integer] documentsCount
|
59
|
+
attr_accessor :documentsCount
|
60
|
+
# @attr [Integer] documentsPages
|
61
|
+
attr_accessor :documentsPages
|
62
|
+
# @attr [Integer] participantsCount
|
63
|
+
attr_accessor :participantsCount
|
64
|
+
# @attr [Array] fieldsInFinalFileName
|
65
|
+
attr_accessor :fieldsInFinalFileName
|
66
|
+
# @attr [Boolean] canParticipantDownloadForm
|
67
|
+
attr_accessor :canParticipantDownloadForm
|
68
|
+
# @attr [Symbol] status
|
69
|
+
attr_accessor :status
|
70
|
+
|
71
|
+
# Human-readable accessors
|
72
|
+
alias_method :owner_guid, :ownerGuid
|
73
|
+
alias_method :owner_guid=, :ownerGuid=
|
74
|
+
alias_method :template_guid, :templateGuid
|
75
|
+
alias_method :template_guid=, :templateGuid=
|
76
|
+
alias_method :created_time_stamp, :createdTimeStamp
|
77
|
+
alias_method :created_time_stamp=, :createdTimeStamp=
|
78
|
+
alias_method :status_date_time, :statusDateTime
|
79
|
+
alias_method :status_date_time=, :statusDateTime=
|
80
|
+
alias_method :documents_count, :documentsCount
|
81
|
+
alias_method :documents_count=, :documentsCount=
|
82
|
+
alias_method :documents_pages, :documentsPages
|
83
|
+
alias_method :documents_pages=, :documentsPages=
|
84
|
+
alias_method :participants_count, :participantsCount
|
85
|
+
alias_method :participants_count=, :participantsCount=
|
86
|
+
alias_method :fields_in_final_file_name, :fieldsInFinalFileName
|
87
|
+
alias_method :fields_in_final_file_name=, :fieldsInFinalFileName=
|
88
|
+
alias_method :can_participant_download_form, :canParticipantDownloadForm
|
89
|
+
alias_method :can_participant_download_form=, :canParticipantDownloadForm=
|
90
|
+
|
91
|
+
#
|
92
|
+
# Converts status to human-readable format.
|
93
|
+
# @return [Symbol]
|
94
|
+
#
|
95
|
+
def status
|
96
|
+
STATUSES.invert[@status]
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
# Creates form.
|
101
|
+
#
|
102
|
+
# @example
|
103
|
+
# template = GroupDocs::Singature::Template!.get!('09662aab7187f31444476288ebaf7da4')
|
104
|
+
# form = GroupDocs::Signature::Form.new
|
105
|
+
# form.name = "Form"
|
106
|
+
# form.create! template
|
107
|
+
#
|
108
|
+
# @param [GroupDocs::Signature::Template] template
|
109
|
+
# @param [Hash] options Hash of options
|
110
|
+
# @option options [Integer] :assembly_id Assembly GUID to use
|
111
|
+
# @param [Hash] access Access credentials
|
112
|
+
# @option access [String] :client_id
|
113
|
+
# @option access [String] :private_key
|
114
|
+
# @raise [ArgumentError] if template is not GroupDocs::Signature::Template
|
115
|
+
#
|
116
|
+
def create!(template, options = {}, access = {})
|
117
|
+
template.is_a?(GroupDocs::Signature::Template) or raise ArgumentError,
|
118
|
+
"Template should be GroupDocs::Signature::Template object, received: #{template.inspect}"
|
119
|
+
|
120
|
+
assembly_id = options.delete(:assembly_id)
|
121
|
+
options[:assemblyId] = assembly_id if assembly_id
|
122
|
+
|
123
|
+
api = Api::Request.new do |request|
|
124
|
+
request[:access] = access
|
125
|
+
request[:method] = :POST
|
126
|
+
request[:path] = '/signature/{{client_id}}/form'
|
127
|
+
request[:request_body] = to_hash
|
128
|
+
end
|
129
|
+
api.add_params(options.merge(name: name, templateId: template.id))
|
130
|
+
json = api.execute!
|
131
|
+
|
132
|
+
self.id = json[:form][:id]
|
133
|
+
end
|
134
|
+
|
135
|
+
#
|
136
|
+
# Returns documents array.
|
137
|
+
#
|
138
|
+
# @param [Hash] access Access credentials
|
139
|
+
# @option access [String] :client_id
|
140
|
+
# @option access [String] :private_key
|
141
|
+
# @return [Array<GroupDocs::Document>]
|
142
|
+
#
|
143
|
+
def documents!(access = {})
|
144
|
+
json = Api::Request.new do |request|
|
145
|
+
request[:access] = access
|
146
|
+
request[:method] = :GET
|
147
|
+
request[:path] = "/signature/{{client_id}}/forms/#{id}/documents"
|
148
|
+
end.execute!
|
149
|
+
|
150
|
+
json[:documents].map do |document|
|
151
|
+
file = Storage::File.new(guid: document[:documentId], name: document[:name])
|
152
|
+
Document.new(document.merge(file: file))
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
#
|
157
|
+
# Publishes form.
|
158
|
+
#
|
159
|
+
# @param [Hash] access Access credentials
|
160
|
+
# @option access [String] :client_id
|
161
|
+
# @option access [String] :private_key
|
162
|
+
#
|
163
|
+
def publish!(access = {})
|
164
|
+
Api::Request.new do |request|
|
165
|
+
request[:access] = access
|
166
|
+
request[:method] = :PUT
|
167
|
+
request[:path] = "/signature/{{client_id}}/forms/#{id}/publish"
|
168
|
+
end.execute!
|
169
|
+
end
|
170
|
+
|
171
|
+
#
|
172
|
+
# Completes form.
|
173
|
+
#
|
174
|
+
# @param [Hash] access Access credentials
|
175
|
+
# @option access [String] :client_id
|
176
|
+
# @option access [String] :private_key
|
177
|
+
#
|
178
|
+
def complete!(access = {})
|
179
|
+
Api::Request.new do |request|
|
180
|
+
request[:access] = access
|
181
|
+
request[:method] = :PUT
|
182
|
+
request[:path] = "/signature/{{client_id}}/forms/#{id}/complete"
|
183
|
+
end.execute!
|
184
|
+
end
|
185
|
+
|
186
|
+
#
|
187
|
+
# Archives completed form.
|
188
|
+
#
|
189
|
+
# @param [Hash] access Access credentials
|
190
|
+
# @option access [String] :client_id
|
191
|
+
# @option access [String] :private_key
|
192
|
+
#
|
193
|
+
def archive!(access = {})
|
194
|
+
Api::Request.new do |request|
|
195
|
+
request[:access] = access
|
196
|
+
request[:method] = :PUT
|
197
|
+
request[:path] = "/signature/{{client_id}}/forms/#{id}/archive"
|
198
|
+
end.execute!
|
199
|
+
end
|
200
|
+
|
201
|
+
end # Signature::Form
|
202
|
+
end # GroupDocs
|