Method: AdvancedBilling::CalendarBilling.from_hash

Defined in:
lib/advanced_billing/models/calendar_billing.rb

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/advanced_billing/models/calendar_billing.rb', line 59

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  snap_day = hash.key?('snap_day') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:CalendarBillingSnapDay), hash['snap_day']
  ) : SKIP
  calendar_billing_first_charge =
    hash.key?('calendar_billing_first_charge') ? hash['calendar_billing_first_charge'] : SKIP

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  CalendarBilling.new(snap_day: snap_day,
                      calendar_billing_first_charge: calendar_billing_first_charge,
                      additional_properties: additional_properties)
end