Sha256: 0ee04a55749a646296721a705ceb4681a174963f34fe7e4d04b994c404b64829

Contents?: true

Size: 1.09 KB

Versions: 5

Compression:

Stored size: 1.09 KB

Contents

module Chargify
  class Customer < Base
    include ResponseHelper

    def self.find_by_reference(reference)
      find(:one, :from => :lookup, :params => {:reference => reference})
    end

    class Subscription < Base
      self.prefix = "/customers/:customer_id/"
    end

    def subscriptions(params = {})
      params.merge!({:customer_id => self.id})
      Subscription.find(:all, :params => params)
    end

    def management_link(params = {})
      params.merge!(:from => "/portal/customers/#{self.id}/management_link")
      ManagementLink.find(:one, params)
    end

    def payment_profiles(params = {})
      params.merge!({:customer_id => self.id})
      PaymentProfile.find(:all, :params => params)
    end

    def build_metadata(params = {})
      CustomerMetadata.new(params.reverse_merge({:resource_id => self.id}))
    end

    def create_metadata(params = {})
      CustomerMetadata.create(params.reverse_merge({:resource_id => self.id}))
    end

    def metadata(params={})
      params.merge!({:resource_id => self.id})
      CustomerMetadata.find(:all, :params => params)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
chargify_api_ares-1.4.15 lib/chargify_api_ares/resources/customer.rb
chargify_api_ares-1.4.14 lib/chargify_api_ares/resources/customer.rb
chargify_api_ares-1.4.13 lib/chargify_api_ares/resources/customer.rb
chargify_api_ares-1.4.11 lib/chargify_api_ares/resources/customer.rb
chargify_api_ares-1.4.10 lib/chargify_api_ares/resources/customer.rb