Class: FakePin::Customer

Inherits:
Object
  • Object
show all
Defined in:
lib/fake_pin/customer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Customer

Returns a new instance of Customer.



7
8
9
# File 'lib/fake_pin/customer.rb', line 7

def initialize(params)
  @params = params
end

Class Method Details

.create(params) ⇒ Object



3
4
5
# File 'lib/fake_pin/customer.rb', line 3

def self.create(params)
  new(params).create
end

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fake_pin/customer.rb', line 11

def create
  card = @params['card']
  @params.require(:email, :card => Card::REQUIRED_PARAMS) if card.present?

  response =  { "token"      => Token.generate('cus'),
                "email"      => @params['email'],
                "created_at" => Time.now.to_s }

  response['card'] = Card.create(card) if card.present?

  response
end