zuora-ruby 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +1 -0
- data/.rubocop.yml +22 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +198 -0
- data/Rakefile +7 -0
- data/bin/console +21 -0
- data/bin/setup +7 -0
- data/circle.yml +3 -0
- data/lib/zuora.rb +33 -0
- data/lib/zuora/client.rb +113 -0
- data/lib/zuora/models.rb +10 -0
- data/lib/zuora/models/account.rb +53 -0
- data/lib/zuora/models/card_holder.rb +60 -0
- data/lib/zuora/models/contact.rb +44 -0
- data/lib/zuora/models/payment_method.rb +1 -0
- data/lib/zuora/models/payment_methods/credit_card.rb +37 -0
- data/lib/zuora/models/rate_plan.rb +21 -0
- data/lib/zuora/models/rate_plan_charge.rb +57 -0
- data/lib/zuora/models/subscription.rb +50 -0
- data/lib/zuora/models/tier.rb +27 -0
- data/lib/zuora/models/utils.rb +23 -0
- data/lib/zuora/resources.rb +17 -0
- data/lib/zuora/resources/accounts.rb +19 -0
- data/lib/zuora/resources/payment_methods.rb +1 -0
- data/lib/zuora/resources/payment_methods/credit_card.rb +26 -0
- data/lib/zuora/resources/subscriptions.rb +21 -0
- data/lib/zuora/serializers.rb +1 -0
- data/lib/zuora/serializers/attribute.rb +35 -0
- data/lib/zuora/serializers/noop.rb +18 -0
- data/lib/zuora/version.rb +6 -0
- data/zuora_ruby.gemspec +54 -0
- metadata +333 -0
    
        data/lib/zuora/models.rb
    ADDED
    
    | @@ -0,0 +1,10 @@ | |
| 1 | 
            +
            require_relative 'models/utils'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require_relative 'models/account'
         | 
| 4 | 
            +
            require_relative 'models/card_holder'
         | 
| 5 | 
            +
            require_relative 'models/contact'
         | 
| 6 | 
            +
            require_relative 'models/payment_method'
         | 
| 7 | 
            +
            require_relative 'models/rate_plan'
         | 
| 8 | 
            +
            require_relative 'models/rate_plan_charge'
         | 
| 9 | 
            +
            require_relative 'models/subscription'
         | 
| 10 | 
            +
            require_relative 'models/tier'
         | 
| @@ -0,0 +1,53 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Zuora
         | 
| 4 | 
            +
              module Models
         | 
| 5 | 
            +
                class Account
         | 
| 6 | 
            +
                  include ActiveModel::Model
         | 
| 7 | 
            +
                  # See http://api.rubyonrails.org/classes/ActiveModel/Dirty.html
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  ATTRIBUTES = :account_number,
         | 
| 10 | 
            +
                               :auto_pay,
         | 
| 11 | 
            +
                               :bill_to_contact,
         | 
| 12 | 
            +
                               :bill_cycle_day,
         | 
| 13 | 
            +
                               :crm_id,
         | 
| 14 | 
            +
                               :currency,
         | 
| 15 | 
            +
                               :credit_card,
         | 
| 16 | 
            +
                               :name,
         | 
| 17 | 
            +
                               :hpm_credit_card_payment_method_id,
         | 
| 18 | 
            +
                               :notes,
         | 
| 19 | 
            +
                               :invoice_template_id,
         | 
| 20 | 
            +
                               :communication_profile_id,
         | 
| 21 | 
            +
                               :payment_gateway,
         | 
| 22 | 
            +
                               :payment_term,
         | 
| 23 | 
            +
                               :sold_to_contact,
         | 
| 24 | 
            +
                               :subscription
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  attr_accessor(*ATTRIBUTES)
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  def attributes
         | 
| 29 | 
            +
                    ATTRIBUTES
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  Zuora::Models::Utils.validate_children self,
         | 
| 33 | 
            +
                                                         'contact',
         | 
| 34 | 
            +
                                                         :bill_to_contact,
         | 
| 35 | 
            +
                                                         :sold_to_contact
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  validates :auto_pay,
         | 
| 38 | 
            +
                            :bill_to_contact,
         | 
