Class: Spree::Conekta::CreditCardCollection

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable, Client
Defined in:
lib/spree/conekta/credit_card_collection.rb

Constant Summary

Constants included from Client

Spree::Conekta::Client::CONEKTA_API

Instance Attribute Summary collapse

Attributes included from Client

#auth_token

Instance Method Summary collapse

Methods included from Client

#connection, #get, #headers, #post

Constructor Details

#initialize(customer, options) ⇒ CreditCardCollection

Returns a new instance of CreditCardCollection.



13
14
15
16
17
# File 'lib/spree/conekta/credit_card_collection.rb', line 13

def initialize(customer, options)
  @customer   = customer
  @auth_token = options[:auth_token]
  @cards      = build_cards(get)
end

Instance Attribute Details

#customerObject (readonly)

Returns the value of attribute customer.



11
12
13
# File 'lib/spree/conekta/credit_card_collection.rb', line 11

def customer
  @customer
end

Instance Method Details

#add(token) ⇒ Object



19
20
21
# File 'lib/spree/conekta/credit_card_collection.rb', line 19

def add(token)
  @cards << Spree::Conekta::CreditCard.create(customer, token, auth_token)
end

#endpointObject



23
24
25
# File 'lib/spree/conekta/credit_card_collection.rb', line 23

def endpoint
  "customers/#{customer.id}/cards"
end