Class: StarkInfra::CreditNote::Signer

Inherits:
Utils::SubResource show all
Defined in:
lib/creditnote/creditnote.rb

Overview

# CreditNote::Signer object

The Signer object stores the CreditNote signer’s information.

## Parameters (required):

  • name [string]: signer’s name. ex: ‘Tony Stark’

  • contact [string]: signer’s contact information. ex: ‘[email protected]

  • method [string]: delivery method for the contract. ex: ‘link’

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Utils::SubResource

#inspect, #to_s

Constructor Details

#initialize(name:, contact:, method:) ⇒ Signer

Returns a new instance of Signer.



358
359
360
361
362
# File 'lib/creditnote/creditnote.rb', line 358

def initialize(name:, contact:, method:)
  @name = name
  @contact = contact
  @method = method
end

Instance Attribute Details

#contactObject (readonly)

Returns the value of attribute contact.



357
358
359
# File 'lib/creditnote/creditnote.rb', line 357

def contact
  @contact
end

#methodObject (readonly)

Returns the value of attribute method.



357
358
359
# File 'lib/creditnote/creditnote.rb', line 357

def method
  @method
end

#nameObject (readonly)

Returns the value of attribute name.



357
358
359
# File 'lib/creditnote/creditnote.rb', line 357

def name
  @name
end

Class Method Details

.parse_signers(signers) ⇒ Object



364
365
366
367
368
369
370
371
372
373
374
375
# File 'lib/creditnote/creditnote.rb', line 364

def self.parse_signers(signers)
  return signers if signers.nil?

  parsed_signers = []
  signers.each do |signer|
    unless signer.is_a? Signer
      signer = StarkInfra::Utils::API.from_api_json(resource[:resource_maker], signer)
    end
    parsed_signers << signer
  end
  parsed_signers
end

.resourceObject



377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/creditnote/creditnote.rb', line 377

def self.resource
  {
    resource_name: 'Signer',
    resource_maker: proc { |json|
      Signer.new(
        name: json['name'],
        contact: json['contact'],
        method: json['method']
      )
    }
  }
end