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.
Methods inherited from BaseModel
#check_for_conflict, #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.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 87 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. Available values: ‘full`, `prorated`, `none`.
38 39 40 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 38 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.
49 50 51 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 49 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
43 44 45 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 43 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. Available values: ‘full`, `prorated`, `none`.
32 33 34 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 32 def upgrade_charge @upgrade_charge end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 154 155 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 114 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.
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 52 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
80 81 82 83 84 85 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 80 def self.nullables %w[ upgrade_charge downgrade_credit ] end |
.optionals ⇒ Object
An array for optional fields
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 66 def self.optionals %w[ proration_upgrade_scheme proration_downgrade_scheme allocations accrue_charge upgrade_charge downgrade_credit payment_collection_method initiate_dunning ] end |