| 39 | 
            +
                            :credit_card,
         | 
| 40 | 
            +
                            :currency,
         | 
| 41 | 
            +
                            :name,
         | 
| 42 | 
            +
                            :payment_term,
         | 
| 43 | 
            +
                            :sold_to_contact,
         | 
| 44 | 
            +
                            presence: true
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                  validates :currency,
         | 
| 47 | 
            +
                            length: { is: 3 }
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                  validates :payment_term,
         | 
| 50 | 
            +
                            inclusion: { in: Zuora::PAYMENT_TERMS }
         | 
| 51 | 
            +
                end
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
            end
         | 
| @@ -0,0 +1,60 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Zuora
         | 
| 4 | 
            +
              module Models
         | 
| 5 | 
            +
                class CardHolder
         | 
| 6 | 
            +
                  include ActiveModel::Model
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  ATTRIBUTES = :card_holder_name,
         | 
| 9 | 
            +
                               :address_line_1,
         | 
| 10 | 
            +
                               :address_line_2,
         | 
| 11 | 
            +
                               :city,
         | 
| 12 | 
            +
                               :state,
         | 
| 13 | 
            +
                               :zip_code,
         | 
| 14 | 
            +
                               :country,
         | 
| 15 | 
            +
                               :phone,
         | 
| 16 | 
            +
                               :email
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  attr_accessor(*ATTRIBUTES)
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def attributes
         | 
| 21 | 
            +
                    ATTRIBUTES
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  validates :card_holder_name,
         | 
| 25 | 
            +
                            :address_line_1,
         | 
| 26 | 
            +
                            :city,
         | 
| 27 | 
            +
                            :state,
         | 
| 28 | 
            +
                            :zip_code,
         | 
| 29 | 
            +
                            :country,
         | 
| 30 | 
            +
                            presence: true
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  validates :card_holder_name,
         | 
| 33 | 
            +
                            length: { maximum: 50 }
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  validates :address_line_1,
         | 
| 36 | 
            +
                            length: { maximum: 255 }
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                  validates :address_line_2,
         | 
| 39 | 
            +
                            length: { maximum: 255 },
         | 
| 40 | 
            +
                            allow_nil: true
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                  validates :city,
         | 
| 43 | 
            +
                            length: { maximum: 40 }
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  validates :state,
         | 
| 46 | 
            +
                            inclusion: { in: Zuora::STATE_ABBREVIATIONS }
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  validates :zip_code,
         | 
| 49 | 
            +
                            length: { maximum: 20 }
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                  validates :phone,
         | 
| 52 | 
            +
                            length: { maximum: 20 },
         | 
| 53 | 
            +
                            allow_nil: true
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                  validates :email,
         | 
| 56 | 
            +
                            length: { maximum: 80 },
         | 
| 57 | 
            +
                            allow_nil: true
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
            end
         | 
| @@ -0,0 +1,44 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Zuora
         | 
| 4 | 
            +
              module Models
         | 
| 5 | 
            +
                class Contact
         | 
| 6 | 
            +
                  include ActiveModel::Model
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  ATTRIBUTES = :address_1,
         | 
| 9 | 
            +
                               :address_2,
         | 
| 10 | 
            +
                               :city,
         | 
| 11 | 
            +
                               :country,
         | 
| 12 | 
            +
                               :county,
         | 
| 13 | 
            +
                               :fax,
         | 
| 14 | 
            +
                               :first_name,
         | 
| 15 | 
            +
                               :home_phone,
         | 
| 16 | 
            +
                               :last_name,
         | 
| 17 | 
            +
                               :mobile_phone,
         | 
| 18 | 
            +
                               :nickname,
         | 
| 19 | 
            +
                               :other_phone,
         | 
| 20 | 
            +
                               :other_phone_type,
         | 
| 21 | 
            +
                               :personal_email,
         | 
| 22 | 
            +
                               :zip_code,
         | 
| 23 | 
            +
                               :state,
         | 
| 24 | 
            +
                               :tax_region,
         | 
| 25 | 
            +
                               :work_email,
         | 
| 26 | 
            +
                               :work_phone
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  attr_accessor(*ATTRIBUTES)
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  def attributes
         | 
