Class: Inkdit::Contract

Inherits:
Resource show all
Defined in:
lib/inkdit/contract.rb

Overview

Represents an Inkdit Contract.

Instance Attribute Summary

Attributes inherited from Resource

#url

Class Method Summary collapse

Instance Method Summary collapse

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.

Raises:



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

#contentString



26
27
28
# File 'lib/inkdit/contract.rb', line 26

def content
  @params['content']
end

#content_updated_atObject

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

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

#nameString



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


40
41
42
# File 'lib/inkdit/contract.rb', line 40

def sharing_link
  @params['links']['shared-with']
end

#signaturesArray<Signature,SignatureField>



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