Module: StripeMock::RequestHandlers::TaxRates
- Included in:
- Instance
- Defined in:
- lib/stripe_mock/request_handlers/tax_rates.rb
Class Method Summary collapse
Instance Method Summary collapse
- #get_tax_rate(route, method_url, params, headers) ⇒ Object
- #list_tax_rates(route, method_url, params, headers) ⇒ Object
- #new_tax_rate(route, method_url, params, headers) ⇒ Object
- #update_tax_rate(route, method_url, params, headers) ⇒ Object
Class Method Details
.included(klass) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/stripe_mock/request_handlers/tax_rates.rb', line 4 def TaxRates.included(klass) klass.add_handler 'post /v1/tax_rates', :new_tax_rate klass.add_handler 'post /v1/tax_rates/([^/]*)', :update_tax_rate klass.add_handler 'get /v1/tax_rates/([^/]*)', :get_tax_rate klass.add_handler 'get /v1/tax_rates', :list_tax_rates end |
Instance Method Details
#get_tax_rate(route, method_url, params, headers) ⇒ Object
28 29 30 31 32 |
# File 'lib/stripe_mock/request_handlers/tax_rates.rb', line 28 def get_tax_rate(route, method_url, params, headers) route =~ method_url tax_rate = assert_existence :tax_rate, $1, tax_rates[$1] tax_rate.clone end |
#list_tax_rates(route, method_url, params, headers) ⇒ Object
24 25 26 |
# File 'lib/stripe_mock/request_handlers/tax_rates.rb', line 24 def list_tax_rates(route, method_url, params, headers) Data.mock_list_object(tax_rates.values, params) end |
#new_tax_rate(route, method_url, params, headers) ⇒ Object
18 19 20 21 22 |
# File 'lib/stripe_mock/request_handlers/tax_rates.rb', line 18 def new_tax_rate(route, method_url, params, headers) params[:id] ||= new_id('txr') tax_rates[ params[:id] ] = Data.mock_tax_rate(params) tax_rates[ params[:id] ] end |
#update_tax_rate(route, method_url, params, headers) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/stripe_mock/request_handlers/tax_rates.rb', line 11 def update_tax_rate(route, method_url, params, headers) route =~ method_url rate = assert_existence :tax_rate, $1, tax_rates[$1] rate.merge!(params) rate end |