Sha256: edde0b239f11232552001e2c8014e8ab3a60cfa90b94e57d36320e0479a75846

Contents?: true

Size: 1.03 KB

Versions: 14

Compression:

Stored size: 1.03 KB

Contents

module ChargeBee
  class Result

    def initialize(response)
      @response = response
    end
    
    def subscription()
      get(:subscription, Subscription, {:addons => Subscription::Addon})
    end

    def customer()
      get(:customer, Customer)
    end

    def card()
      get(:card, Card)
    end
    
    def address()
      get(:address, Address)
    end
    
    def invoice()
      get(:invoice, Invoice, {:line_items => Invoice::LineItem, :discounts => Invoice::Discount})
    end

    def transaction()
      get(:transaction, Transaction)
    end

    def event()
      get(:event, Event)
    end

    def hosted_page()
      get(:hosted_page, HostedPage)
    end
    
    def plan()
      get(:plan, Plan)
    end
    
    def addon()
      get(:addon, Addon)
    end
    
    def coupon()
      get(:coupon, Coupon)
    end
    
    def to_s(*args) 
      JSON.pretty_generate(@response) 
    end
    
    private
    def get(type, klass, sub_types = {})
      klass.construct(@response[type], sub_types)
    end
    
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
chargebee-1.1.7 lib/chargebee/result.rb
chargebee-1.1.6 lib/chargebee/result.rb
chargebee-1.1.5 lib/chargebee/result.rb
chargebee-1.1.4 lib/chargebee/result.rb
chargebee-1.1.3 lib/chargebee/result.rb
chargebee-1.1.2 lib/chargebee/result.rb
chargebee-1.1.1 lib/chargebee/result.rb
chargebee-1.1.0 lib/chargebee/result.rb
chargebee-1.0.9 lib/chargebee/result.rb
chargebee-1.0.8 lib/chargebee/result.rb
chargebee-1.0.7 lib/chargebee/result.rb
chargebee-1.0.6 lib/chargebee/result.rb
chargebee-1.0.5 lib/chargebee/result.rb
chargebee-1.0.4 lib/chargebee/result.rb