Class: Spree::Conekta::CreditCard

Inherits:
Object
  • Object
show all
Includes:
Client
Defined in:
lib/spree/conekta/credit_card.rb

Constant Summary

Constants included from Client

Spree::Conekta::Client::CONEKTA_API

Instance Attribute Summary collapse

Attributes included from Client

#auth_token

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Client

#connection, #get, #headers, #post

Constructor Details

#initialize(customer, options) ⇒ CreditCard

Returns a new instance of CreditCard.



17
18
19
20
21
22
# File 'lib/spree/conekta/credit_card.rb', line 17

def initialize(customer, options)
  @customer   = customer
  @auth_token = options[:auth_token]
  build_card(options[:card])   if options[:card]
  create_card(options[:token]) if options[:token]
end

Instance Attribute Details

#brandObject

Returns the value of attribute brand.



7
8
9
# File 'lib/spree/conekta/credit_card.rb', line 7

def brand
  @brand
end

#customerObject (readonly)

Returns the value of attribute customer.



6
7
8
# File 'lib/spree/conekta/credit_card.rb', line 6

def customer
  @customer
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/spree/conekta/credit_card.rb', line 7

def id
  @id
end

#last4Object

Returns the value of attribute last4.



7
8
9
# File 'lib/spree/conekta/credit_card.rb', line 7

def last4
  @last4
end

Class Method Details

.build(customer, card, auth_token) ⇒ Object



13
14
15
# File 'lib/spree/conekta/credit_card.rb', line 13

def self.build(customer, card, auth_token)
  new(customer, card: card, auth_token: auth_token)
end

.create(customer, token, auth_token) ⇒ Object



9
10
11
# File 'lib/spree/conekta/credit_card.rb', line 9

def self.create(customer, token, auth_token)
  new(customer, token: token, auth_token: auth_token)
end

Instance Method Details

#endpointObject



24
25
26
# File 'lib/spree/conekta/credit_card.rb', line 24

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