Class: AdvancedBilling::SubscriptionPreview

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/subscription_preview.rb

Overview

SubscriptionPreview Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(current_billing_manifest: SKIP, next_billing_manifest: SKIP, additional_properties: {}) ⇒ SubscriptionPreview

Returns a new instance of SubscriptionPreview.



41
42
43
44
45
46
47
48
49
50
# File 'lib/advanced_billing/models/subscription_preview.rb', line 41

def initialize(current_billing_manifest: SKIP, next_billing_manifest: SKIP,
               additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @current_billing_manifest = current_billing_manifest unless current_billing_manifest == SKIP
  @next_billing_manifest = next_billing_manifest unless next_billing_manifest == SKIP
end

Instance Attribute Details

#current_billing_manifestBillingManifest

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/advanced_billing/models/subscription_preview.rb', line 14

def current_billing_manifest
  @current_billing_manifest
end

#next_billing_manifestBillingManifest

TODO: Write general description for this method

Returns:



18
19
20
# File 'lib/advanced_billing/models/subscription_preview.rb', line 18

def next_billing_manifest
  @next_billing_manifest
end

Class Method Details

.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

.namesObject

A mapping from model property names to API property names.



21
22
23
24
25
26
# File 'lib/advanced_billing/models/subscription_preview.rb', line 21

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['current_billing_manifest'] = 'current_billing_manifest'
  @_hash['next_billing_manifest'] = 'next_billing_manifest'
  @_hash
end

.nullablesObject

An array for nullable fields



37
38
39
# File 'lib/advanced_billing/models/subscription_preview.rb', line 37

def self.nullables
  []
end

.optionalsObject

An array for optional fields



29
30
31
32
33
34
# File 'lib/advanced_billing/models/subscription_preview.rb', line 29

def self.optionals
  %w[
    current_billing_manifest
    next_billing_manifest
  ]
end