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,93 @@
|
|
1
|
+
module GroupDocs
|
2
|
+
class Signature::List < Api::Entity
|
3
|
+
|
4
|
+
#
|
5
|
+
# Returns array of predefined lists.
|
6
|
+
#
|
7
|
+
# @param [Hash] access Access credentials
|
8
|
+
# @option access [String] :client_id
|
9
|
+
# @option access [String] :private_key
|
10
|
+
# @return [Array<GroupDocs::Signature::List>]
|
11
|
+
#
|
12
|
+
def self.get!(access = {})
|
13
|
+
json = Api::Request.new do |request|
|
14
|
+
request[:access] = access
|
15
|
+
request[:method] = :GET
|
16
|
+
request[:path] = '/signature/{{client_id}}/lists'
|
17
|
+
end.execute!
|
18
|
+
|
19
|
+
json[:lists].map do |list|
|
20
|
+
new(list)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# @attr [String] id
|
25
|
+
attr_accessor :id
|
26
|
+
# @attr [String] name
|
27
|
+
attr_accessor :name
|
28
|
+
# @attr [Array<String>] values
|
29
|
+
attr_accessor :values
|
30
|
+
# @attr [String] defaultValue
|
31
|
+
attr_accessor :defaultValue
|
32
|
+
|
33
|
+
# Human-readable accessors
|
34
|
+
alias_method :default_value, :defaultValue
|
35
|
+
alias_method :default_value=, :defaultValue=
|
36
|
+
|
37
|
+
#
|
38
|
+
# Converts values to API compatible view.
|
39
|
+
# @param [Array<String>, String] values
|
40
|
+
#
|
41
|
+
def values=(values)
|
42
|
+
@values = values.is_a?(Array) ? values.join(?;) : values
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# Returns values as array.
|
47
|
+
# @return [Array<String>]
|
48
|
+
#
|
49
|
+
def values
|
50
|
+
@values.split(?;)
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
# Adds predefined list.
|
55
|
+
#
|
56
|
+
# @example
|
57
|
+
# list = GroupDocs::Signature::List.new
|
58
|
+
# list.name = 'Cities'
|
59
|
+
# list.values = %w(London Paris)
|
60
|
+
# list.add!
|
61
|
+
#
|
62
|
+
# @param [Hash] access Access credentials
|
63
|
+
# @option access [String] :client_id
|
64
|
+
# @option access [String] :private_key
|
65
|
+
#
|
66
|
+
def add!(access = {})
|
67
|
+
json = Api::Request.new do |request|
|
68
|
+
request[:access] = access
|
69
|
+
request[:method] = :POST
|
70
|
+
request[:path] = '/signature/{{client_id}}/list'
|
71
|
+
request[:request_body] = to_hash
|
72
|
+
end.execute!
|
73
|
+
|
74
|
+
self.id = json[:list][:id]
|
75
|
+
end
|
76
|
+
|
77
|
+
#
|
78
|
+
# Deletes predefined list.
|
79
|
+
#
|
80
|
+
# @param [Hash] access Access credentials
|
81
|
+
# @option access [String] :client_id
|
82
|
+
# @option access [String] :private_key
|
83
|
+
#
|
84
|
+
def delete!(access = {})
|
85
|
+
Api::Request.new do |request|
|
86
|
+
request[:access] = access
|
87
|
+
request[:method] = :DELETE
|
88
|
+
request[:path] = "/signature/{{client_id}}/lists/#{id}"
|
89
|
+
end.execute!
|
90
|
+
end
|
91
|
+
|
92
|
+
end # Signature::List
|
93
|
+
end # GroupDocs
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module GroupDocs
|
2
|
+
class Signature::Recipient < Api::Entity
|
3
|
+
|
4
|
+
STATUSES = {
|
5
|
+
none: -1,
|
6
|
+
waiting: 0,
|
7
|
+
notified: 1,
|
8
|
+
delegated: 2,
|
9
|
+
rejected: 3,
|
10
|
+
signed: 4,
|
11
|
+
}
|
12
|
+
|
13
|
+
# @attr [String] id
|
14
|
+
attr_accessor :id
|
15
|
+
# @attr [String] email
|
16
|
+
attr_accessor :email
|
17
|
+
# @attr [String] firstName
|
18
|
+
attr_accessor :firstName
|
19
|
+
# @attr [String] lastName
|
20
|
+
attr_accessor :lastName
|
21
|
+
# @attr [String] nickname
|
22
|
+
attr_accessor :nickname
|
23
|
+
# @attr [String] roleId
|
24
|
+
attr_accessor :roleId
|
25
|
+
# @attr [String] order
|
26
|
+
attr_accessor :order
|
27
|
+
# @attr [Symbol] status
|
28
|
+
attr_accessor :status
|
29
|
+
|
30
|
+
# Human-readable accessors
|
31
|
+
alias_method :first_name, :firstName
|
32
|
+
alias_method :first_name=, :firstName=
|
33
|
+
alias_method :last_name, :lastName
|
34
|
+
alias_method :last_name=, :lastName=
|
35
|
+
alias_method :role_id, :roleId
|
36
|
+
alias_method :role_id=, :roleId=
|
37
|
+
|
38
|
+
#
|
39
|
+
# Converts status to human-readable format.
|
40
|
+
# @return [Symbol]
|
41
|
+
#
|
42
|
+
def status
|
43
|
+
STATUSES.invert[@status]
|
44
|
+
end
|
45
|
+
|
46
|
+
end # Signature::Recipient
|
47
|
+
end # GroupDocs
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module GroupDocs
|
2
|
+
class Signature::Role < Api::Entity
|
3
|
+
|
4
|
+
#
|
5
|
+
# Returns array of predefined roles.
|
6
|
+
#
|
7
|
+
# @param [Hash] options Hash of options
|
8
|
+
# @option options [String] :id Filter by identifier
|
9
|
+
# @param [Hash] access Access credentials
|
10
|
+
# @option access [String] :client_id
|
11
|
+
# @option access [String] :private_key
|
12
|
+
# @return [Array<GroupDocs::Signature::role>]
|
13
|
+
#
|
14
|
+
def self.get!(options = {}, access = {})
|
15
|
+
api = Api::Request.new do |request|
|
16
|
+
request[:access] = access
|
17
|
+
request[:method] = :GET
|
18
|
+
request[:path] = '/signature/{{client_id}}/roles'
|
19
|
+
end
|
20
|
+
api.add_params(options)
|
21
|
+
json = api.execute!
|
22
|
+
|
23
|
+
json[:roles].map do |role|
|
24
|
+
new(role)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# @attr [String] id
|
29
|
+
attr_accessor :id
|
30
|
+
# @attr [String] name
|
31
|
+
attr_accessor :name
|
32
|
+
# @attr [Integer] canEdit
|
33
|
+
attr_accessor :canEdit
|
34
|
+
# @attr [Integer] canSign
|
35
|
+
attr_accessor :canSign
|
36
|
+
# @attr [Integer] canAnnotate
|
37
|
+
attr_accessor :canAnnotate
|
38
|
+
# @attr [Integer] canDelegate
|
39
|
+
attr_accessor :canDelegate
|
40
|
+
|
41
|
+
# Human-readable accessors
|
42
|
+
alias_method :can_edit, :canEdit
|
43
|
+
alias_method :can_edit=, :canEdit=
|
44
|
+
alias_method :can_sign, :canSign
|
45
|
+
alias_method :can_sign=, :canSign=
|
46
|
+
alias_method :can_annotate, :canAnnotate
|
47
|
+
alias_method :can_annotate=, :canAnnotate=
|
48
|
+
alias_method :can_delegate, :canDelegate
|
49
|
+
alias_method :can_delegate=, :canDelegate=
|
50
|
+
|
51
|
+
#
|
52
|
+
# Returns true if role can edit.
|
53
|
+
# @return [Boolean]
|
54
|
+
#
|
55
|
+
def can_edit?
|
56
|
+
can_edit == 1
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# Returns true if role can sign.
|
61
|
+
# @return [Boolean]
|
62
|
+
#
|
63
|
+
def can_sign?
|
64
|
+
can_sign == 1
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# Returns true if role can annotate.
|
69
|
+
# @return [Boolean]
|
70
|
+
#
|
71
|
+
def can_annotate?
|
72
|
+
can_annotate == 1
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
# Returns true if role can delegate.
|
77
|
+
# @return [Boolean]
|
78
|
+
#
|
79
|
+
def can_delegate?
|
80
|
+
can_delegate == 1
|
81
|
+
end
|
82
|
+
|
83
|
+
end # Signature::Role
|
84
|
+
end # GroupDocs
|
@@ -0,0 +1,6 @@
|
|
1
|
+
require 'groupdocs/signature/shared/document_methods'
|
2
|
+
require 'groupdocs/signature/shared/entity_fields'
|
3
|
+
require 'groupdocs/signature/shared/entity_methods'
|
4
|
+
require 'groupdocs/signature/shared/field_methods'
|
5
|
+
require 'groupdocs/signature/shared/recipient_methods'
|
6
|
+
require 'groupdocs/signature/shared/resource_methods'
|
@@ -0,0 +1,98 @@
|
|
1
|
+
module GroupDocs
|
2
|
+
class Signature
|
3
|
+
#
|
4
|
+
# Envelope and template entities share the same set of document methods.
|
5
|
+
#
|
6
|
+
# @see GroupDocs::Signature::Envelope
|
7
|
+
# @see GroupDocs::Signature::Template
|
8
|
+
#
|
9
|
+
module DocumentMethods
|
10
|
+
|
11
|
+
#
|
12
|
+
# Returns documents array.
|
13
|
+
#
|
14
|
+
# @param [Hash] access Access credentials
|
15
|
+
# @option access [String] :client_id
|
16
|
+
# @option access [String] :private_key
|
17
|
+
# @return [Array<GroupDocs::Document>]
|
18
|
+
#
|
19
|
+
def documents!(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}/documents"
|
24
|
+
end.execute!
|
25
|
+
|
26
|
+
json[:documents].map do |document|
|
27
|
+
file = Storage::File.new(guid: document[:documentId], name: document[:name])
|
28
|
+
Document.new(document.merge(file: file))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Adds document.
|
34
|
+
#
|
35
|
+
# @example
|
36
|
+
# template = GroupDocs::Signature::Template.get!("g94h5g84hj9g4gf23i40j")
|
37
|
+
# document = GroupDocs::Storage::Folder.list!.last.to_document
|
38
|
+
# template.add_document! document
|
39
|
+
#
|
40
|
+
# @example
|
41
|
+
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
42
|
+
# document = GroupDocs::Storage::Folder.list!.last.to_document
|
43
|
+
# envelope.add_document! document
|
44
|
+
#
|
45
|
+
# @param [GroupDocs::Document] document
|
46
|
+
# @param [Hash] options
|
47
|
+
# @option options [Integer] :order Display order of the document
|
48
|
+
# @param [Hash] access Access credentials
|
49
|
+
# @option access [String] :client_id
|
50
|
+
# @option access [String] :private_key
|
51
|
+
# @raise [ArgumentError] if document is not GroupDocs::Document
|
52
|
+
#
|
53
|
+
def add_document!(document, options = {}, access = {})
|
54
|
+
document.is_a?(GroupDocs::Document) or raise ArgumentError,
|
55
|
+
"Document should be GroupDocs::Document object, received: #{document.inspect}"
|
56
|
+
|
57
|
+
api = Api::Request.new do |request|
|
58
|
+
request[:access] = access
|
59
|
+
request[:method] = :POST
|
60
|
+
request[:path] = "/signature/{{client_id}}/#{pluralized_class_name}/#{id}/document/#{document.file.guid}"
|
61
|
+
end
|
62
|
+
api.add_params(options)
|
63
|
+
api.execute!
|
64
|
+
end
|
65
|
+
|
66
|
+
#
|
67
|
+
# Removes document.
|
68
|
+
#
|
69
|
+
# @example
|
70
|
+
# template = GroupDocs::Signature::Template.get!("g94h5g84hj9g4gf23i40j")
|
71
|
+
# document = template.documents!.first
|
72
|
+
# template.remove_document! document
|
73
|
+
#
|
74
|
+
# @example
|
75
|
+
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
76
|
+
# document = envelope.documents!.first
|
77
|
+
# envelope.remove_document! document
|
78
|
+
#
|
79
|
+
# @param [GroupDocs::Document] document
|
80
|
+
# @param [Hash] access Access credentials
|
81
|
+
# @option access [String] :client_id
|
82
|
+
# @option access [String] :private_key
|
83
|
+
# @raise [ArgumentError] if document is not GroupDocs::Document
|
84
|
+
#
|
85
|
+
def remove_document!(document, access = {})
|
86
|
+
document.is_a?(GroupDocs::Document) or raise ArgumentError,
|
87
|
+
"Document should be GroupDocs::Document object, received: #{document.inspect}"
|
88
|
+
|
89
|
+
Api::Request.new do |request|
|
90
|
+
request[:access] = access
|
91
|
+
request[:method] = :DELETE
|
92
|
+
request[:path] = "/signature/{{client_id}}/#{pluralized_class_name}/#{id}/documents/#{document.file.guid}"
|
93
|
+
end.execute!
|
94
|
+
end
|
95
|
+
|
96
|
+
end # DocumentMethods
|
97
|
+
end # Signature
|
98
|
+
end # GroupDocs
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module GroupDocs
|
2
|
+
class Signature
|
3
|
+
#
|
4
|
+
# Envelope and template entities share the same set of fields.
|
5
|
+
#
|
6
|
+
# @see GroupDocs::Signature::Envelope
|
7
|
+
# @see GroupDocs::Signature::Template
|
8
|
+
#
|
9
|
+
module EntityFields
|
10
|
+
|
11
|
+
# @attr [String] id
|
12
|
+
attr_accessor :id
|
13
|
+
# @attr [String] name
|
14
|
+
attr_accessor :name
|
15
|
+
# @attr [Integer] ownerId
|
16
|
+
attr_accessor :ownerId
|
17
|
+
# @attr [String] ownerGuid
|
18
|
+
attr_accessor :ownerGuid
|
19
|
+
# @attr [String] reminderTime
|
20
|
+
attr_accessor :reminderTime
|
21
|
+
# @attr [Integer] stepExpireTime
|
22
|
+
attr_accessor :stepExpireTime
|
23
|
+
# @attr [Boolean] ownerShouldSign
|
24
|
+
attr_accessor :ownerShouldSign
|
25
|
+
# @attr [Boolean] orderedSignature
|
26
|
+
attr_accessor :orderedSignature
|
27
|
+
# @attr [String] emailSubject
|
28
|
+
attr_accessor :emailSubject
|
29
|
+
# @attr [String] emailBody
|
30
|
+
attr_accessor :emailBody
|
31
|
+
# @attr [Integer] documentsCount
|
32
|
+
attr_accessor :documentsCount
|
33
|
+
# @attr [Integer] documentsPages
|
34
|
+
attr_accessor :documentsPages
|
35
|
+
# @attr [Array<GroupDocs::Signature::Contact>] recipients
|
36
|
+
attr_accessor :recipients
|
37
|
+
|
38
|
+
# Human-readable accessors
|
39
|
+
alias_method :owner_id, :ownerId
|
40
|
+
alias_method :owner_id=, :ownerId=
|
41
|
+
alias_method :owner_guid, :ownerGuid
|
42
|
+
alias_method :owner_guid=, :ownerGuid=
|
43
|
+
alias_method :reminder_time, :reminderTime
|
44
|
+
alias_method :reminder_time=, :reminderTime=
|
45
|
+
alias_method :step_expire_time, :stepExpireTime
|
46
|
+
alias_method :step_expire_time=, :stepExpireTime=
|
47
|
+
alias_method :owner_should_sign, :ownerShouldSign
|
48
|
+
alias_method :owner_should_sign=, :ownerShouldSign=
|
49
|
+
alias_method :ordered_signature, :orderedSignature
|
50
|
+
alias_method :ordered_signature=, :orderedSignature=
|
51
|
+
alias_method :email_subject, :emailSubject
|
52
|
+
alias_method :email_subject=, :emailSubject=
|
53
|
+
alias_method :email_body, :emailBody
|
54
|
+
alias_method :email_body=, :emailBody=
|
55
|
+
alias_method :documents_count, :documentsCount
|
56
|
+
alias_method :documents_count=, :documentsCount=
|
57
|
+
alias_method :documents_pages, :documentsPages
|
58
|
+
alias_method :documents_pages=, :documentsPages=
|
59
|
+
|
60
|
+
#
|
61
|
+
# Converts each recipient to GroupDocs::Signature::Recipient object.
|
62
|
+
# @param [Array<GroupDocs::Signature::Recipient, Hash>] recipients
|
63
|
+
#
|
64
|
+
def recipients=(recipients)
|
65
|
+
if recipients
|
66
|
+
@recipients = recipients.map do |recipient|
|
67
|
+
if recipient.is_a?(GroupDocs::Signature::Recipient)
|
68
|
+
recipient
|
69
|
+
else
|
70
|
+
Signature::Recipient.new(recipient)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
#
|
77
|
+
# Returns true if owner should sign.
|
78
|
+
# @return [Boolean]
|
79
|
+
#
|
80
|
+
def owner_should_sign
|
81
|
+
@ownerShouldSign == 1 ? true : false
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# Returns ordered signature type.
|
86
|
+
# @return [Symbol]
|
87
|
+
#
|
88
|
+
def ordered_signature
|
89
|
+
@orderedSignature == 1 ? :parallel : :ordered
|
90
|
+
end
|
91
|
+
|
92
|
+
end # EntityFields
|
93
|
+
end # Signature
|
94
|
+
end # GroupDocs
|
@@ -0,0 +1,145 @@
|
|
1
|
+
module GroupDocs
|
2
|
+
class Signature
|
3
|
+
#
|
4
|
+
# Envelope and template entities share the same set of methods.
|
5
|
+
#
|
6
|
+
# @see GroupDocs::Signature::Form
|
7
|
+
# @see GroupDocs::Signature::Envelope
|
8
|
+
# @see GroupDocs::Signature::Template
|
9
|
+
#
|
10
|
+
module EntityMethods
|
11
|
+
|
12
|
+
def self.included(klass)
|
13
|
+
klass.extend ClassMethods
|
14
|
+
end
|
15
|
+
|
16
|
+
module ClassMethods
|
17
|
+
#
|
18
|
+
# Returns template, envelope or form by its identifier.
|
19
|
+
#
|
20
|
+
# @param [String] id
|
21
|
+
# @param [Hash] access Access credentials
|
22
|
+
# @option access [String] :client_id
|
23
|
+
# @option access [String] :private_key
|
24
|
+
# @return [GroupDocs::Signature::Template, GroupDocs::Signature::Envelope, GroupDocs::Signature::Form]
|
25
|
+
#
|
26
|
+
def get!(id, access = {})
|
27
|
+
class_name = self.name.split('::').last.downcase
|
28
|
+
|
29
|
+
json = Api::Request.new do |request|
|
30
|
+
request[:access] = access
|
31
|
+
request[:method] = :GET
|
32
|
+
request[:path] = "/signature/{{client_id}}/#{class_name}s/#{id}"
|
33
|
+
end.execute!
|
34
|
+
|
35
|
+
new(json[class_name.to_sym])
|
36
|
+
end
|
37
|
+
end # ClassMethods
|
38
|
+
|
39
|
+
#
|
40
|
+
# Creates template or envelope.
|
41
|
+
#
|
42
|
+
# @example Create new template
|
43
|
+
# template = GroupDocs::Signature::Template.new
|
44
|
+
# template.name = "Template"
|
45
|
+
# template.email_subject = "Sing this!"
|
46
|
+
# template.create!
|
47
|
+
#
|
48
|
+
# @example Create new envelope
|
49
|
+
# envelope = GroupDocs::Signature::Envelope.new
|
50
|
+
# envelope.name = "Envelope"
|
51
|
+
# envelope.email_subject = "Sing this!"
|
52
|
+
# envelope.create!
|
53
|
+
#
|
54
|
+
# @param [Hash] options Hash of options
|
55
|
+
# @option options [Integer] :template_id Template GUID to use
|
56
|
+
# @option options [Integer] :envelope_id Envelope GUID to use
|
57
|
+
# @param [Hash] access Access credentials
|
58
|
+
# @option access [String] :client_id
|
59
|
+
# @option access [String] :private_key
|
60
|
+
#
|
61
|
+
def create!(options = {}, access = {})
|
62
|
+
template_id = options.delete(:template_id)
|
63
|
+
envelope_id = options.delete(:envelope_id)
|
64
|
+
options[:templateId] = template_id if template_id
|
65
|
+
options[:envelopeId] = envelope_id if envelope_id
|
66
|
+
|
67
|
+
api = Api::Request.new do |request|
|
68
|
+
request[:access] = access
|
69
|
+
request[:method] = :POST
|
70
|
+
request[:path] = "/signature/{{client_id}}/#{class_name}"
|
71
|
+
request[:request_body] = to_hash
|
72
|
+
end
|
73
|
+
api.add_params(options.merge(name: name))
|
74
|
+
json = api.execute!
|
75
|
+
|
76
|
+
self.id = json[class_name.to_sym][:id]
|
77
|
+
end
|
78
|
+
|
79
|
+
#
|
80
|
+
# Modifies template, envelope or form.
|
81
|
+
#
|
82
|
+
# @example Modify template
|
83
|
+
# template = GroupDocs::Signature::Template.get!("g94h5g84hj9g4gf23i40j")
|
84
|
+
# template.name = "Template"
|
85
|
+
# template.email_subject = "Sing this!"
|
86
|
+
# template.modify!
|
87
|
+
#
|
88
|
+
# @example Modify envelope
|
89
|
+
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
90
|
+
# envelope.name = "Envelope"
|
91
|
+
# envelope.email_subject = "Sing this!"
|
92
|
+
# envelope.modify!
|
93
|
+
#
|
94
|
+
# @param [Hash] access Access credentials
|
95
|
+
# @option access [String] :client_id
|
96
|
+
# @option access [String] :private_key
|
97
|
+
#
|
98
|
+
def modify!(access = {})
|
99
|
+
Api::Request.new do |request|
|
100
|
+
request[:access] = access
|
101
|
+
request[:method] = :POST
|
102
|
+
request[:path] = "/signature/{{client_id}}/#{pluralized_class_name}/#{id}"
|
103
|
+
request[:request_body] = to_hash
|
104
|
+
end.execute!
|
105
|
+
end
|
106
|
+
|
107
|
+
#
|
108
|
+
# Renames template, envelope or form.
|
109
|
+
#
|
110
|
+
# @param [String] name New template name
|
111
|
+
# @param [Hash] access Access credentials
|
112
|
+
# @option access [String] :client_id
|
113
|
+
# @option access [String] :private_key
|
114
|
+
#
|
115
|
+
def rename!(name, access = {})
|
116
|
+
api = Api::Request.new do |request|
|
117
|
+
request[:access] = access
|
118
|
+
request[:method] = :PUT
|
119
|
+
request[:path] = "/signature/{{client_id}}/#{pluralized_class_name}/#{id}"
|
120
|
+
end
|
121
|
+
key = (class_name == 'form' ? :new_name : :name )
|
122
|
+
api.add_params(key => name)
|
123
|
+
api.execute!
|
124
|
+
|
125
|
+
self.name = name
|
126
|
+
end
|
127
|
+
|
128
|
+
#
|
129
|
+
# Deletes template, envelope or form.
|
130
|
+
#
|
131
|
+
# @param [Hash] access Access credentials
|
132
|
+
# @option access [String] :client_id
|
133
|
+
# @option access [String] :private_key
|
134
|
+
#
|
135
|
+
def delete!(access = {})
|
136
|
+
Api::Request.new do |request|
|
137
|
+
request[:access] = access
|
138
|
+
request[:method] = :DELETE
|
139
|
+
request[:path] = "/signature/{{client_id}}/#{pluralized_class_name}/#{id}"
|
140
|
+
end.execute!
|
141
|
+
end
|
142
|
+
|
143
|
+
end # EntityMethods
|
144
|
+
end # Signature
|
145
|
+
end # GroupDocs
|