Class: AdvancedBilling::UpdateSubscription
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::UpdateSubscription
- Defined in:
- lib/advanced_billing/models/update_subscription.rb
Overview
UpdateSubscription Model.
Instance Attribute Summary collapse
-
#components ⇒ Array[UpdateSubscriptionComponent]
(Optional) An array of component ids and custom prices to be added to the subscription.
-
#credit_card_attributes ⇒ CreditCardAttributes
TODO: Write general description for this method.
-
#custom_price ⇒ SubscriptionCustomPrice
(Optional) Used in place of ‘product_price_point_id` to define a custom price point unique to the subscription.
-
#dunning_communication_delay_enabled ⇒ TrueClass | FalseClass
Enable Communication Delay feature, making sure no communication (email or SMS) is sent to the Customer between 9PM and 8AM in time zone set by the ‘dunning_communication_delay_time_zone` attribute.
-
#dunning_communication_delay_time_zone ⇒ String
Time zone for the Dunning Communication Delay feature.
-
#net_terms ⇒ Object
Use for subscriptions with product eligible for calendar billing only.
-
#next_billing_at ⇒ DateTime
Use for subscriptions with product eligible for calendar billing only.
-
#next_product_id ⇒ String
Set to an empty string to cancel a delayed product change.
-
#next_product_price_point_id ⇒ String
Set to an empty string to cancel a delayed product change.
-
#payment_collection_method ⇒ String
Use for subscriptions with product eligible for calendar billing only.
-
#product_change_delayed ⇒ TrueClass | FalseClass
Set to the id of a different product to change the subscription’s product.
-
#product_handle ⇒ String
Set to the handle of a different product to change the subscription’s product.
-
#product_id ⇒ Integer
Set to the id of a different product to change the subscription’s product.
-
#product_price_point_handle ⇒ String
Set to change the current product’s price point.
-
#product_price_point_id ⇒ Integer
Set to change the current product’s price point.
-
#receives_invoice_emails ⇒ TrueClass | FalseClass
Use for subscriptions with product eligible for calendar billing only.
-
#reference ⇒ String
Use for subscriptions with product eligible for calendar billing only.
-
#snap_day ⇒ Object
Use for subscriptions with product eligible for calendar billing only.
-
#stored_credential_transaction_id ⇒ Integer
Use for subscriptions with product eligible for calendar billing only.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(credit_card_attributes: SKIP, product_handle: SKIP, product_id: SKIP, product_change_delayed: SKIP, next_product_id: SKIP, next_product_price_point_id: SKIP, snap_day: SKIP, next_billing_at: SKIP, payment_collection_method: SKIP, receives_invoice_emails: SKIP, net_terms: SKIP, stored_credential_transaction_id: SKIP, reference: SKIP, custom_price: SKIP, components: SKIP, dunning_communication_delay_enabled: SKIP, dunning_communication_delay_time_zone: SKIP, product_price_point_id: SKIP, product_price_point_handle: SKIP, additional_properties: {}) ⇒ UpdateSubscription
constructor
A new instance of UpdateSubscription.
- #to_custom_next_billing_at ⇒ Object
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(credit_card_attributes: SKIP, product_handle: SKIP, product_id: SKIP, product_change_delayed: SKIP, next_product_id: SKIP, next_product_price_point_id: SKIP, snap_day: SKIP, next_billing_at: SKIP, payment_collection_method: SKIP, receives_invoice_emails: SKIP, net_terms: SKIP, stored_credential_transaction_id: SKIP, reference: SKIP, custom_price: SKIP, components: SKIP, dunning_communication_delay_enabled: SKIP, dunning_communication_delay_time_zone: SKIP, product_price_point_id: SKIP, product_price_point_handle: SKIP, additional_properties: {}) ⇒ UpdateSubscription
Returns a new instance of UpdateSubscription.
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 161 def initialize(credit_card_attributes: SKIP, product_handle: SKIP, product_id: SKIP, product_change_delayed: SKIP, next_product_id: SKIP, next_product_price_point_id: SKIP, snap_day: SKIP, next_billing_at: SKIP, payment_collection_method: SKIP, receives_invoice_emails: SKIP, net_terms: SKIP, stored_credential_transaction_id: SKIP, reference: SKIP, custom_price: SKIP, components: SKIP, dunning_communication_delay_enabled: SKIP, dunning_communication_delay_time_zone: SKIP, product_price_point_id: SKIP, product_price_point_handle: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @credit_card_attributes = credit_card_attributes unless credit_card_attributes == SKIP @product_handle = product_handle unless product_handle == SKIP @product_id = product_id unless product_id == SKIP @product_change_delayed = product_change_delayed unless product_change_delayed == SKIP @next_product_id = next_product_id unless next_product_id == SKIP unless next_product_price_point_id == SKIP @next_product_price_point_id = next_product_price_point_id end @snap_day = snap_day unless snap_day == SKIP @next_billing_at = next_billing_at unless next_billing_at == SKIP unless payment_collection_method == SKIP @payment_collection_method = payment_collection_method end @receives_invoice_emails = receives_invoice_emails unless receives_invoice_emails == SKIP @net_terms = net_terms unless net_terms == SKIP unless stored_credential_transaction_id == SKIP @stored_credential_transaction_id = stored_credential_transaction_id end @reference = reference unless reference == SKIP @custom_price = custom_price unless custom_price == SKIP @components = components unless components == SKIP unless dunning_communication_delay_enabled == SKIP @dunning_communication_delay_enabled = dunning_communication_delay_enabled end unless dunning_communication_delay_time_zone == SKIP @dunning_communication_delay_time_zone = dunning_communication_delay_time_zone end @product_price_point_id = product_price_point_id unless product_price_point_id == SKIP unless product_price_point_handle == SKIP @product_price_point_handle = product_price_point_handle end end |
Instance Attribute Details
#components ⇒ Array[UpdateSubscriptionComponent]
(Optional) An array of component ids and custom prices to be added to the subscription.
81 82 83 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 81 def components @components end |
#credit_card_attributes ⇒ CreditCardAttributes
TODO: Write general description for this method
15 16 17 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 15 def credit_card_attributes @credit_card_attributes end |
#custom_price ⇒ SubscriptionCustomPrice
(Optional) Used in place of ‘product_price_point_id` to define a custom price point unique to the subscription
76 77 78 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 76 def custom_price @custom_price end |
#dunning_communication_delay_enabled ⇒ TrueClass | FalseClass
Enable Communication Delay feature, making sure no communication (email or SMS) is sent to the Customer between 9PM and 8AM in time zone set by the ‘dunning_communication_delay_time_zone` attribute.
87 88 89 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 87 def dunning_communication_delay_enabled @dunning_communication_delay_enabled end |
#dunning_communication_delay_time_zone ⇒ String
Time zone for the Dunning Communication Delay feature.
91 92 93 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 91 def dunning_communication_delay_time_zone @dunning_communication_delay_time_zone end |
#net_terms ⇒ Object
Use for subscriptions with product eligible for calendar billing only. Value can be 1-28 or ‘end’.
61 62 63 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 61 def net_terms @net_terms end |
#next_billing_at ⇒ DateTime
Use for subscriptions with product eligible for calendar billing only. Value can be 1-28 or ‘end’.
46 47 48 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 46 def next_billing_at @next_billing_at end |
#next_product_id ⇒ String
Set to an empty string to cancel a delayed product change.
32 33 34 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 32 def next_product_id @next_product_id end |
#next_product_price_point_id ⇒ String
Set to an empty string to cancel a delayed product change.
36 37 38 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 36 def next_product_price_point_id @next_product_price_point_id end |
#payment_collection_method ⇒ String
Use for subscriptions with product eligible for calendar billing only. Value can be 1-28 or ‘end’.
51 52 53 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 51 def payment_collection_method @payment_collection_method end |
#product_change_delayed ⇒ TrueClass | FalseClass
Set to the id of a different product to change the subscription’s product
28 29 30 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 28 def product_change_delayed @product_change_delayed end |
#product_handle ⇒ String
Set to the handle of a different product to change the subscription’s product
20 21 22 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 20 def product_handle @product_handle end |
#product_id ⇒ Integer
Set to the id of a different product to change the subscription’s product
24 25 26 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 24 def product_id @product_id end |
#product_price_point_handle ⇒ String
Set to change the current product’s price point.
99 100 101 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 99 def product_price_point_handle @product_price_point_handle end |
#product_price_point_id ⇒ Integer
Set to change the current product’s price point.
95 96 97 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 95 def product_price_point_id @product_price_point_id end |
#receives_invoice_emails ⇒ TrueClass | FalseClass
Use for subscriptions with product eligible for calendar billing only. Value can be 1-28 or ‘end’.
56 57 58 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 56 def receives_invoice_emails @receives_invoice_emails end |
#reference ⇒ String
Use for subscriptions with product eligible for calendar billing only. Value can be 1-28 or ‘end’.
71 72 73 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 71 def reference @reference end |
#snap_day ⇒ Object
Use for subscriptions with product eligible for calendar billing only. Value can be 1-28 or ‘end’.
41 42 43 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 41 def snap_day @snap_day end |
#stored_credential_transaction_id ⇒ Integer
Use for subscriptions with product eligible for calendar billing only. Value can be 1-28 or ‘end’.
66 67 68 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 66 def stored_credential_transaction_id @stored_credential_transaction_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 218 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. credit_card_attributes = CreditCardAttributes.from_hash(hash['credit_card_attributes']) if hash['credit_card_attributes'] product_handle = hash.key?('product_handle') ? hash['product_handle'] : SKIP product_id = hash.key?('product_id') ? hash['product_id'] : SKIP product_change_delayed = hash.key?('product_change_delayed') ? hash['product_change_delayed'] : SKIP next_product_id = hash.key?('next_product_id') ? hash['next_product_id'] : SKIP next_product_price_point_id = hash.key?('next_product_price_point_id') ? hash['next_product_price_point_id'] : SKIP snap_day = hash.key?('snap_day') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:UpdateSubscriptionSnapDay), hash['snap_day'] ) : SKIP next_billing_at = if hash.key?('next_billing_at') (DateTimeHelper.from_rfc3339(hash['next_billing_at']) if hash['next_billing_at']) else SKIP end payment_collection_method = hash.key?('payment_collection_method') ? hash['payment_collection_method'] : SKIP receives_invoice_emails = hash.key?('receives_invoice_emails') ? hash['receives_invoice_emails'] : SKIP net_terms = hash.key?('net_terms') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:UpdateSubscriptionNetTerms), hash['net_terms'] ) : SKIP stored_credential_transaction_id = hash.key?('stored_credential_transaction_id') ? hash['stored_credential_transaction_id'] : SKIP reference = hash.key?('reference') ? hash['reference'] : SKIP custom_price = SubscriptionCustomPrice.from_hash(hash['custom_price']) if hash['custom_price'] # Parameter is an array, so we need to iterate through it components = nil unless hash['components'].nil? components = [] hash['components'].each do |structure| components << (UpdateSubscriptionComponent.from_hash(structure) if structure) end end components = SKIP unless hash.key?('components') dunning_communication_delay_enabled = hash.key?('dunning_communication_delay_enabled') ? hash['dunning_communication_delay_enabled'] : SKIP dunning_communication_delay_time_zone = hash.key?('dunning_communication_delay_time_zone') ? hash['dunning_communication_delay_time_zone'] : SKIP product_price_point_id = hash.key?('product_price_point_id') ? hash['product_price_point_id'] : SKIP product_price_point_handle = hash.key?('product_price_point_handle') ? hash['product_price_point_handle'] : SKIP # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. UpdateSubscription.new(credit_card_attributes: credit_card_attributes, product_handle: product_handle, product_id: product_id, product_change_delayed: product_change_delayed, next_product_id: next_product_id, next_product_price_point_id: next_product_price_point_id, snap_day: snap_day, next_billing_at: next_billing_at, payment_collection_method: payment_collection_method, receives_invoice_emails: receives_invoice_emails, net_terms: net_terms, stored_credential_transaction_id: stored_credential_transaction_id, reference: reference, custom_price: custom_price, components: components, dunning_communication_delay_enabled: dunning_communication_delay_enabled, dunning_communication_delay_time_zone: dunning_communication_delay_time_zone, product_price_point_id: product_price_point_id, product_price_point_handle: product_price_point_handle, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
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 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 102 def self.names @_hash = {} if @_hash.nil? @_hash['credit_card_attributes'] = 'credit_card_attributes' @_hash['product_handle'] = 'product_handle' @_hash['product_id'] = 'product_id' @_hash['product_change_delayed'] = 'product_change_delayed' @_hash['next_product_id'] = 'next_product_id' @_hash['next_product_price_point_id'] = 'next_product_price_point_id' @_hash['snap_day'] = 'snap_day' @_hash['next_billing_at'] = 'next_billing_at' @_hash['payment_collection_method'] = 'payment_collection_method' @_hash['receives_invoice_emails'] = 'receives_invoice_emails' @_hash['net_terms'] = 'net_terms' @_hash['stored_credential_transaction_id'] = 'stored_credential_transaction_id' @_hash['reference'] = 'reference' @_hash['custom_price'] = 'custom_price' @_hash['components'] = 'components' @_hash['dunning_communication_delay_enabled'] = 'dunning_communication_delay_enabled' @_hash['dunning_communication_delay_time_zone'] = 'dunning_communication_delay_time_zone' @_hash['product_price_point_id'] = 'product_price_point_id' @_hash['product_price_point_handle'] = 'product_price_point_handle' @_hash end |
.nullables ⇒ Object
An array for nullable fields
155 156 157 158 159 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 155 def self.nullables %w[ dunning_communication_delay_time_zone ] end |
.optionals ⇒ Object
An array for optional fields
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 130 def self.optionals %w[ credit_card_attributes product_handle product_id product_change_delayed next_product_id next_product_price_point_id snap_day next_billing_at payment_collection_method receives_invoice_emails net_terms stored_credential_transaction_id reference custom_price components dunning_communication_delay_enabled dunning_communication_delay_time_zone product_price_point_id product_price_point_handle ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
304 305 306 307 308 309 310 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 304 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#to_custom_next_billing_at ⇒ Object
298 299 300 |
# File 'lib/advanced_billing/models/update_subscription.rb', line 298 def to_custom_next_billing_at DateTimeHelper.to_rfc3339(next_billing_at) end |