| 31 | 
            +
                    ATTRIBUTES
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  validates :first_name,
         | 
| 35 | 
            +
                            :last_name,
         | 
| 36 | 
            +
                            :country,
         | 
| 37 | 
            +
                            presence: true
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  validates :first_name,
         | 
| 40 | 
            +
                            :last_name,
         | 
| 41 | 
            +
                            length: { maximum: 100 }
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
            end
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            require_relative 'payment_methods/credit_card'
         | 
| @@ -0,0 +1,37 @@ | |
| 1 | 
            +
            module Zuora
         | 
| 2 | 
            +
              module Models
         | 
| 3 | 
            +
                module PaymentMethods
         | 
| 4 | 
            +
                  class CreditCard
         | 
| 5 | 
            +
                    include ActiveModel::Model
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                    ATTRIBUTES = :card_type,
         | 
| 8 | 
            +
                                 :card_number,
         | 
| 9 | 
            +
                                 :expiration_month,
         | 
| 10 | 
            +
                                 :expiration_year,
         | 
| 11 | 
            +
                                 :security_code
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                    attr_accessor(*ATTRIBUTES)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                    def attributes
         | 
| 16 | 
            +
                      ATTRIBUTES
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    validates :card_type,
         | 
| 20 | 
            +
                              :card_number,
         | 
| 21 | 
            +
                              :expiration_month,
         | 
| 22 | 
            +
                              :expiration_year,
         | 
| 23 | 
            +
                              :security_code,
         | 
| 24 | 
            +
                              presence: true
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                    validates :card_type,
         | 
| 27 | 
            +
                              inclusion: { in: Zuora::CREDIT_CARD_TYPES }
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                    validates :expiration_month,
         | 
| 30 | 
            +
                              inclusion: { in: Zuora::MONTHS }
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                    validates :expiration_year,
         | 
| 33 | 
            +
                              length: { is: 4 }
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
            end
         | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Zuora
         | 
| 4 | 
            +
              module Models
         | 
| 5 | 
            +
                class RatePlan
         | 
| 6 | 
            +
                  include ActiveModel::Model
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  ATTRIBUTES = :product_rate_plan_id,
         | 
| 9 | 
            +
                               :charge_overrides
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  attr_accessor(*ATTRIBUTES)
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  def attributes
         | 
| 14 | 
            +
                    ATTRIBUTES
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  validates :product_rate_plan_id,
         | 
| 18 | 
            +
                            presence: true
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
| @@ -0,0 +1,57 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Zuora
         | 
| 4 | 
            +
              module Models
         | 
| 5 | 
            +
                class RatePlanCharge
         | 
| 6 | 
            +
                  include ActiveModel::Model
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  ATTRIBUTES = :product_rate_plan_charge_id,
         | 
| 9 | 
            +
                               :number,
         | 
| 10 | 
            +
                               :description,
         | 
| 11 | 
            +
                               :price,
         | 
| 12 | 
            +
                               :tiers,
         | 
| 13 | 
            +
                               :included_units,
         | 
| 14 | 
            +
                               :overage_price,
         | 
| 15 | 
            +
                               :list_price_base,
         | 
| 16 | 
            +
                               :quantity,
         | 
| 17 | 
            +
                               :discounted_amount,
         | 
| 18 | 
            +
                               :discount_percentage,
         | 
| 19 | 
            +
                               :apply_discount_to,
         | 
| 20 | 
            +
                               :discount_level,
         | 
| 21 | 
            +
                               :trigger_event,
         | 
| 22 | 
            +
                               :trigger_date,
         | 
| 23 | 
            +
                               :end_date_condition,
         | 
| 24 | 
            +
                               :up_to_periods_type,
         | 
| 25 | 
            +
                               :up_to_periods,
         | 
| 26 | 
            +
                               :specific_end_date,
         | 
| 27 | 
            +
                               :billing_period,
         | 
| 28 | 
            +
                               :specific_billing_period,
         | 
| 29 | 
            +
                               :billing_period_alignment,
         | 
| 30 | 
            +
                               :billing_timing,
         | 
| 31 | 
            +
                               :rating_group,
         | 
| 32 | 
            +
                               :bill_cycle_type,
         | 
