Class: AdvancedBilling::CreateSubscription

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

Overview

CreateSubscription Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(product_handle: SKIP, product_id: SKIP, product_price_point_handle: SKIP, product_price_point_id: SKIP, custom_price: SKIP, coupon_code: SKIP, coupon_codes: SKIP, payment_collection_method: SKIP, receives_invoice_emails: SKIP, net_terms: SKIP, customer_id: SKIP, next_billing_at: SKIP, initial_billing_at: SKIP, stored_credential_transaction_id: SKIP, sales_rep_id: SKIP, payment_profile_id: SKIP, reference: SKIP, customer_attributes: SKIP, payment_profile_attributes: SKIP, credit_card_attributes: SKIP, bank_account_attributes: SKIP, components: SKIP, calendar_billing: SKIP, metafields: SKIP, customer_reference: SKIP, group: SKIP, ref: SKIP, cancellation_message: SKIP, cancellation_method: SKIP, currency: SKIP, expires_at: SKIP, expiration_tracks_next_billing_change: SKIP, agreement_terms: SKIP, authorizer_first_name: SKIP, authorizer_last_name: SKIP, calendar_billing_first_charge: SKIP, reason_code: SKIP, product_change_delayed: SKIP, offer_id: SKIP, prepaid_configuration: SKIP, previous_billing_at: SKIP, import_mrr: SKIP, canceled_at: SKIP, activated_at: SKIP, agreement_acceptance: SKIP, ach_agreement: SKIP, dunning_communication_delay_enabled: false, dunning_communication_delay_time_zone: SKIP, skip_billing_manifest_taxes: false, additional_properties: {}) ⇒ CreateSubscription

Returns a new instance of CreateSubscription.



435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/advanced_billing/models/create_subscription.rb', line 435

def initialize(product_handle: SKIP, product_id: SKIP,
               product_price_point_handle: SKIP,
               product_price_point_id: SKIP, custom_price: SKIP,
               coupon_code: SKIP, coupon_codes: SKIP,
               payment_collection_method: SKIP,
               receives_invoice_emails: SKIP, net_terms: SKIP,
               customer_id: SKIP, next_billing_at: SKIP,
               initial_billing_at: SKIP,
               stored_credential_transaction_id: SKIP, sales_rep_id: SKIP,
               payment_profile_id: SKIP, reference: SKIP,
               customer_attributes: SKIP, payment_profile_attributes: SKIP,
               credit_card_attributes: SKIP, bank_account_attributes: SKIP,
               components: SKIP, calendar_billing: SKIP, metafields: SKIP,
               customer_reference: SKIP, group: SKIP, ref: SKIP,
               cancellation_message: SKIP, cancellation_method: SKIP,
               currency: SKIP, expires_at: SKIP,
               expiration_tracks_next_billing_change: SKIP,
               agreement_terms: SKIP, authorizer_first_name: SKIP,
               authorizer_last_name: SKIP,
               calendar_billing_first_charge: SKIP, reason_code: SKIP,
               product_change_delayed: SKIP, offer_id: SKIP,
               prepaid_configuration: SKIP, previous_billing_at: SKIP,
               import_mrr: SKIP, canceled_at: SKIP, activated_at: SKIP,
               agreement_acceptance: SKIP, ach_agreement: SKIP,
               dunning_communication_delay_enabled: false,
               dunning_communication_delay_time_zone: SKIP,
               skip_billing_manifest_taxes: false,
               additional_properties: {})
  @product_handle = product_handle unless product_handle == SKIP
  @product_id = product_id unless product_id == SKIP
  unless product_price_point_handle == SKIP
    @product_price_point_handle =
      product_price_point_handle
  end
  @product_price_point_id = product_price_point_id unless product_price_point_id == SKIP
  @custom_price = custom_price unless custom_price == SKIP
  @coupon_code = coupon_code unless coupon_code == SKIP
  @coupon_codes = coupon_codes unless coupon_codes == 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
  @customer_id = customer_id unless customer_id == SKIP
  @next_billing_at = next_billing_at unless next_billing_at == SKIP
  @initial_billing_at = initial_billing_at unless initial_billing_at == SKIP
  unless stored_credential_transaction_id == SKIP
    @stored_credential_transaction_id =
      stored_credential_transaction_id
  end
  @sales_rep_id = sales_rep_id unless sales_rep_id == SKIP
  @payment_profile_id = payment_profile_id unless payment_profile_id == SKIP
  @reference = reference unless reference == SKIP
  @customer_attributes = customer_attributes unless customer_attributes == SKIP
  unless payment_profile_attributes == SKIP
    @payment_profile_attributes =
      payment_profile_attributes
  end
  @credit_card_attributes = credit_card_attributes unless credit_card_attributes == SKIP
  @bank_account_attributes =  unless  == SKIP
  @components = components unless components == SKIP
  @calendar_billing = calendar_billing unless calendar_billing == SKIP
  @metafields = metafields unless metafields == SKIP
  @customer_reference = customer_reference unless customer_reference == SKIP
  @group = group unless group == SKIP
  @ref = ref unless ref == SKIP
  @cancellation_message = cancellation_message unless cancellation_message == SKIP
  @cancellation_method = cancellation_method unless cancellation_method == SKIP
  @currency = currency unless currency == SKIP
  @expires_at = expires_at unless expires_at == SKIP
  unless expiration_tracks_next_billing_change == SKIP
    @expiration_tracks_next_billing_change =
      expiration_tracks_next_billing_change
  end
  @agreement_terms = agreement_terms unless agreement_terms == SKIP
  @authorizer_first_name = authorizer_first_name unless authorizer_first_name == SKIP
  @authorizer_last_name = authorizer_last_name unless authorizer_last_name == SKIP
  unless calendar_billing_first_charge == SKIP
    @calendar_billing_first_charge =
      calendar_billing_first_charge
  end
  @reason_code = reason_code unless reason_code == SKIP
  @product_change_delayed = product_change_delayed unless product_change_delayed == SKIP
  @offer_id = offer_id unless offer_id == SKIP
  @prepaid_configuration = prepaid_configuration unless prepaid_configuration == SKIP
  @previous_billing_at = previous_billing_at unless previous_billing_at == SKIP
  @import_mrr = import_mrr unless import_mrr == SKIP
  @canceled_at = canceled_at unless canceled_at == SKIP
  @activated_at = activated_at unless activated_at == SKIP
  @agreement_acceptance = agreement_acceptance unless agreement_acceptance == SKIP
  @ach_agreement = ach_agreement unless ach_agreement == 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
  unless skip_billing_manifest_taxes == SKIP
    @skip_billing_manifest_taxes =
      skip_billing_manifest_taxes
  end

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

