Module: StripeMock::RequestHandlers::TaxIds
- Included in:
- Instance
- Defined in:
- lib/stripe_mock/request_handlers/tax_ids.rb
Class Method Summary collapse
Instance Method Summary collapse
- #delete_customer_tax_id(route, method_url, params, headers) ⇒ Object
- #delete_tax_id(route, method_url, params, headers) ⇒ Object
- #get_customer_tax_id(route, method_url, params, headers) ⇒ Object
- #get_tax_id(route, method_url, params, headers) ⇒ Object
- #list_customer_tax_ids(route, method_url, params, headers) ⇒ Object
- #list_tax_ids(route, method_url, params, headers) ⇒ Object
- #new_customer_tax_id(route, method_url, params, headers) ⇒ Object
- #new_tax_id(route, method_url, params, headers) ⇒ Object
Class Method Details
.included(klass) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/stripe_mock/request_handlers/tax_ids.rb', line 4 def TaxIds.included(klass) klass.add_handler 'post /v1/tax_ids', :new_tax_id klass.add_handler 'post /v1/customers/(.*)/tax_ids', :new_customer_tax_id klass.add_handler 'get /v1/tax_ids/([^/]*)', :get_tax_id klass.add_handler 'get /v1/customers/(.*)/tax_ids/([^/]*)', :get_customer_tax_id klass.add_handler 'get /v1/tax_ids', :list_tax_ids klass.add_handler 'get /v1/customers/(.*)/tax_ids', :list_customer_tax_ids klass.add_handler 'delete /v1/tax_ids/([^/]*)', :delete_tax_id klass.add_handler 'delete /v1/customers/(.*)/tax_ids/([^/]*)', :delete_customer_tax_id end |
Instance Method Details
#delete_customer_tax_id(route, method_url, params, headers) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/stripe_mock/request_handlers/tax_ids.rb', line 53 def delete_customer_tax_id(route, method_url, params, headers) route =~ method_url tax_id = tax_ids[$2] tax_id = nil if tax_id[:customer] != $1 tax_id = assert_existence :tax_id, $2, tax_id tax_ids[$2] = { id: tax_ids[$2][:id], deleted: true } end |
#delete_tax_id(route, method_url, params, headers) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/stripe_mock/request_handlers/tax_ids.rb', line 44 def delete_tax_id(route, method_url, params, headers) route =~ method_url assert_existence :tax_id, $1, tax_ids[$1] tax_ids[$1] = { id: tax_ids[$1][:id], deleted: true } end |
#get_customer_tax_id(route, method_url, params, headers) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/stripe_mock/request_handlers/tax_ids.rb', line 29 def get_customer_tax_id(route, method_url, params, headers) route =~ method_url tax_id = tax_ids[$2] tax_id = nil if tax_id[:customer] != $1 tax_id = assert_existence :tax_id, $2, tax_id tax_id.clone end |
#get_tax_id(route, method_url, params, headers) ⇒ Object
24 25 26 27 28 |
# File 'lib/stripe_mock/request_handlers/tax_ids.rb', line 24 def get_tax_id(route, method_url, params, headers) route =~ method_url tax_id = assert_existence :tax_id, $1, tax_ids[$1] tax_id.clone end |
#list_customer_tax_ids(route, method_url, params, headers) ⇒ Object
40 41 42 |
# File 'lib/stripe_mock/request_handlers/tax_ids.rb', line 40 def list_customer_tax_ids(route, method_url, params, headers) Data.mock_list_object(tax_ids.values.select { |t| t[:customer] == $1 }, params) end |
#list_tax_ids(route, method_url, params, headers) ⇒ Object
37 38 39 |
# File 'lib/stripe_mock/request_handlers/tax_ids.rb', line 37 def list_tax_ids(route, method_url, params, headers) Data.mock_list_object(tax_ids.values, params) end |
#new_customer_tax_id(route, method_url, params, headers) ⇒ Object
20 21 22 |
# File 'lib/stripe_mock/request_handlers/tax_ids.rb', line 20 def new_customer_tax_id(route, method_url, params, headers) new_tax_id(route, method_url, params.merge(customer: $1)) end |
#new_tax_id(route, method_url, params, headers) ⇒ Object
15 16 17 18 19 |
# File 'lib/stripe_mock/request_handlers/tax_ids.rb', line 15 def new_tax_id(route, method_url, params, headers) params[:id] ||= new_id('txi') tax_ids[ params[:id] ] = Data.mock_tax_id(params) tax_ids[ params[:id] ] end |