Class: Inkdit::SignatureField
- Inherits:
-
Object
- Object
- Inkdit::SignatureField
- Defined in:
- lib/inkdit/signature_field.rb
Overview
Represents an unsigned signature placeholder.
Instance Method Summary collapse
-
#designate(params) ⇒ Object
params
is a Hash specifying who this signature field should be designated to. - #designation_url ⇒ Object
-
#initialize(client, contract, params) ⇒ SignatureField
constructor
A new instance of SignatureField.
- #inspect ⇒ Object
-
#sign! ⇒ Signature
sign this field as the user and entity associated with the current access token.
-
#url ⇒ String
The URL of this signature field.
Constructor Details
#initialize(client, contract, params) ⇒ SignatureField
Returns a new instance of SignatureField.
4 5 6 7 8 |
# File 'lib/inkdit/signature_field.rb', line 4 def initialize(client, contract, params) @client = client @contract = contract @params = params end |
Instance Method Details
#designate(params) ⇒ Object
params
is a Hash specifying who this signature field should be designated to. It must contain the key individual
. It can contain the key organization
if a specific organization is being designated.
, and organization
. At least one should be present. They should be [Entity]s
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/inkdit/signature_field.rb', line 43 def designate(params) params = { :individual => { :url => params[:individual].url } } params[:entity] = if params[:organization] { :url => params[:organization].url } else params[:individual] end response = @client.put self.designation_url, { :body => params.to_json, :headers => { 'Content-Type' => 'application/json' } } if response.status != 200 raise Inkdit::Error.new(response) end Inkdit::SignatureField.new(@client, @contract, response.parsed) end |
#designation_url ⇒ Object
15 16 17 |
# File 'lib/inkdit/signature_field.rb', line 15 def designation_url @params['links']['designation'] end |
#inspect ⇒ Object
63 64 65 |
# File 'lib/inkdit/signature_field.rb', line 63 def inspect "#<#{self.class.inspect} params=#{@params}>" end |
#sign! ⇒ Signature
sign this field as the user and entity associated with the current access token.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/inkdit/signature_field.rb', line 21 def sign! params = { :if_updated_at => @contract.content_updated_at } response = @client.put self.url, { :body => params.to_json, :headers => { 'Content-Type' => 'application/json' } } if response.status != 201 raise Inkdit::Error.new(response) end Inkdit::Signature.new(@client, response.parsed) end |
#url ⇒ String
Returns the URL of this signature field.
11 12 13 |
# File 'lib/inkdit/signature_field.rb', line 11 def url @params['url'] end |