lib/groupdocs/signature.rb in groupdocs-1.4.2 vs lib/groupdocs/signature.rb in groupdocs-1.5.0
- old
+ new
@@ -31,10 +31,36 @@
json[:signatures].map do |signature|
new(signature)
end
end
+ #
+ # Returns a list of all signatures for recipient.
+ #
+ # @param [GroupDocs::Signature::Recipient] recipient
+ # @param [Hash] access Access credentials
+ # @option access [String] :client_id
+ # @option access [String] :private_key
+ # @return [Array<GroupDocs::Signature>]
+ #
+ def self.get_for_recipient!(recipient, access = {})
+ recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
+ "Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
+
+ api = Api::Request.new do |request|
+ request[:access] = access
+ request[:method] = :GET
+ request[:path] = '/signature/public/signatures'
+ end
+ api.add_params(:recipientId => recipient.id)
+ json = api.execute!
+
+ json[:signatures].map do |signature|
+ new(signature)
+ end
+ end
+
# @attr [String] id
attr_accessor :id
# @attr [String] userGuid
attr_accessor :userGuid
# @attr [String] recipientId
@@ -112,10 +138,35 @@
self.id = json[:signature][:id]
end
#
+ # Creates signature for recipient.
+ #
+ # @param [GroupDocs::Signature::Recipient] recipient
+ # @param [String] title Signature title
+ # @param [Hash] access Access credentials
+ # @option access [String] :client_id
+ # @option access [String] :private_key
+ #
+ def create_for_recipient!(recipient, title, access = {})
+ recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
+ "Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
+
+ api = Api::Request.new do |request|
+ request[:access] = access
+ request[:method] = :POST
+ request[:path] = '/signature/public/signature'
+ request[:request_body] = to_hash
+ end
+ api.add_params(:name => title, :recipientId => recipient.id)
+ json = api.execute!
+
+ self.id = json[:signature][:id]
+ end
+
+ #
# Deletes signature.
#
# @param [Hash] access Access credentials
# @option access [String] :client_id
# @option access [String] :private_key
@@ -123,9 +174,39 @@
def delete!(access = {})
Api::Request.new do |request|
request[:access] = access
request[:method] = :DELETE
request[:path] = "/signature/{{client_id}}/signatures/#{id}"
+ end.execute!
+ end
+
+ #
+ # Returns signature data.
+ #
+ # @param [Hash] access Access credentials
+ # @option access [String] :client_id
+ # @option access [String] :private_key
+ #
+ def signature_data!(access = {})
+ self.signature_data = Api::Request.new do |request|
+ request[:access] = access
+ request[:method] = :GET
+ request[:path] = "/signature/public/signatures/signature/#{id}/signatureData"
+ end.execute!
+ end
+
+ #
+ # Returns initials data.
+ #
+ # @param [Hash] access Access credentials
+ # @option access [String] :client_id
+ # @option access [String] :private_key
+ #
+ def initials_data!(access = {})
+ self.initials_data = Api::Request.new do |request|
+ request[:access] = access
+ request[:method] = :GET
+ request[:path] = "/signature/public/signatures/signature/#{id}/initialsData"
end.execute!
end
end # Signature
end # GroupDocs