Class: DatagroutConduit::Receipt

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#actual_creditsObject

Returns the value of attribute actual_credits

Returns:

  • (Object)

    the current value of actual_credits



35
36
37
# File 'lib/datagrout_conduit/types.rb', line 35

def actual_credits
  @actual_credits
end

#balance_afterObject

Returns the value of attribute balance_after

Returns:

  • (Object)

    the current value of balance_after



35
36
37
# File 'lib/datagrout_conduit/types.rb', line 35

def balance_after
  @balance_after
end

#balance_beforeObject

Returns the value of attribute balance_before

Returns:

  • (Object)

    the current value of balance_before



35
36
37
# File 'lib/datagrout_conduit/types.rb', line 35

def balance_before
  @balance_before
end

#breakdownObject

Returns the value of attribute breakdown

Returns:

  • (Object)

    the current value of breakdown



35
36
37
# File 'lib/datagrout_conduit/types.rb', line 35

def breakdown
  @breakdown
end

#byokObject

Returns the value of attribute byok

Returns:

  • (Object)

    the current value of byok



35
36
37
# File 'lib/datagrout_conduit/types.rb', line 35

def byok
  @byok
end

#estimated_creditsObject

Returns the value of attribute estimated_credits

Returns:

  • (Object)

    the current value of estimated_credits



35
36
37
# File 'lib/datagrout_conduit/types.rb', line 35

def estimated_credits
  @estimated_credits
end

#net_creditsObject

Returns the value of attribute net_credits

Returns:

  • (Object)

    the current value of net_credits



35
36
37
# File 'lib/datagrout_conduit/types.rb', line 35

def net_credits
  @net_credits
end

#receipt_idObject

Returns the value of attribute receipt_id

Returns:

  • (Object)

    the current value of receipt_id



35
36
37
# File 'lib/datagrout_conduit/types.rb', line 35

def receipt_id
  @receipt_id
end

#savingsObject

Returns the value of attribute savings

Returns:

  • (Object)

    the current value of savings



35
36
37
# File 'lib/datagrout_conduit/types.rb', line 35

def savings
  @savings
end

#savings_bonusObject

Returns the value of attribute savings_bonus

Returns:

  • (Object)

    the current value of savings_bonus



35
36
37
# File 'lib/datagrout_conduit/types.rb', line 35

def savings_bonus
  @savings_bonus
end

#timestampObject

Returns the value of attribute timestamp

Returns:

  • (Object)

    the current value of timestamp



35
36
37
# File 'lib/datagrout_conduit/types.rb', line 35

def timestamp
  @timestamp
end

#transaction_idObject

Returns the value of attribute transaction_id

Returns:

  • (Object)

    the current value of transaction_id



35
36
37
# File 'lib/datagrout_conduit/types.rb', line 35

def transaction_id
  @transaction_id
end

Class Method Details

.from_hash(hash) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/datagrout_conduit/types.rb', line 43

def self.from_hash(hash)
  return nil if hash.nil?

  hash = hash.transform_keys(&:to_s)
  new(
    receipt_id: hash["receipt_id"],
    transaction_id: hash["transaction_id"],
    timestamp: hash["timestamp"],
    estimated_credits: hash["estimated_credits"]&.to_f,
    actual_credits: hash["actual_credits"]&.to_f,
    net_credits: hash["net_credits"]&.to_f,
    savings: (hash["savings"] || 0.0).to_f,
    savings_bonus: (hash["savings_bonus"] || 0.0).to_f,
    balance_before: hash["balance_before"]&.to_f,
    balance_after: hash["balance_after"]&.to_f,
    breakdown: hash["breakdown"] || {},
    byok: Byok.from_hash(hash["byok"])
  )
end