| 33 | 
            +
                               :bill_cycle_day,
         | 
| 34 | 
            +
                               :number_of_periods,
         | 
| 35 | 
            +
                               :overage_unused_units_credit_option,
         | 
| 36 | 
            +
                               :unused_units_credit_rates,
         | 
| 37 | 
            +
                               :price_change_option,
         | 
| 38 | 
            +
                               :price_increase_percentage,
         | 
| 39 | 
            +
                               :weekly_bill_cycle_day
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  attr_accessor(*ATTRIBUTES)
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  def attributes
         | 
| 44 | 
            +
                    ATTRIBUTES
         | 
| 45 | 
            +
                  end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                  validates :product_rate_plan_charge_id,
         | 
| 48 | 
            +
                            presence: true
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                  validates :number,
         | 
| 51 | 
            +
                            length: { maximum: 50 }
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                  validates :description,
         | 
| 54 | 
            +
                            length: { maximum: 500 }
         | 
| 55 | 
            +
                end
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
            end
         | 
| @@ -0,0 +1,50 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Zuora
         | 
| 4 | 
            +
              module Models
         | 
| 5 | 
            +
                class Subscription
         | 
| 6 | 
            +
                  include ActiveModel::Model
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  ATTRIBUTES = :account_key,
         | 
| 9 | 
            +
                               :invoice_owner_account_key,
         | 
| 10 | 
            +
                               :term_type,
         | 
| 11 | 
            +
                               :contract_effective_date,
         | 
| 12 | 
            +
                               :service_activation_date,
         | 
| 13 | 
            +
                               :customer_acceptance_date,
         | 
| 14 | 
            +
                               :term_start_date,
         | 
| 15 | 
            +
                               :initial_term,
         | 
| 16 | 
            +
                               :initial_term_period_type,
         | 
| 17 | 
            +
                               :auto_renew,
         | 
| 18 | 
            +
                               :renewal_term,
         | 
| 19 | 
            +
                               :renewal_term_period_type,
         | 
| 20 | 
            +
                               :renewal_setting,
         | 
| 21 | 
            +
                               :notes,
         | 
| 22 | 
            +
                               :invoice_collect,
         | 
| 23 | 
            +
                               :invoice,
         | 
| 24 | 
            +
                               :collect,
         | 
| 25 | 
            +
                               :invoice_separately,
         | 
| 26 | 
            +
                               :apply_credit_balance,
         | 
| 27 | 
            +
                               :invoice_target_date,
         | 
| 28 | 
            +
                               :subscribe_to_rate_plans
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  attr_accessor(*ATTRIBUTES)
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  def attributes
         | 
| 33 | 
            +
                    ATTRIBUTES
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  validates :account_key,
         | 
| 37 | 
            +
                            :term_type,
         | 
| 38 | 
            +
                            :contract_effective_date,
         | 
| 39 | 
            +
                            :subscribe_to_rate_plans,
         | 
| 40 | 
            +
                            presence: true
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                  validates :term_type,
         | 
| 43 | 
            +
                            inclusion: { in: Zuora::SUBSCRIPTION_TERM_TYPES }
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  validates :initial_term,
         | 
| 46 | 
            +
                            presence: true,
         | 
| 47 | 
            +
                            if: proc { |sub| sub.term_type == 'EVERGREEN' }
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
            end
         | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            module Zuora
         | 
| 2 | 
            +
              module Models
         | 
| 3 | 
            +
                class RatePlanChargeTier
         | 
| 4 | 
            +
                  include ActiveModel::Model
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  ATTRIBUTES = :tier,
         | 
| 7 | 
            +
                               :starting_unit,
         | 
| 8 | 
            +
                               :ending_unit,
         | 
| 9 | 
            +
                               :price,
         | 
| 10 | 
            +
                               :price_format
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  attr_accessor(*ATTRIBUTES)
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def attributes
         | 
| 15 | 
            +
                    ATTRIBUTES
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  validates :tier,
         | 
| 19 | 
            +
                            :price,
         | 
| 20 | 
            +
                            presence: true
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  validates :price_format,
         | 
| 23 | 
            +
                            inclusion: { in: %w(FlatFee PerUnit) },
         | 