Instance Attribute Details

#ach_agreementACHAgreement

(Optional) If passed, the proof of the authorized ACH agreement terms will be persisted.

Returns:



295
296
297
# File 'lib/advanced_billing/models/create_subscription.rb', line 295

def ach_agreement
  @ach_agreement
end

#activated_atDateTime

Setting this attribute to true will cause the subscription’s MRR to be added to your MRR analytics immediately. For this value to be honored, a next_billing_at must be present and set to a future date. This key/value will not be returned in the subscription response body.

Returns:

  • (DateTime)


286
287
288
# File 'lib/advanced_billing/models/create_subscription.rb', line 286

def activated_at
  @activated_at
end

#agreement_acceptanceAgreementAcceptance

Required when creating a subscription with Maxio Payments.

Returns:



290
291
292
# File 'lib/advanced_billing/models/create_subscription.rb', line 290

def agreement_acceptance
  @agreement_acceptance
end

#agreement_termsString

(Optional) The ACH authorization agreement terms. If enabled, an email will be sent to the customer with a copy of the terms.

Returns:

  • (String)


218
219
220
# File 'lib/advanced_billing/models/create_subscription.rb', line 218

def agreement_terms
  @agreement_terms
end

#authorizer_first_nameString

(Optional) The first name of the person authorizing the ACH agreement.

Returns:

  • (String)


222
223
224
# File 'lib/advanced_billing/models/create_subscription.rb', line 222

def authorizer_first_name
  @authorizer_first_name
end

#authorizer_last_nameString

(Optional) The last name of the person authorizing the ACH agreement.

Returns:

  • (String)


226
227
228
# File 'lib/advanced_billing/models/create_subscription.rb', line 226

def authorizer_last_name
  @authorizer_last_name
end

#bank_account_attributesBankAccountAttributes

