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

#to_hash, #to_json

Constructor Details

#initialize(current_billing_manifest = SKIP, next_billing_manifest = SKIP) ⇒ SubscriptionPreview

Returns a new instance of SubscriptionPreview.



41
42
43
44
45
# File 'lib/advanced_billing/models/subscription_preview.rb', line 41

def initialize(current_billing_manifest = SKIP,
               next_billing_manifest = SKIP)
  @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.



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/advanced_billing/models/subscription_preview.rb', line 48

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']

  # Create object from extracted values.
  SubscriptionPreview.new(current_billing_manifest,
                          next_billing_manifest)
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