Class: StarkInfra::CreditSigner

Inherits:
StarkCore::Utils::Resource
  • Object
show all
Defined in:
lib/creditsigner/creditsigner.rb

Overview

# CreditSigner object

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’

## Attributes (return-only):

  • id [string]: unique id returned when the CreditSigner is created. ex: ‘5656565656565656’

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, contact:, method:, id: nil) ⇒ CreditSigner

Returns a new instance of CreditSigner.



19
20
21
22
23
24
# File 'lib/creditsigner/creditsigner.rb', line 19

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

Instance Attribute Details

#contactObject (readonly)

Returns the value of attribute contact.



18
19
20
# File 'lib/creditsigner/creditsigner.rb', line 18

def contact
  @contact
end

#idObject (readonly)

Returns the value of attribute id.



18
19
20
# File 'lib/creditsigner/creditsigner.rb', line 18

def id
  @id
end

#methodObject (readonly)

Returns the value of attribute method.



18
19
20
# File 'lib/creditsigner/creditsigner.rb', line 18

def method
  @method
end

#nameObject (readonly)

Returns the value of attribute name.



18
19
20
# File 'lib/creditsigner/creditsigner.rb', line 18

def name
  @name
end

Class Method Details

.parse_signers(signers) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/creditsigner/creditsigner.rb', line 26

def self.parse_signers(signers)
  resource_maker = StarkInfra::CreditSigner.resource[:resource_maker]
  return signers if signers.nil?

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

.resourceObject



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/creditsigner/creditsigner.rb', line 40

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