Class: AdvancedBilling::AllocateComponents
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::AllocateComponents
- Defined in:
- lib/advanced_billing/models/allocate_components.rb
Overview
AllocateComponents Model.
Instance Attribute Summary collapse
-
#accrue_charge ⇒ TrueClass | FalseClass
TODO: Write general description for this method.
-
#allocations ⇒ Array[CreateAllocation]
TODO: Write general description for this method.
-
#downgrade_credit ⇒ CreditType
The type of credit to be created when upgrading/downgrading.
-
#initiate_dunning ⇒ TrueClass | FalseClass
If true, if the immediate component payment fails, initiate dunning for the subscription.
-
#payment_collection_method ⇒ CollectionMethod
(Optional) If not passed, the allocation(s) will use the payment collection method on the subscription.
-
#proration_downgrade_scheme ⇒ String
TODO: Write general description for this method.
-
#proration_upgrade_scheme ⇒ String
TODO: Write general description for this method.
-
#upgrade_charge ⇒ CreditType
The type of credit to be created when upgrading/downgrading.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(proration_upgrade_scheme: SKIP, proration_downgrade_scheme: SKIP, allocations: SKIP, accrue_charge: SKIP, upgrade_charge: SKIP, downgrade_credit: SKIP, payment_collection_method: SKIP, initiate_dunning: SKIP, additional_properties: {}) ⇒ AllocateComponents
constructor
A new instance of AllocateComponents.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(proration_upgrade_scheme: SKIP, proration_downgrade_scheme: SKIP, allocations: SKIP, accrue_charge: SKIP, upgrade_charge: SKIP, downgrade_credit: SKIP, payment_collection_method: SKIP, initiate_dunning: SKIP, additional_properties: {}) ⇒ AllocateComponents
Returns a new instance of AllocateComponents.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 85 def initialize(proration_upgrade_scheme: SKIP, proration_downgrade_scheme: SKIP, allocations: SKIP, accrue_charge: SKIP, upgrade_charge: SKIP, downgrade_credit: SKIP, payment_collection_method: SKIP, initiate_dunning: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @proration_upgrade_scheme = proration_upgrade_scheme unless proration_upgrade_scheme == SKIP unless proration_downgrade_scheme == SKIP @proration_downgrade_scheme = proration_downgrade_scheme end @allocations = allocations unless allocations == SKIP @accrue_charge = accrue_charge unless accrue_charge == SKIP @upgrade_charge = upgrade_charge unless upgrade_charge == SKIP @downgrade_credit = downgrade_credit unless downgrade_credit == SKIP unless payment_collection_method == SKIP @payment_collection_method = payment_collection_method end @initiate_dunning = initiate_dunning unless initiate_dunning == SKIP end |
Instance Attribute Details
#accrue_charge ⇒ TrueClass | FalseClass
TODO: Write general description for this method
26 27 28 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 26 def accrue_charge @accrue_charge end |
#allocations ⇒ Array[CreateAllocation]
TODO: Write general description for this method
22 23 24 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 22 def allocations @allocations end |
#downgrade_credit ⇒ CreditType
The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.
36 37 38 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 36 def downgrade_credit @downgrade_credit end |
#initiate_dunning ⇒ TrueClass | FalseClass
If true, if the immediate component payment fails, initiate dunning for the subscription. Otherwise, leave the charges on the subscription to pay for at renewal.
47 48 49 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 47 def initiate_dunning @initiate_dunning end |
#payment_collection_method ⇒ CollectionMethod
(Optional) If not passed, the allocation(s) will use the payment collection method on the subscription
41 42 43 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 41 def payment_collection_method @payment_collection_method end |
#proration_downgrade_scheme ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 18 def proration_downgrade_scheme @proration_downgrade_scheme end |
#proration_upgrade_scheme ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 14 def proration_upgrade_scheme @proration_upgrade_scheme end |
#upgrade_charge ⇒ CreditType
The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.
31 32 33 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 31 def upgrade_charge @upgrade_charge end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 112 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. proration_upgrade_scheme = hash.key?('proration_upgrade_scheme') ? hash['proration_upgrade_scheme'] : SKIP proration_downgrade_scheme = hash.key?('proration_downgrade_scheme') ? hash['proration_downgrade_scheme'] : SKIP # Parameter is an array, so we need to iterate through it allocations = nil unless hash['allocations'].nil? allocations = [] hash['allocations'].each do |structure| allocations << (CreateAllocation.from_hash(structure) if structure) end end allocations = SKIP unless hash.key?('allocations') accrue_charge = hash.key?('accrue_charge') ? hash['accrue_charge'] : SKIP upgrade_charge = hash.key?('upgrade_charge') ? hash['upgrade_charge'] : SKIP downgrade_credit = hash.key?('downgrade_credit') ? hash['downgrade_credit'] : SKIP payment_collection_method = hash.key?('payment_collection_method') ? hash['payment_collection_method'] : SKIP initiate_dunning = hash.key?('initiate_dunning') ? hash['initiate_dunning'] : SKIP # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. AllocateComponents.new(proration_upgrade_scheme: proration_upgrade_scheme, proration_downgrade_scheme: proration_downgrade_scheme, allocations: allocations, accrue_charge: accrue_charge, upgrade_charge: upgrade_charge, downgrade_credit: downgrade_credit, payment_collection_method: payment_collection_method, initiate_dunning: initiate_dunning, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 50 def self.names @_hash = {} if @_hash.nil? @_hash['proration_upgrade_scheme'] = 'proration_upgrade_scheme' @_hash['proration_downgrade_scheme'] = 'proration_downgrade_scheme' @_hash['allocations'] = 'allocations' @_hash['accrue_charge'] = 'accrue_charge' @_hash['upgrade_charge'] = 'upgrade_charge' @_hash['downgrade_credit'] = 'downgrade_credit' @_hash['payment_collection_method'] = 'payment_collection_method' @_hash['initiate_dunning'] = 'initiate_dunning' @_hash end |
.nullables ⇒ Object
An array for nullable fields
78 79 80 81 82 83 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 78 def self.nullables %w[ upgrade_charge downgrade_credit ] end |
.optionals ⇒ Object
An array for optional fields
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 64 def self.optionals %w[ proration_upgrade_scheme proration_downgrade_scheme allocations accrue_charge upgrade_charge downgrade_credit payment_collection_method initiate_dunning ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
167 168 169 170 171 172 173 174 175 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 167 def inspect class_name = self.class.name.split('::').last "<#{class_name} proration_upgrade_scheme: #{@proration_upgrade_scheme.inspect},"\ " proration_downgrade_scheme: #{@proration_downgrade_scheme.inspect}, allocations:"\ " #{@allocations.inspect}, accrue_charge: #{@accrue_charge.inspect}, upgrade_charge:"\ " #{@upgrade_charge.inspect}, downgrade_credit: #{@downgrade_credit.inspect},"\ " payment_collection_method: #{@payment_collection_method.inspect}, initiate_dunning:"\ " #{@initiate_dunning.inspect}, additional_properties: #{get_additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
156 157 158 159 160 161 162 163 164 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 156 def to_s class_name = self.class.name.split('::').last "<#{class_name} proration_upgrade_scheme: #{@proration_upgrade_scheme},"\ " proration_downgrade_scheme: #{@proration_downgrade_scheme}, allocations: #{@allocations},"\ " accrue_charge: #{@accrue_charge}, upgrade_charge: #{@upgrade_charge}, downgrade_credit:"\ " #{@downgrade_credit}, payment_collection_method: #{@payment_collection_method},"\ " initiate_dunning: #{@initiate_dunning}, additional_properties:"\ " #{get_additional_properties}>" end |