Module: StripeMock::RequestHandlers::Payouts
- Included in:
- Instance
- Defined in:
- lib/stripe_mock/request_handlers/payouts.rb
Class Method Summary collapse
Instance Method Summary collapse
- #get_payout(route, method_url, params, headers) ⇒ Object
- #list_payouts(route, method_url, params, headers) ⇒ Object
- #new_payout(route, method_url, params, headers) ⇒ Object
Class Method Details
.included(klass) ⇒ Object
5 6 7 8 9 |
# File 'lib/stripe_mock/request_handlers/payouts.rb', line 5 def Payouts.included(klass) klass.add_handler 'post /v1/payouts', :new_payout klass.add_handler 'get /v1/payouts', :list_payouts klass.add_handler 'get /v1/payouts/(.*)', :get_payout end |
Instance Method Details
#get_payout(route, method_url, params, headers) ⇒ Object
25 26 27 28 29 |
# File 'lib/stripe_mock/request_handlers/payouts.rb', line 25 def get_payout(route, method_url, params, headers) route =~ method_url assert_existence :payout, $1, payouts[$1] payouts[$1] ||= Data.mock_payout(:id => $1) end |
#list_payouts(route, method_url, params, headers) ⇒ Object
21 22 23 |
# File 'lib/stripe_mock/request_handlers/payouts.rb', line 21 def list_payouts(route, method_url, params, headers) Data.mock_list_object(payouts.clone.values, params) end |
#new_payout(route, method_url, params, headers) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/stripe_mock/request_handlers/payouts.rb', line 11 def new_payout(route, method_url, params, headers) id = new_id('po') unless params[:amount].is_a?(Integer) || (params[:amount].is_a?(String) && /^\d+$/.match(params[:amount])) raise Stripe::InvalidRequestError.new("Invalid integer: #{params[:amount]}", 'amount', http_status: 400) end payouts[id] = Data.mock_payout(params.merge :id => id) end |