Module: StripeMock::RequestHandlers::InvoiceItems
- Included in:
- Instance
- Defined in:
- lib/stripe_mock/request_handlers/invoice_items.rb
Class Method Summary collapse
Instance Method Summary collapse
- #delete_invoice_item(route, method_url, params, headers) ⇒ Object
- #get_invoice_item(route, method_url, params, headers) ⇒ Object
- #list_invoice_items(route, method_url, params, headers) ⇒ Object
- #new_invoice_item(route, method_url, params, headers) ⇒ Object
- #update_invoice_item(route, method_url, params, headers) ⇒ Object
Class Method Details
.included(klass) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/stripe_mock/request_handlers/invoice_items.rb', line 5 def InvoiceItems.included(klass) klass.add_handler 'post /v1/invoiceitems', :new_invoice_item klass.add_handler 'post /v1/invoiceitems/(.*)', :update_invoice_item klass.add_handler 'get /v1/invoiceitems/(.*)', :get_invoice_item klass.add_handler 'get /v1/invoiceitems', :list_invoice_items klass.add_handler 'delete /v1/invoiceitems/(.*)', :delete_invoice_item end |
Instance Method Details
#delete_invoice_item(route, method_url, params, headers) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/stripe_mock/request_handlers/invoice_items.rb', line 24 def delete_invoice_item(route, method_url, params, headers) route =~ method_url assert_existence :list_item, $1, invoice_items[$1] invoice_items[$1] = { id: invoice_items[$1][:id], deleted: true } end |
#get_invoice_item(route, method_url, params, headers) ⇒ Object
38 39 40 41 |
# File 'lib/stripe_mock/request_handlers/invoice_items.rb', line 38 def get_invoice_item(route, method_url, params, headers) route =~ method_url assert_existence :invoice_item, $1, invoice_items[$1] end |
#list_invoice_items(route, method_url, params, headers) ⇒ Object
34 35 36 |
# File 'lib/stripe_mock/request_handlers/invoice_items.rb', line 34 def list_invoice_items(route, method_url, params, headers) Data.mock_list_object(invoice_items.values, params) end |
#new_invoice_item(route, method_url, params, headers) ⇒ Object
13 14 15 16 |
# File 'lib/stripe_mock/request_handlers/invoice_items.rb', line 13 def new_invoice_item(route, method_url, params, headers) params[:id] ||= new_id('ii') invoice_items[params[:id]] = Data.mock_invoice_item(params) end |
#update_invoice_item(route, method_url, params, headers) ⇒ Object
18 19 20 21 22 |
# File 'lib/stripe_mock/request_handlers/invoice_items.rb', line 18 def update_invoice_item(route, method_url, params, headers) route =~ method_url list_item = assert_existence :list_item, $1, invoice_items[$1] list_item.merge!(params) end |