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[CreateAllocationRequest]
TODO: Write general description for this method.
-
#downgrade_credit ⇒ String
TODO: Write general description for this method.
-
#payment_collection_method ⇒ PaymentCollectionMethod1
(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 ⇒ String
TODO: Write general description for this method.
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 = 'no-prorate', proration_downgrade_scheme = 'no-prorate', allocations = SKIP, accrue_charge = SKIP, upgrade_charge = SKIP, downgrade_credit = SKIP, payment_collection_method = PaymentCollectionMethod1::AUTOMATIC) ⇒ AllocateComponents
constructor
A new instance of AllocateComponents.
Methods inherited from BaseModel
Constructor Details
#initialize(proration_upgrade_scheme = 'no-prorate', proration_downgrade_scheme = 'no-prorate', allocations = SKIP, accrue_charge = SKIP, upgrade_charge = SKIP, downgrade_credit = SKIP, payment_collection_method = PaymentCollectionMethod1::AUTOMATIC) ⇒ AllocateComponents
Returns a new instance of AllocateComponents.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 72 def initialize( proration_upgrade_scheme = 'no-prorate', proration_downgrade_scheme = 'no-prorate', allocations = SKIP, accrue_charge = SKIP, upgrade_charge = SKIP, downgrade_credit = SKIP, payment_collection_method = PaymentCollectionMethod1::AUTOMATIC ) @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 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[CreateAllocationRequest]
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 ⇒ String
TODO: Write general description for this method
34 35 36 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 34 def downgrade_credit @downgrade_credit end |
#payment_collection_method ⇒ PaymentCollectionMethod1
(Optional) If not passed, the allocation(s) will use the payment collection method on the subscription
39 40 41 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 39 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 ⇒ String
TODO: Write general description for this method
30 31 32 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 30 def upgrade_charge @upgrade_charge end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 94 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. proration_upgrade_scheme = hash['proration_upgrade_scheme'] ||= 'no-prorate' proration_downgrade_scheme = hash['proration_downgrade_scheme'] ||= 'no-prorate' # Parameter is an array, so we need to iterate through it allocations = nil unless hash['allocations'].nil? allocations = [] hash['allocations'].each do |structure| allocations << (CreateAllocationRequest.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['payment_collection_method'] ||= PaymentCollectionMethod1::AUTOMATIC # Create object from extracted values. AllocateComponents.new(proration_upgrade_scheme, proration_downgrade_scheme, allocations, accrue_charge, upgrade_charge, downgrade_credit, payment_collection_method) end |
.names ⇒ Object
A mapping from model property names to API property names.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 42 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 end |
.nullables ⇒ Object
An array for nullable fields
68 69 70 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 68 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/advanced_billing/models/allocate_components.rb', line 55 def self.optionals %w[ proration_upgrade_scheme proration_downgrade_scheme allocations accrue_charge upgrade_charge downgrade_credit payment_collection_method ] end |