| 24 | 
            +
                            allow_nil: true
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            module Zuora
         | 
| 2 | 
            +
              module Models
         | 
| 3 | 
            +
                module Utils
         | 
| 4 | 
            +
                  # Calls `validate_each` on for each provided attribute.
         | 
| 5 | 
            +
                  # Attaches error generated via message fragment.
         | 
| 6 | 
            +
                  # e.g. 'invalid widget'
         | 
| 7 | 
            +
                  #
         | 
| 8 | 
            +
                  # @param [Object] sender;
         | 
| 9 | 
            +
                  # @param [String] message
         | 
| 10 | 
            +
                  # @param [Array<Symbol>] fields
         | 
| 11 | 
            +
                  # @return [Nil]
         | 
| 12 | 
            +
                  def self.validate_children(sender, message, *fields)
         | 
| 13 | 
            +
                    sender.validates_each fields do |record, attr, value|
         | 
| 14 | 
            +
                      if !value.respond_to?(:valid?) || !value.respond_to?(:errors)
         | 
| 15 | 
            +
                        record.errors.add attr, "invalid #{message}"
         | 
| 16 | 
            +
                      elsif value.invalid?
         | 
| 17 | 
            +
                        record.errors.add attr, value.errors.join(',')
         | 
| 18 | 
            +
                      end
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
| @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            module Zuora
         | 
| 2 | 
            +
              module Resources
         | 
| 3 | 
            +
                InvalidModel = Class.new(StandardError)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                def self.with_valid(model, &block)
         | 
| 6 | 
            +
                  if model.valid?
         | 
| 7 | 
            +
                    block.call model
         | 
| 8 | 
            +
                  else
         | 
| 9 | 
            +
                    fail InvalidModel, model
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            require_relative 'resources/accounts'
         | 
| 16 | 
            +
            require_relative 'resources/payment_methods'
         | 
| 17 | 
            +
            require_relative 'resources/subscriptions'
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            module Zuora
         | 
| 2 | 
            +
              module Resources
         | 
| 3 | 
            +
                module Accounts
         | 
| 4 | 
            +
                  RESOURCE_URI = '/rest/v1/accounts'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  def self.create!(client, model, serializer = Zuora::Serializers::Noop)
         | 
| 7 | 
            +
                    Zuora::Resources.with_valid model do |mod|
         | 
| 8 | 
            +
                      client.post RESOURCE_URI, serializer.serialize(mod)
         | 
| 9 | 
            +
                    end
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  def self.update!(client, model, serializer = Zuora::Serializers::Noop)
         | 
| 13 | 
            +
                    Zuora::Resources.with_valid model do |mod|
         | 
| 14 | 
            +
                      client.post RESOURCE_URI, serializer.serialize(mod)
         | 
| 15 | 
            +
                    end
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            end
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            require_relative 'payment_methods/credit_card'
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
            module Zuora
         | 
| 3 | 
            +
              module Resources
         | 
| 4 | 
            +
                module PaymentMethods
         | 
| 5 | 
            +
                  module CreditCards
         | 
| 6 | 
            +
                    RESOURCE_URI = '/rest/v1/credit_card/payment_account'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                    # Validates a model, and throws if invalid.
         | 
| 9 | 
            +
                    # Otherwise, makes an HTTP request, creating a credit card
         | 
| 10 | 
            +
                    # payment account.
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                    # https://api.zuora.com/rest/v1/payment-methods/credit-cards
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                    # @param [Zuora::Client] client
         | 
| 15 | 
            +
                    # @param [Zuora::Model::PaymentMethod] model: the credit card
         | 
| 16 | 
            +
                    # @param [Class] serializer: any object supporting .serialze(data)
         | 
| 17 | 
            +
                    # @return [Faraday::Response]
         | 
| 18 | 
            +
                    def self.create!(client, model, serializer = Zuora::Serializers::Noop)
         | 
| 19 | 
            +
                      Zuora::Resources.with_valid model do |mod|
         | 
| 20 | 
            +
                        client.post RESOURCE_URI, serializer.serialize(mod)
         | 
| 21 | 
            +
                      end
         | 
| 22 | 
            +
                    end
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
            end
         |