Module: StripeMock::RequestHandlers::ExternalAccounts

Included in:
Instance
Defined in:
lib/stripe_mock/request_handlers/external_accounts.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/stripe_mock/request_handlers/external_accounts.rb', line 5

def ExternalAccounts.included(klass)
  klass.add_handler 'get /v1/accounts/(.*)/external_accounts', :retrieve_external_accounts
  klass.add_handler 'post /v1/accounts/(.*)/external_accounts', :create_external_account
  klass.add_handler 'post /v1/accounts/(.*)/external_accounts/(.*)/verify', :verify_external_account
  klass.add_handler 'get /v1/accounts/(.*)/external_accounts/(.*)', :retrieve_external_account
  klass.add_handler 'delete /v1/accounts/(.*)/external_accounts/(.*)', :delete_external_account
  klass.add_handler 'post /v1/accounts/(.*)/external_accounts/(.*)', :update_external_account
end

Instance Method Details

#create_external_account(route, method_url, params, headers) ⇒ Object



14
15
16
17
# File 'lib/stripe_mock/request_handlers/external_accounts.rb', line 14

def (route, method_url, params, headers)
  route =~ method_url
  (:account, $1, params, accounts)
end

#delete_external_account(route, method_url, params, headers) ⇒ Object



31
32
33
34
# File 'lib/stripe_mock/request_handlers/external_accounts.rb', line 31

def (route, method_url, params, headers)
  route =~ method_url
  delete_card_from(:account, $1, $2, accounts)
end

#retrieve_external_account(route, method_url, params, headers) ⇒ Object



24
25
26
27
28
29
# File 'lib/stripe_mock/request_handlers/external_accounts.rb', line 24

def (route, method_url, params, headers)
  route =~ method_url
   = assert_existence :account, $1, accounts[$1]

  assert_existence :card, $2, get_card(, $2)
end

#retrieve_external_accounts(route, method_url, params, headers) ⇒ Object



19
20
21
22
# File 'lib/stripe_mock/request_handlers/external_accounts.rb', line 19

def retrieve_external_accounts(route, method_url, params, headers)
  route =~ method_url
  retrieve_object_cards(:account, $1, accounts)
end

#update_external_account(route, method_url, params, headers) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/stripe_mock/request_handlers/external_accounts.rb', line 36

def (route, method_url, params, headers)
  route =~ method_url
   = assert_existence :account, $1, accounts[$1]

  card = assert_existence :card, $2, get_card(, $2)
  card.merge!(params)
  card
end

#verify_external_account(route, method_url, params, headers) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/stripe_mock/request_handlers/external_accounts.rb', line 45

def (route, method_url, params, headers)
  route =~ method_url
   = assert_existence :account, $1, accounts[$1]

   = assert_existence :bank_account, $2, (, $2)
  
end