Class: AdvancedBilling::SubscriptionMigrationPreview

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

Overview

SubscriptionMigrationPreview Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(prorated_adjustment_in_cents: SKIP, charge_in_cents: SKIP, payment_due_in_cents: SKIP, credit_applied_in_cents: SKIP, additional_properties: {}) ⇒ SubscriptionMigrationPreview

Returns a new instance of SubscriptionMigrationPreview.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/advanced_billing/models/subscription_migration_preview.rb', line 56

def initialize(prorated_adjustment_in_cents: SKIP, charge_in_cents: SKIP,
               payment_due_in_cents: SKIP, credit_applied_in_cents: SKIP,
               additional_properties: {})
  unless prorated_adjustment_in_cents == SKIP
    @prorated_adjustment_in_cents =
      prorated_adjustment_in_cents
  end
  @charge_in_cents = charge_in_cents unless charge_in_cents == SKIP
  @payment_due_in_cents = payment_due_in_cents unless payment_due_in_cents == SKIP
  @credit_applied_in_cents = credit_applied_in_cents unless credit_applied_in_cents == SKIP

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

Instance Attribute Details

#charge_in_centsInteger

The amount of the charge that would be created for the new product.

Returns:

  • (Integer)


19
20
21
# File 'lib/advanced_billing/models/subscription_migration_preview.rb', line 19

def charge_in_cents
  @charge_in_cents
end

#credit_applied_in_centsInteger

Represents a credit in cents that is applied to your subscription as part of a migration process for a specific product, which reduces the amount owed for the subscription.

Returns:

  • (Integer)


29
30
31
# File 'lib/advanced_billing/models/subscription_migration_preview.rb', line 29

def credit_applied_in_cents
  @credit_applied_in_cents
end

#payment_due_in_centsInteger

The amount of the payment due in the case of an upgrade.

Returns:

  • (Integer)


23
24
25
# File 'lib/advanced_billing/models/subscription_migration_preview.rb', line 23

def payment_due_in_cents
  @payment_due_in_cents
end

#prorated_adjustment_in_centsInteger

The amount of the prorated adjustment that would be issued for the current subscription.

Returns:

  • (Integer)


15
16
17
# File 'lib/advanced_billing/models/subscription_migration_preview.rb', line 15

def prorated_adjustment_in_cents
  @prorated_adjustment_in_cents
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/advanced_billing/models/subscription_migration_preview.rb', line 74

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  prorated_adjustment_in_cents =
    hash.key?('prorated_adjustment_in_cents') ? hash['prorated_adjustment_in_cents'] : SKIP
  charge_in_cents =
    hash.key?('charge_in_cents') ? hash['charge_in_cents'] : SKIP
  payment_due_in_cents =
    hash.key?('payment_due_in_cents') ? hash['payment_due_in_cents'] : SKIP
  credit_applied_in_cents =
    hash.key?('credit_applied_in_cents') ? hash['credit_applied_in_cents'] : SKIP

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  SubscriptionMigrationPreview.new(prorated_adjustment_in_cents: prorated_adjustment_in_cents,
                                   charge_in_cents: charge_in_cents,
                                   payment_due_in_cents: payment_due_in_cents,
                                   credit_applied_in_cents: credit_applied_in_cents,
                                   additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



32
33
34
35
36
37
38
39
# File 'lib/advanced_billing/models/subscription_migration_preview.rb', line 32

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['prorated_adjustment_in_cents'] = 'prorated_adjustment_in_cents'
  @_hash['charge_in_cents'] = 'charge_in_cents'
  @_hash['payment_due_in_cents'] = 'payment_due_in_cents'
  @_hash['credit_applied_in_cents'] = 'credit_applied_in_cents'
  @_hash
end

.nullablesObject

An array for nullable fields



52
53
54
# File 'lib/advanced_billing/models/subscription_migration_preview.rb', line 52

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    prorated_adjustment_in_cents
    charge_in_cents
    payment_due_in_cents
    credit_applied_in_cents
  ]
end