Module: StripeMock::RequestHandlers::Accounts
- Included in:
- Instance
- Defined in:
- lib/stripe_mock/request_handlers/accounts.rb
Constant Summary collapse
- VALID_START_YEAR =
2009
Class Method Summary collapse
Instance Method Summary collapse
- #deauthorize(route, method_url, params, headers) ⇒ Object
- #delete_account(route, method_url, params, headers) ⇒ Object
- #get_account(route, method_url, params, headers) ⇒ Object
- #list_accounts(route, method_url, params, headers) ⇒ Object
- #new_account(route, method_url, params, headers) ⇒ Object
- #update_account(route, method_url, params, headers) ⇒ Object
Class Method Details
.included(klass) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/stripe_mock/request_handlers/accounts.rb', line 6 def Accounts.included(klass) klass.add_handler 'post /v1/accounts', :new_account klass.add_handler 'get /v1/account', :get_account klass.add_handler 'get /v1/accounts/(.*)', :get_account klass.add_handler 'post /v1/accounts/(.*)', :update_account klass.add_handler 'get /v1/accounts', :list_accounts klass.add_handler 'post /oauth/deauthorize', :deauthorize klass.add_handler 'delete /v1/accounts/(.*)', :delete_account end |
Instance Method Details
#deauthorize(route, method_url, params, headers) ⇒ Object
46 47 48 49 50 |
# File 'lib/stripe_mock/request_handlers/accounts.rb', line 46 def (route, method_url, params, headers) init_account route =~ method_url Stripe::StripeObject.construct_from(:stripe_user_id => params[:stripe_user_id]) end |
#delete_account(route, method_url, params, headers) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/stripe_mock/request_handlers/accounts.rb', line 52 def delete_account(route, method_url, params, headers) init_account route =~ method_url assert_existence :account, $1, accounts[$1] accounts[$1] = { id: accounts[$1][:id], deleted: true } end |
#get_account(route, method_url, params, headers) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/stripe_mock/request_handlers/accounts.rb', line 22 def get_account(route, method_url, params, headers) route =~ method_url init_account id = $1 || accounts.keys[0] assert_existence :account, id, accounts[id] end |
#list_accounts(route, method_url, params, headers) ⇒ Object
41 42 43 44 |
# File 'lib/stripe_mock/request_handlers/accounts.rb', line 41 def list_accounts(route, method_url, params, headers) init_account Data.mock_list_object(accounts.values, params) end |
#new_account(route, method_url, params, headers) ⇒ Object
16 17 18 19 20 |
# File 'lib/stripe_mock/request_handlers/accounts.rb', line 16 def new_account(route, method_url, params, headers) params[:id] ||= new_id('acct') route =~ method_url accounts[params[:id]] ||= Data.mock_account(params) end |
#update_account(route, method_url, params, headers) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/stripe_mock/request_handlers/accounts.rb', line 29 def update_account(route, method_url, params, headers) route =~ method_url account = assert_existence :account, $1, accounts[$1] account.merge!(params) if blank_value?(params[:tos_acceptance], :date) raise Stripe::InvalidRequestError.new("Invalid integer: ", "tos_acceptance[date]", http_status: 400) elsif params[:tos_acceptance] && params[:tos_acceptance][:date] validate_acceptance_date(params[:tos_acceptance][:date]) end account end |