Class: PolarLoop::Types::Mandate

Inherits:
Struct
  • Object
show all
Defined in:
lib/polarloop/types/mandate.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#activeObject

Returns the value of attribute active

Returns:

  • (Object)

    the current value of active



5
6
7
# File 'lib/polarloop/types/mandate.rb', line 5

def active
  @active
end

#amountObject

Returns the value of attribute amount

Returns:

  • (Object)

    the current value of amount



5
6
7
# File 'lib/polarloop/types/mandate.rb', line 5

def amount
  @amount
end

#created_atObject

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



5
6
7
# File 'lib/polarloop/types/mandate.rb', line 5

def created_at
  @created_at
end

#intervalObject

Returns the value of attribute interval

Returns:

  • (Object)

    the current value of interval



5
6
7
# File 'lib/polarloop/types/mandate.rb', line 5

def interval
  @interval
end

#last_charged_atObject

Returns the value of attribute last_charged_at

Returns:

  • (Object)

    the current value of last_charged_at



5
6
7
# File 'lib/polarloop/types/mandate.rb', line 5

def last_charged_at
  @last_charged_at
end

#max_total_amountObject

Returns the value of attribute max_total_amount

Returns:

  • (Object)

    the current value of max_total_amount



5
6
7
# File 'lib/polarloop/types/mandate.rb', line 5

def max_total_amount
  @max_total_amount
end

#merchantObject

Returns the value of attribute merchant

Returns:

  • (Object)

    the current value of merchant



5
6
7
# File 'lib/polarloop/types/mandate.rb', line 5

def merchant
  @merchant
end

#payerObject

Returns the value of attribute payer

Returns:

  • (Object)

    the current value of payer



5
6
7
# File 'lib/polarloop/types/mandate.rb', line 5

def payer
  @payer
end

#reference_idObject

Returns the value of attribute reference_id

Returns:

  • (Object)

    the current value of reference_id



5
6
7
# File 'lib/polarloop/types/mandate.rb', line 5

def reference_id
  @reference_id
end

#tokenObject

Returns the value of attribute token

Returns:

  • (Object)

    the current value of token



5
6
7
# File 'lib/polarloop/types/mandate.rb', line 5

def token
  @token
end

#total_chargedObject

Returns the value of attribute total_charged

Returns:

  • (Object)

    the current value of total_charged



5
6
7
# File 'lib/polarloop/types/mandate.rb', line 5

def total_charged
  @total_charged
end

Class Method Details

.from_abi(values) ⇒ Object

Converts positional array from ABI decoder to Mandate struct. ABI order matches Solidity struct field order.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/polarloop/types/mandate.rb', line 21

def self.from_abi(values)
  new(
    payer: values[0],
    created_at: values[1].to_i,
    last_charged_at: values[2].to_i,
    merchant: values[3],
    interval: values[4].to_i,
    active: values[5],
    token: values[6],
    amount: values[7].to_i,
    max_total_amount: values[8].to_i,
    total_charged: values[9].to_i,
    reference_id: to_hex_bytes32(values[10])
  )
end

.to_hex_bytes32(binary) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/polarloop/types/mandate.rb', line 37

def self.to_hex_bytes32(binary)
  return "0x" + "00" * 32 if binary.nil?

  if binary.is_a?(String) && binary.start_with?("0x")
    binary.downcase
  elsif binary.is_a?(String)
    "0x" + binary.unpack1("H*")
  else
    "0x" + binary.to_s(16).rjust(64, "0")
  end
end