Sha256: 3d48745376b602187b3d1c5f64adfb8d682f4c6d287436fa6e93812e37f44571

Contents?: true

Size: 910 Bytes

Versions: 1

Compression:

Stored size: 910 Bytes

Contents

module Conekta
  class Customer < APIResource
    include Conekta::APIOperations::Create
    include Conekta::APIOperations::Delete
    include Conekta::APIOperations::Update
    include Conekta::APIOperations::List
    include Conekta::APIOperations::CreateMember

    def refresh_from(values, api_key, partial=false)
      super
      customer = self
      for i in 0..(customer.cards.count - 1)
        customer.cards[i].customer = customer
      end
      if customer.subscription
        customer.subscription.customer = customer
      end
    end

    def create_subscription(params={})
      subscription = create_member('subscription', params)
      subscription.customer = self
      self.subscription = subscription
      subscription
    end

    def create_card(params={})
      card = create_member('cards', params)
      card.customer = self
      self.cards << card
      card
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
conekta-0.3.3 lib/conekta/customer.rb