Class: Universign::Document
- Inherits:
-
Object
- Object
- Universign::Document
- Includes:
- Safeguard
- Defined in:
- lib/universign/document.rb
Instance Attribute Summary collapse
-
#file_content ⇒ Object
readonly
Returns the value of attribute file_content.
-
#file_url ⇒ Object
readonly
Returns the value of attribute file_url.
-
#name ⇒ String
The file name of this document.
-
#params ⇒ Object
Returns the value of attribute params.
Class Method Summary collapse
-
.from_data(data) ⇒ Universign::Document
Create a new document from a Hash.
Instance Method Summary collapse
-
#content ⇒ Array<Byte>
The raw content of the PDF document.
- #content=(data) ⇒ Object
-
#document_type ⇒ String
The type of this document.
-
#initialize(options = {}) ⇒ Document
constructor
Create a new Universign::Document.
-
#meta_data ⇒ Hash
The meta data of the PDF document.
- #meta_data=(data) ⇒ Object
- #signature_fields=(data) ⇒ Object
-
#url ⇒ String
The URL to download the PDF document.
- #url=(data) ⇒ Object
Methods included from Safeguard
Constructor Details
#initialize(options = {}) ⇒ Document
Create a new Universign::Document
15 16 17 18 19 20 21 |
# File 'lib/universign/document.rb', line 15 def initialize( = {}) @params = HashWithIndifferentAccess.new .each do |key, value| send("#{key}=", value) end end |
Instance Attribute Details
#file_content ⇒ Object (readonly)
Returns the value of attribute file_content.
5 6 7 |
# File 'lib/universign/document.rb', line 5 def file_content @file_content end |
#file_url ⇒ Object (readonly)
Returns the value of attribute file_url.
5 6 7 |
# File 'lib/universign/document.rb', line 5 def file_url @file_url end |
#name ⇒ String
The file name of this document
69 70 71 |
# File 'lib/universign/document.rb', line 69 def name @name end |
#params ⇒ Object
Returns the value of attribute params.
6 7 8 |
# File 'lib/universign/document.rb', line 6 def params @params end |
Class Method Details
.from_data(data) ⇒ Universign::Document
Create a new document from a Hash
27 28 29 30 31 32 33 |
# File 'lib/universign/document.rb', line 27 def self.from_data(data) @params = data document = Universign::Document.new document.params.merge!(@params) document end |
Instance Method Details
#content ⇒ Array<Byte>
The raw content of the PDF document
38 39 40 |
# File 'lib/universign/document.rb', line 38 def content @content ||= params['content'] end |
#content=(data) ⇒ Object
42 43 44 45 |
# File 'lib/universign/document.rb', line 42 def content=(data) @content = data params[:content] = XMLRPC::Base64.new(data) end |
#document_type ⇒ String
The type of this document
62 63 64 |
# File 'lib/universign/document.rb', line 62 def document_type @document_type ||= params['documentType'] end |
#meta_data ⇒ Hash
The meta data of the PDF document
94 95 96 |
# File 'lib/universign/document.rb', line 94 def ||= params['metaData'] end |
#meta_data=(data) ⇒ Object
98 99 100 101 102 103 104 105 |
# File 'lib/universign/document.rb', line 98 def (data) if !data.is_a?(Hash) raise MetaDataMustBeAHash end = data params['metaData'] = data end |
#signature_fields=(data) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/universign/document.rb', line 78 def signature_fields=(data) if !data.is_a?(Array) raise 'SignatureFieldsMustBeAnArray' end @signature_fields = data params['signatureFields'] = data.map do |d| raise 'BadSignatureFieldType' unless d.instance_of?(SignatureField) d.params end end |
#url ⇒ String
The URL to download the PDF document
50 51 52 |
# File 'lib/universign/document.rb', line 50 def url @url ||= params['url'] end |
#url=(data) ⇒ Object
54 55 56 57 |
# File 'lib/universign/document.rb', line 54 def url=(data) @url = data params['url'] = data end |