Credit Card data to create a new Subscription. Interchangeable with ‘payment_profile_attributes` property.



147
148
149
# File 'lib/advanced_billing/models/create_subscription.rb', line 147

def 
  @bank_account_attributes
end

#calendar_billingCalendarBilling

(Optional). Cannot be used when also specifying next_billing_at

Returns:



158
159
160
# File 'lib/advanced_billing/models/create_subscription.rb', line 158

def calendar_billing
  @calendar_billing
end

#calendar_billing_first_chargeString

(Optional) One of “prorated” (the default – the prorated product price will be charged immediately), “immediate” (the full product price will be charged immediately), or “delayed” (the full product price will be charged with the first scheduled renewal).

Returns:

  • (String)


233
234
235
# File 'lib/advanced_billing/models/create_subscription.rb', line 233

def calendar_billing_first_charge
  @calendar_billing_first_charge
end

#canceled_atDateTime

Setting this attribute to true will cause the subscription’s MRR to be added to your MRR analytics immediately. For this value to be honored, a next_billing_at must be present and set to a future date. This key/value will not be returned in the subscription response body.

Returns:

  • (DateTime)


279
280
281
# File 'lib/advanced_billing/models/create_subscription.rb', line 279

def canceled_at
  @canceled_at
end

#cancellation_messageString

(Optional) Can be used when canceling a subscription (via the HTTP DELETE method) to make a note about the reason for cancellation.

Returns:

  • (String)


188
189
190
# File 'lib/advanced_billing/models/create_subscription.rb', line 188

def cancellation_message
  @cancellation_message
end

#cancellation_methodString

(Optional) Can be used when canceling a subscription (via the HTTP DELETE method) to make a note about how the subscription was canceled.

Returns:

  • (String)


193
194
195
# File 'lib/advanced_billing/models/create_subscription.rb', line 193

def cancellation_method
  @cancellation_method
end

#componentsArray[CreateSubscriptionComponent]

(Optional) An array of component ids and quantities to be added to the subscription. See [Components](maxio.zendesk.com/hc/en-us/articles/24261141522189-Co mponents-Overview) for more information.

Returns:



154
155
156
# File 'lib/advanced_billing/models/create_subscription.rb', line 154

def components
  @components
end

#coupon_codeString

(deprecated) The coupon code of the single coupon currently applied to the subscription. See coupon_codes instead as subscriptions can now have more than one coupon.

Returns:

  • (String)


41
42
43
# File 'lib/advanced_billing/models/create_subscription.rb', line 41

def coupon_code
  @coupon_code
end

#coupon_codesArray[String]

An array for all the coupons attached to the subscription.

Returns:

  • (Array[String])


45
46
47
# File 'lib/advanced_billing/models/create_subscription.rb', line 45

def coupon_codes
  @coupon_codes
end

#credit_card_attributesPaymentProfileAttributes

Credit Card data to create a new Subscription. Interchangeable with ‘payment_profile_attributes` property.



142
143
144
# File 'lib/advanced_billing/models/create_subscription.rb', line 142

def credit_card_attributes
  @credit_card_attributes
end

#currencyString

(Optional) If Multi-Currency is enabled and the currency is configured in Chargify, pass it at signup to create a subscription on a non-default currency. Note that you cannot update the currency of an existing subscription.

Returns:

  • (String)


200
201
202
# File 'lib/advanced_billing/models/create_subscription.rb', line 200

def currency
  @currency
end

#custom_priceSubscriptionCustomPrice

(Optional) Used in place of ‘product_price_point_id` to define a custom price point unique to the subscription



35
36
37
# File 'lib/advanced_billing/models/create_subscription.rb', line 35

def custom_price
  @custom_price
end

#customer_attributesCustomerAttributes

The reference value (provided by your app) for the subscription itelf.

Returns:



133
134
135
# File 'lib/advanced_billing/models/create_subscription.rb', line 133

def customer_attributes
  @customer_attributes
end

#customer_idInteger

The ID of an existing customer within Chargify. Required, unless a ‘customer_reference` or a set of `customer_attributes` is given.

Returns:

  • (Integer)


68
69
70
# File 'lib/advanced_billing/models/create_subscription.rb', line 68

def customer_id
  @customer_id
end

#customer_referenceString

The reference value (provided by your app) of an existing customer within Chargify. Required, unless a ‘customer_id` or a set of `customer_attributes` is given.

Returns:

  • (String)


170
171
172
# File 'lib/advanced_billing/models/create_subscription.rb', line 170

def customer_reference
  @customer_reference
end

#dunning_communication_delay_enabledTrueClass | 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.

Returns:

  • (TrueClass | FalseClass)


301
302
303
# File 'lib/advanced_billing/models/create_subscription.rb', line 301

def dunning_communication_delay_enabled
  @dunning_communication_delay_enabled
end

#dunning_communication_delay_time_zoneString

Time zone for the Dunning Communication Delay feature.

Returns:

  • (String)


305
306
307
# File 'lib/advanced_billing/models/create_subscription.rb', line 305

def dunning_communication_delay_time_zone
  @dunning_communication_delay_time_zone
end

#expiration_tracks_next_billing_changeString

(Optional, default false) When set to true, and when next_billing_at is present, if the subscription expires, the expires_at will be shifted by the same amount of time as the difference between the old and new “next billing” dates.

Returns:

  • (String)


213
214
215
# File 'lib/advanced_billing/models/create_subscription.rb', line 213

def expiration_tracks_next_billing_change
  @expiration_tracks_next_billing_change
end

#expires_atDateTime

Timestamp giving the expiration date of this subscription (if any). You may manually change the expiration date at any point during a subscription period.

Returns:

  • (DateTime)


206
207
208
# File 'lib/advanced_billing/models/create_subscription.rb', line 206

def expires_at
  @expires_at
end

#groupGroupSettings

The reference value (provided by your app) of an existing customer within Chargify. Required, unless a ‘customer_id` or a set of `customer_attributes` is given.

