Class: Stripe::QuoteService

Inherits:
StripeService show all
Defined in:
lib/stripe/services/quote_service.rb

Defined Under Namespace

Classes: AcceptParams, CancelParams, CreateParams, FinalizeQuoteParams, ListParams, ListPreviewInvoiceLinesParams, MarkDraftParams, MarkStaleParams, PdfParams, ReestimateParams, RetrieveParams, UpdateParams

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from StripeService

#request, #request_stream

Constructor Details

#initialize(requestor) ⇒ QuoteService

Returns a new instance of QuoteService.



8
9
10
11
12
13
14
15
16
# File 'lib/stripe/services/quote_service.rb', line 8

def initialize(requestor)
  super
  @preview_invoices = Stripe::QuotePreviewInvoiceService.new(@requestor)
  @preview_subscription_schedules = Stripe::QuotePreviewSubscriptionScheduleService
                                    .new(@requestor)
  @lines = Stripe::QuoteLineService.new(@requestor)
  @line_items = Stripe::QuoteLineItemService.new(@requestor)
  @computed_upfront_line_items = Stripe::QuoteComputedUpfrontLineItemsService.new(@requestor)
end

Instance Attribute Details

#computed_upfront_line_itemsObject (readonly)

Returns the value of attribute computed_upfront_line_items.



6
7
8
# File 'lib/stripe/services/quote_service.rb', line 6

def computed_upfront_line_items
  @computed_upfront_line_items
end

#line_itemsObject (readonly)

Returns the value of attribute line_items.



6
7
8
# File 'lib/stripe/services/quote_service.rb', line 6

def line_items
  @line_items
end

#linesObject (readonly)

Returns the value of attribute lines.



6
7
8
# File 'lib/stripe/services/quote_service.rb', line 6

def lines
  @lines
end

#preview_invoicesObject (readonly)

Returns the value of attribute preview_invoices.



6
7
8
# File 'lib/stripe/services/quote_service.rb', line 6

def preview_invoices
  @preview_invoices
end

#preview_subscription_schedulesObject (readonly)

Returns the value of attribute preview_subscription_schedules.



6
7
8
# File 'lib/stripe/services/quote_service.rb', line 6

def preview_subscription_schedules
  @preview_subscription_schedules
end

Instance Method Details

#accept(quote, params = {}, opts = {}) ⇒ Object

Accepts the specified quote.



2305
2306
2307
2308
2309
2310
2311
2312
2313
# File 'lib/stripe/services/quote_service.rb', line 2305

def accept(quote, params = {}, opts = {})
  request(
    method: :post,
    path: format("/v1/quotes/%<quote>s/accept", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#cancel(quote, params = {}, opts = {}) ⇒ Object

Cancels the quote.



2316
2317
2318
2319
2320
2321
2322
2323
2324
# File 'lib/stripe/services/quote_service.rb', line 2316

def cancel(quote, params = {}, opts = {})
  request(
    method: :post,
    path: format("/v1/quotes/%<quote>s/cancel", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#create(params = {}, opts = {}) ⇒ Object

A quote models prices and services for a customer. Default options for header, description, footer, and expires_at can be set in the dashboard via the [quote template](dashboard.stripe.com/settings/billing/quote).



2327
2328
2329
# File 'lib/stripe/services/quote_service.rb', line 2327

def create(params = {}, opts = {})
  request(method: :post, path: "/v1/quotes", params: params, opts: opts, base_address: :api)
end

#finalize_quote(quote, params = {}, opts = {}) ⇒ Object

Finalizes the quote.



2332
2333
2334
2335
2336
2337
2338
2339
2340
# File 'lib/stripe/services/quote_service.rb', line 2332

def finalize_quote(quote, params = {}, opts = {})
  request(
    method: :post,
    path: format("/v1/quotes/%<quote>s/finalize", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#list(params = {}, opts = {}) ⇒ Object

Returns a list of your quotes.



2343
2344
2345
# File 'lib/stripe/services/quote_service.rb', line 2343

def list(params = {}, opts = {})
  request(method: :get, path: "/v1/quotes", params: params, opts: opts, base_address: :api)
end

#list_preview_invoice_lines(quote, preview_invoice, params = {}, opts = {}) ⇒ Object

Preview the invoice line items that would be generated by accepting the quote.



2348
2349
2350
2351
2352
2353
2354
2355
2356
# File 'lib/stripe/services/quote_service.rb', line 2348

def list_preview_invoice_lines(quote, preview_invoice, params = {}, opts = {})
  request(
    method: :get,
    path: format("/v1/quotes/%<quote>s/preview_invoices/%<preview_invoice>s/lines", { quote: CGI.escape(quote), preview_invoice: CGI.escape(preview_invoice) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#mark_draft(quote, params = {}, opts = {}) ⇒ Object

Converts a stale quote to draft.



2359
2360
2361
2362
2363
2364
2365
2366
2367
# File 'lib/stripe/services/quote_service.rb', line 2359

def mark_draft(quote, params = {}, opts = {})
  request(
    method: :post,
    path: format("/v1/quotes/%<quote>s/mark_draft", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#mark_stale(quote, params = {}, opts = {}) ⇒ Object

Converts a draft or open quote to stale.



2370
2371
2372
2373
2374
2375
2376
2377
2378
# File 'lib/stripe/services/quote_service.rb', line 2370

def mark_stale(quote, params = {}, opts = {})
  request(
    method: :post,
    path: format("/v1/quotes/%<quote>s/mark_stale", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#pdf(quote, params = {}, opts = {}, &read_body_chunk_block) ⇒ Object

Download the PDF for a finalized quote. Explanation for special handling can be found [here](docs.stripe.com/quotes/overview#quote_pdf)



2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
# File 'lib/stripe/services/quote_service.rb', line 2381

def pdf(quote, params = {}, opts = {}, &read_body_chunk_block)
  opts = { api_base: APIRequestor.active_requestor.config.uploads_base }.merge(opts)
  request_stream(
    method: :get,
    path: format("/v1/quotes/%<quote>s/pdf", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts,
    base_address: :files,
    &read_body_chunk_block
  )
end

#reestimate(quote, params = {}, opts = {}) ⇒ Object

Recompute the upcoming invoice estimate for the quote.



2394
2395
2396
2397
2398
2399
2400
2401
2402
# File 'lib/stripe/services/quote_service.rb', line 2394

def reestimate(quote, params = {}, opts = {})
  request(
    method: :post,
    path: format("/v1/quotes/%<quote>s/reestimate", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#retrieve(quote, params = {}, opts = {}) ⇒ Object

Retrieves the quote with the given ID.



2405
2406
2407
2408
2409
2410
2411
2412
2413
# File 'lib/stripe/services/quote_service.rb', line 2405

def retrieve(quote, params = {}, opts = {})
  request(
    method: :get,
    path: format("/v1/quotes/%<quote>s", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#update(quote, params = {}, opts = {}) ⇒ Object

A quote models prices and services for a customer.



2416
2417
2418
2419
2420
2421
2422
2423
2424
# File 'lib/stripe/services/quote_service.rb', line 2416

def update(quote, params = {}, opts = {})
  request(
    method: :post,
    path: format("/v1/quotes/%<quote>s", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end