Class: Inkdit::Contract
Overview
Represents an Inkdit Contract.
Instance Attribute Summary
Attributes inherited from Resource
Class Method Summary collapse
-
.create(client, owner, params) ⇒ Contract
create a new contract.
Instance Method Summary collapse
-
#content ⇒ String
The contract’s content.
-
#content_updated_at ⇒ Object
an opaque string indicating the version of the contract’s content.
-
#html_link ⇒ Object
the URL of this contract’s HTML representation.
-
#name ⇒ String
A human-readable name for the contract.
- #share_with(individual, entity) ⇒ Object
- #sharing_link ⇒ Object
-
#signatures ⇒ Array<Signature,SignatureField>
This contract’s signatures and unsigned signature fields.
-
#test? ⇒ Boolean
whether the cantract is a test contract or not.
Methods inherited from Resource
#==, #fetch!, #initialize, #inspect
Constructor Details
This class inherits a constructor from Inkdit::Resource
Class Method Details
.create(client, owner, params) ⇒ Contract
create a new contract.
13 14 15 16 17 18 |
# File 'lib/inkdit/contract.rb', line 13 def self.create(client, owner, params) response = client.post owner.contracts_link, { :body => params.to_json, :headers => { 'Content-Type' => 'application/json' } } raise Inkdit::Error.new(response) unless response.status == 201 self.new(client, response.parsed) end |
Instance Method Details
#content ⇒ String
Returns the contract’s content.
26 27 28 |
# File 'lib/inkdit/contract.rb', line 26 def content @params['content'] end |
#content_updated_at ⇒ Object
an opaque string indicating the version of the contract’s content
45 46 47 |
# File 'lib/inkdit/contract.rb', line 45 def content_updated_at @params['content_updated_at'] end |
#html_link ⇒ Object
the URL of this contract’s HTML representation.
36 37 38 |
# File 'lib/inkdit/contract.rb', line 36 def html_link @params['links']['html'] end |
#name ⇒ String
Returns a human-readable name for the contract.
21 22 23 |
# File 'lib/inkdit/contract.rb', line 21 def name @params['name'] end |
#share_with(individual, entity) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/inkdit/contract.rb', line 62 def share_with(individual, entity) params = { :individual => { :url => individual }, :entity => { :url => entity } } @client.post self.sharing_link, { :body => params.to_json, :headers => { 'Content-Type' => 'application/json' } } end |
#sharing_link ⇒ Object
40 41 42 |
# File 'lib/inkdit/contract.rb', line 40 def sharing_link @params['links']['shared-with'] end |
#signatures ⇒ Array<Signature,SignatureField>
Returns this contract’s signatures and unsigned signature fields.
50 51 52 53 54 55 56 57 58 |
# File 'lib/inkdit/contract.rb', line 50 def signatures @params['signatures'].map do |s| if s['signed_by'] Inkdit::Signature.new(@client, s) else Inkdit::SignatureField.new(@client, self, s) end end end |
#test? ⇒ Boolean
whether the cantract is a test contract or not
31 32 33 |
# File 'lib/inkdit/contract.rb', line 31 def test? @params['test'] end |