Method: AdvancedBilling::SubscriptionPreview.from_hash
- Defined in:
- lib/advanced_billing/models/subscription_preview.rb
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/advanced_billing/models/subscription_preview.rb', line 53 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. current_billing_manifest = BillingManifest.from_hash(hash['current_billing_manifest']) if hash['current_billing_manifest'] next_billing_manifest = BillingManifest.from_hash(hash['next_billing_manifest']) if hash['next_billing_manifest'] # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. SubscriptionPreview.new(current_billing_manifest: current_billing_manifest, next_billing_manifest: next_billing_manifest, additional_properties: additional_properties) end |