Returns:



176
177
178
# File 'lib/advanced_billing/models/create_subscription.rb', line 176

def group
  @group
end

#import_mrrTrueClass | FalseClass

Setting this attribute to true will cause the subscription’s MRR to be added to your MRR analytics immediately. For this value to be honored, a next_billing_at must be present and set to a future date. This key/value will not be returned in the subscription response body.

Returns:

  • (TrueClass | FalseClass)


272
273
274
# File 'lib/advanced_billing/models/create_subscription.rb', line 272

def import_mrr
  @import_mrr
end

#initial_billing_atDateTime

(Optional) Set this attribute to a future date/time to create a subscription in the “Awaiting Signup” state, rather than “Active” or “Trialing”. See the notes on “Date/Time Format” in our [subscription import documentation](maxio.zendesk.com/hc/en-us/articles/24251489107213- Advanced-Billing-Subscription-Imports#date-format). In the “Awaiting Signup” state, a subscription behaves like any other. It can be canceled, allocated to, had its billing date changed. etc. When the initial_billing_at date hits, the subscription will transition to the expected state. If the product has a trial, the subscription will enter a trial, otherwise it will go active. Setup fees will be respected either before or after the trial, as configured on the price point. If the payment is due at the initial_billing_at and it fails the subscription will be immediately canceled. See further notes in the section on Delayed Signups.

Returns:

  • (DateTime)


103
104
105
# File 'lib/advanced_billing/models/create_subscription.rb', line 103

def initial_billing_at
  @initial_billing_at
end

#metafieldsHash[String, String]

(Optional) A set of key/value pairs representing custom fields and their values. Metafields will be created “on-the-fly” in your site for a given key, if they have not been created yet.

Returns:

  • (Hash[String, String])


164
165
166
# File 'lib/advanced_billing/models/create_subscription.rb', line 164

def metafields
  @metafields
end

#net_termsString

(Optional) Default: null The number of days after renewal (on invoice billing) that a subscription is due. A value between 0 (due immediately) and 180.

Returns:

  • (String)


63
64
65
# File 'lib/advanced_billing/models/create_subscription.rb', line 63

def net_terms
  @net_terms
end

#next_billing_atDateTime

(Optional) Set this attribute to a future date/time to sync imported subscriptions to your existing renewal schedule. See the notes on “Date/Time Format” in our [subscription import documentation](maxio.zendesk.com/hc/en-us/articles/24251489107213- Advanced-Billing-Subscription-Imports#date-format). If you provide a next_billing_at timestamp that is in the future, no trial or initial charges will be applied when you create the subscription. In fact, no payment will be captured at all. The first payment will be captured, according to the prices defined by the product, near the time specified by next_billing_at. If you do not provide a value for next_billing_at, any trial and/or initial charges will be assessed and charged at the time of subscription creation. If the card cannot be successfully charged, the subscription will not be created. See further notes in the section on Importing Subscriptions.

Returns:

  • (DateTime)


85
86
87
# File 'lib/advanced_billing/models/create_subscription.rb', line 85

def next_billing_at
  @next_billing_at
end

#offer_idObject

Use in place of passing product and component information to set up the subscription with an existing offer. May be either the Chargify id of the offer or its handle prefixed with ‘handle:`.er

Returns:

  • (Object)


250
251
252
# File 'lib/advanced_billing/models/create_subscription.rb', line 250

def offer_id
  @offer_id
end

#payment_collection_methodCollectionMethod

The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - ‘invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`.

Returns:



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

def payment_collection_method
  @payment_collection_method
end

#payment_profile_attributesPaymentProfileAttributes

alias to credit_card_attributes



137
138
139
# File 'lib/advanced_billing/models/create_subscription.rb', line 137

def payment_profile_attributes
  @payment_profile_attributes
end

#payment_profile_idInteger

The Payment Profile ID of an existing card or bank account, which belongs to an existing customer to use for payment for this subscription. If the card, bank account, or customer does not exist already, or if you want to use a new (unstored) card or bank account for the subscription, use ‘payment_profile_attributes` instead to create a new payment profile along with the subscription. (This value is available on an existing subscription via the API as `credit_card` > id or `bank_account` > id)

Returns:

  • (Integer)


125
126
127
# File 'lib/advanced_billing/models/create_subscription.rb', line 125

def payment_profile_id
  @payment_profile_id
end

#prepaid_configurationUpsertPrepaidConfiguration

Use in place of passing product and component information to set up the subscription with an existing offer. May be either the Chargify id of the offer or its handle prefixed with ‘handle:`.er



256
257
258
# File 'lib/advanced_billing/models/create_subscription.rb', line 256

def prepaid_configuration
  @prepaid_configuration
end

#previous_billing_atDateTime

Providing a previous_billing_at that is in the past will set the current_period_starts_at when the subscription is created. It will also set activated_at if not explicitly passed during the subscription import. Can only be used if next_billing_at is also passed. Using this option will allow you to set the period start for the subscription so mid period component allocations have the correct prorated amount.

Returns:

  • (DateTime)


265
266
267
# File 'lib/advanced_billing/models/create_subscription.rb', line 265

def previous_billing_at
  @previous_billing_at
end

#product_change_delayedTrueClass | FalseClass

(Optional, used only for Delayed Product Change When set to true, indicates that a changed value for product_handle should schedule the product change to the next subscription renewal.

Returns:

  • (TrueClass | FalseClass)


244
245
246
# File 'lib/advanced_billing/models/create_subscription.rb', line 244

def product_change_delayed
  @product_change_delayed
end

#product_handleString

The API Handle of the product for which you are creating a subscription. Required, unless a ‘product_id` is given instead.

Returns:

  • (String)


16
17
18
# File 'lib/advanced_billing/models/create_subscription.rb', line 16

def product_handle
  @product_handle
end

#product_idInteger

The Product ID of the product for which you are creating a subscription. The product ID is not currently published, so we recommend using the API Handle instead.

Returns:

  • (Integer)


22
23
24
# File 'lib/advanced_billing/models/create_subscription.rb', line 22

def product_id
  @product_id
end

#product_price_point_handleString

The user-friendly API handle of a product’s particular price point.

Returns:

  • (String)


26
27
28
# File 'lib/advanced_billing/models/create_subscription.rb', line 26

def product_price_point_handle
  @product_price_point_handle
end

#product_price_point_idInteger

The ID of the particular price point on the product.

Returns:

  • (Integer)


30
31
32
# File 'lib/advanced_billing/models/create_subscription.rb', line 30

def product_price_point_id
  @product_price_point_id
end

#reason_codeString

(Optional) Can be used when canceling a subscription (via the HTTP DELETE method) to indicate why a subscription was canceled.

Returns:

  • (String)


238
239
240
# File 'lib/advanced_billing/models/create_subscription.rb', line 238

def reason_code
  @reason_code
end

#receives_invoice_emailsString

(Optional) Default: True - Whether or not this subscription is set to receive emails related to this subscription.

Returns:

  • (String)


57
58
59
# File 'lib/advanced_billing/models/create_subscription.rb', line 57

def receives_invoice_emails
  @receives_invoice_emails
end

#refString

A valid referral code. (optional, see [Referrals](maxio.zendesk.com/hc/en-us/articles/24286981223693-Ref errals-Reference#how-to-obtain-referral-codes) for more details). If supplied, must be valid, or else subscription creation will fail.

Returns:

  • (String)


183
184
185
# File 'lib/advanced_billing/models/create_subscription.rb', line 183

def ref
  @ref
end

#referenceString

The reference value (provided by your app) for the subscription itelf.

Returns:

  • (String)


129
130
131
# File 'lib/advanced_billing/models/create_subscription.rb', line 129

def reference
  @reference
end

#sales_rep_idInteger

For European sites subject to PSD2 and using 3D Secure, this can be used to reference a previous transaction for the customer. This will ensure the card will be charged successfully at renewal.

Returns:

  • (Integer)


115
116
117
# File 'lib/advanced_billing/models/create_subscription.rb', line 115

def sales_rep_id
  @sales_rep_id
end

#skip_billing_manifest_taxesTrueClass | FalseClass

Valid only for the Subscription Preview endpoint. When set to ‘true` it skips calculating taxes for the current and next billing manifests.

Returns:

  • (TrueClass | FalseClass)


310
311
312
# File 'lib/advanced_billing/models/create_subscription.rb', line 310

def skip_billing_manifest_taxes
  @skip_billing_manifest_taxes
end

#stored_credential_transaction_idInteger

For European sites subject to PSD2 and using 3D Secure, this can be used to reference a previous transaction for the customer. This will ensure the card will be charged successfully at renewal.

Returns:

  • (Integer)


109
110
111
# File 'lib/advanced_billing/models/create_subscription.rb', line 109

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.



547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
# File 'lib/advanced_billing/models/create_subscription.rb', line 547

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  product_handle =
    hash.key?('product_handle') ? hash['product_handle'] : SKIP
  product_id = hash.key?('product_id') ? hash['product_id'] : SKIP
  product_price_point_handle =
    hash.key?('product_price_point_handle') ? hash['product_price_point_handle'] : SKIP
  product_price_point_id =
    hash.key?('product_price_point_id') ? hash['product_price_point_id'] : SKIP
  custom_price = SubscriptionCustomPrice.from_hash(hash['custom_price']) if
    hash['custom_price']
  coupon_code = hash.key?('coupon_code') ? hash['coupon_code'] : SKIP
  coupon_codes = hash.key?('coupon_codes') ? hash['coupon_codes'] : SKIP
  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') ? hash['net_terms'] : SKIP
  customer_id = hash.key?('customer_id') ? hash['customer_id'] : 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
  initial_billing_at = if hash.key?('initial_billing_at')
                         (DateTimeHelper.from_rfc3339(hash['initial_billing_at']) if hash['initial_billing_at'])
                       else
                         SKIP
                       end
  stored_credential_transaction_id =
    hash.key?('stored_credential_transaction_id') ? hash['stored_credential_transaction_id'] : SKIP
  sales_rep_id = hash.key?('sales_rep_id') ? hash['sales_rep_id'] : SKIP
  payment_profile_id =
    hash.key?('payment_profile_id') ? hash['payment_profile_id'] : SKIP
  reference = hash.key?('reference') ? hash['reference'] : SKIP
  customer_attributes = CustomerAttributes.from_hash(hash['customer_attributes']) if
    hash['customer_attributes']
  if hash['payment_profile_attributes']
    payment_profile_attributes = PaymentProfileAttributes.from_hash(hash['payment_profile_attributes'])
  end
  credit_card_attributes = PaymentProfileAttributes.from_hash(hash['credit_card_attributes']) if
    hash['credit_card_attributes']
   = BankAccountAttributes.from_hash(hash['bank_account_attributes']) if
    hash['bank_account_attributes']
  # Parameter is an array, so we need to iterate through it
  components = nil
  unless hash['components'].nil?
    components = []
    hash['components'].each do |structure|
      components << (CreateSubscriptionComponent.from_hash(structure) if structure)
    end
  end

  components = SKIP unless hash.key?('components')
  calendar_billing = CalendarBilling.from_hash(hash['calendar_billing']) if
    hash['calendar_billing']
  metafields = hash.key?('metafields') ? hash['metafields'] : SKIP
  customer_reference =
    hash.key?('customer_reference') ? hash['customer_reference'] : SKIP
  group = GroupSettings.from_hash(hash['group']) if hash['group']
  ref = hash.key?('ref') ? hash['ref'] : SKIP
  cancellation_message =
    hash.key?('cancellation_message') ? hash['cancellation_message'] : SKIP
  cancellation_method =
    hash.key?('cancellation_method') ? hash['cancellation_method'] : SKIP
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  expires_at = if hash.key?('expires_at')
                 (DateTimeHelper.from_rfc3339(hash['expires_at']) if hash['expires_at'])
               else
                 SKIP
               end
  expiration_tracks_next_billing_change =
    hash.key?('expiration_tracks_next_billing_change') ? hash['expiration_tracks_next_billing_change'] : SKIP
  agreement_terms =
    hash.key?('agreement_terms') ? hash['agreement_terms'] : SKIP
  authorizer_first_name =
    hash.key?('authorizer_first_name') ? hash['authorizer_first_name'] : SKIP
  authorizer_last_name =
    hash.key?('authorizer_last_name') ? hash['authorizer_last_name'] : SKIP
  calendar_billing_first_charge =
    hash.key?('calendar_billing_first_charge') ? hash['calendar_billing_first_charge'] : SKIP
  reason_code = hash.key?('reason_code') ? hash['reason_code'] : SKIP
  product_change_delayed =
    hash.key?('product_change_delayed') ? hash['product_change_delayed'] : SKIP
  offer_id = hash.key?('offer_id') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:CreateSubscriptionOfferId), hash['offer_id']
  ) : SKIP
  prepaid_configuration = UpsertPrepaidConfiguration.from_hash(hash['prepaid_configuration']) if
    hash['prepaid_configuration']
  previous_billing_at = if hash.key?('previous_billing_at')
                          (DateTimeHelper.from_rfc3339(hash['previous_billing_at']) if hash['previous_billing_at'])
                        else
                          SKIP
                        end
  import_mrr = hash.key?('import_mrr') ? hash['import_mrr'] : SKIP
  canceled_at = if hash.key?('canceled_at')
                  (DateTimeHelper.from_rfc3339(hash['canceled_at']) if hash['canceled_at'])
                else
                  SKIP
                end
  activated_at = if hash.key?('activated_at')
                   (DateTimeHelper.from_rfc3339(hash['activated_at']) if hash['activated_at'])
                 else
                   SKIP
                 end
  agreement_acceptance = AgreementAcceptance.from_hash(hash['agreement_acceptance']) if
    hash['agreement_acceptance']
  ach_agreement = ACHAgreement.from_hash(hash['ach_agreement']) if hash['ach_agreement']
  dunning_communication_delay_enabled =
    hash['dunning_communication_delay_enabled'] ||= false
  dunning_communication_delay_time_zone =
    hash.key?('dunning_communication_delay_time_zone') ? hash['dunning_communication_delay_time_zone'] : SKIP
  skip_billing_manifest_taxes =
    hash['skip_billing_manifest_taxes'] ||= false

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

  # Create object from extracted values.
  CreateSubscription.new(product_handle: product_handle,
                         product_id: product_id,
                         product_price_point_handle: product_price_point_handle,
                         product_price_point_id: product_price_point_id,
                         custom_price: custom_price,
                         coupon_code: coupon_code,
                         coupon_codes: coupon_codes,
                         payment_collection_method: payment_collection_method,
                         receives_invoice_emails: receives_invoice_emails,
                         net_terms: net_terms,
                         customer_id: customer_id,
                         next_billing_at: next_billing_at,
                         initial_billing_at: initial_billing_at,
                         stored_credential_transaction_id: stored_credential_transaction_id,
                         sales_rep_id: sales_rep_id,
                         payment_profile_id: payment_profile_id,
                         reference: reference,
                         customer_attributes: customer_attributes,
                         payment_profile_attributes: payment_profile_attributes,
                         credit_card_attributes: credit_card_attributes,
                         bank_account_attributes: ,
                         components: components,
                         calendar_billing: calendar_billing,
                         metafields: metafields,
                         customer_reference: customer_reference,
                         group: group,
                         ref: ref,
                         cancellation_message: cancellation_message,
                         cancellation_method: cancellation_method,
                         currency: currency,
                         expires_at: expires_at,
                         expiration_tracks_next_billing_change: expiration_tracks_next_billing_change,
                         agreement_terms: agreement_terms,
                         authorizer_first_name: authorizer_first_name,
                         authorizer_last_name: authorizer_last_name,
                         calendar_billing_first_charge: calendar_billing_first_charge,
                         reason_code: reason_code,
                         product_change_delayed: product_change_delayed,
                         offer_id: offer_id,
                         prepaid_configuration: prepaid_configuration,
                         previous_billing_at: previous_billing_at,
                         import_mrr: import_mrr,
                         canceled_at: canceled_at,
                         activated_at: activated_at,
                         agreement_acceptance: agreement_acceptance,
                         ach_agreement: ach_agreement,
                         dunning_communication_delay_enabled: dunning_communication_delay_enabled,
                         dunning_communication_delay_time_zone: dunning_communication_delay_time_zone,
                         skip_billing_manifest_taxes: skip_billing_manifest_taxes,
                         additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/advanced_billing/models/create_subscription.rb', line 313

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['product_handle'] = 'product_handle'
  @_hash['product_id'] = 'product_id'
  @_hash['product_price_point_handle'] = 'product_price_point_handle'
  @_hash['product_price_point_id'] = 'product_price_point_id'
  @_hash['custom_price'] = 'custom_price'
  @_hash['coupon_code'] = 'coupon_code'
  @_hash['coupon_codes'] = 'coupon_codes'
  @_hash['payment_collection_method'] = 'payment_collection_method'
  @_hash['receives_invoice_emails'] = 'receives_invoice_emails'
  @_hash['net_terms'] = 'net_terms'
  @_hash['customer_id'] = 'customer_id'
  @_hash['next_billing_at'] = 'next_billing_at'
  @_hash['initial_billing_at'] = 'initial_billing_at'
  @_hash['stored_credential_transaction_id'] =
    'stored_credential_transaction_id'
  @_hash['sales_rep_id'] = 'sales_rep_id'
  @_hash['payment_profile_id'] = 'payment_profile_id'
  @_hash['reference'] = 'reference'
  @_hash['customer_attributes'] = 'customer_attributes'
  @_hash['payment_profile_attributes'] = 'payment_profile_attributes'
  @_hash['credit_card_attributes'] = 'credit_card_attributes'
  @_hash['bank_account_attributes'] = 'bank_account_attributes'
  @_hash['components'] = 'components'
  @_hash['calendar_billing'] = 'calendar_billing'
  @_hash['metafields'] = 'metafields'
  @_hash['customer_reference'] = 'customer_reference'
  @_hash['group'] = 'group'
  @_hash['ref'] = 'ref'
  @_hash['cancellation_message'] = 'cancellation_message'
  @_hash['cancellation_method'] = 'cancellation_method'
  @_hash['currency'] = 'currency'
  @_hash['expires_at'] = 'expires_at'
  @_hash['expiration_tracks_next_billing_change'] =
    'expiration_tracks_next_billing_change'
  @_hash['agreement_terms'] = 'agreement_terms'
  @_hash['authorizer_first_name'] = 'authorizer_first_name'
  @_hash['authorizer_last_name'] = 'authorizer_last_name'
  @_hash['calendar_billing_first_charge'] =
    'calendar_billing_first_charge'
  @_hash['reason_code'] = 'reason_code'
  @_hash['product_change_delayed'] = 'product_change_delayed'
  @_hash['offer_id'] = 'offer_id'
  @_hash['prepaid_configuration'] = 'prepaid_configuration'
  @_hash['previous_billing_at'] = 'previous_billing_at'
  @_hash['import_mrr'] = 'import_mrr'
  @_hash['canceled_at'] = 'canceled_at'
  @_hash['activated_at'] = 'activated_at'
  @_hash['agreement_acceptance'] = 'agreement_acceptance'
  @_hash['ach_agreement'] = 'ach_agreement'
  @_hash['dunning_communication_delay_enabled'] =
    'dunning_communication_delay_enabled'
  @_hash['dunning_communication_delay_time_zone'] =
    'dunning_communication_delay_time_zone'
  @_hash['skip_billing_manifest_taxes'] = 'skip_billing_manifest_taxes'
  @_hash
end

.nullablesObject

An array for nullable fields



428
429
430
431
432
433
# File 'lib/advanced_billing/models/create_subscription.rb', line 428

def self.nullables
  %w[
    dunning_communication_delay_enabled
    dunning_communication_delay_time_zone
  ]
end

.optionalsObject

An array for optional fields



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/advanced_billing/models/create_subscription.rb', line 373

def self.optionals
  %w[
    product_handle
    product_id
    product_price_point_handle
    product_price_point_id
    custom_price
    coupon_code
    coupon_codes
    payment_collection_method
    receives_invoice_emails
    net_terms
    customer_id
    next_billing_at
    initial_billing_at
    stored_credential_transaction_id
    sales_rep_id
    payment_profile_id
    reference
    customer_attributes
    payment_profile_attributes
    credit_card_attributes
    bank_account_attributes
    components
    calendar_billing
    metafields
    customer_reference
    group
    ref
    cancellation_message
    cancellation_method
    currency
    expires_at
    expiration_tracks_next_billing_change
    agreement_terms
    authorizer_first_name
    authorizer_last_name
    calendar_billing_first_charge
    reason_code
    product_change_delayed
    offer_id
    prepaid_configuration
    previous_billing_at
    import_mrr
    canceled_at
    activated_at
    agreement_acceptance
    ach_agreement
    dunning_communication_delay_enabled
    dunning_communication_delay_time_zone
    skip_billing_manifest_taxes
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



746
747
748
749
750
751
752
# File 'lib/advanced_billing/models/create_subscription.rb', line 746

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_activated_atObject



740
741
742
# File 'lib/advanced_billing/models/create_subscription.rb', line 740

def to_custom_activated_at
  DateTimeHelper.to_rfc3339(activated_at)
end

#to_custom_canceled_atObject



736
737
738
# File 'lib/advanced_billing/models/create_subscription.rb', line 736

def to_custom_canceled_at
  DateTimeHelper.to_rfc3339(canceled_at)
end

#to_custom_expires_atObject



728
729
730
# File 'lib/advanced_billing/models/create_subscription.rb', line 728

def to_custom_expires_at
  DateTimeHelper.to_rfc3339(expires_at)
end

#to_custom_initial_billing_atObject



724
725
726
# File 'lib/advanced_billing/models/create_subscription.rb', line 724

def to_custom_initial_billing_at
  DateTimeHelper.to_rfc3339(initial_billing_at)
end

#to_custom_next_billing_atObject



720
721
722
# File 'lib/advanced_billing/models/create_subscription.rb', line 720

def to_custom_next_billing_at
  DateTimeHelper.to_rfc3339(next_billing_at)
end

#to_custom_previous_billing_atObject



732
733
734
# File 'lib/advanced_billing/models/create_subscription.rb', line 732

def to_custom_previous_billing_at
  DateTimeHelper.to_rfc3339(previous_billing_at)
end