mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-04 00:00:47 -04:00
141 lines
4.6 KiB
Ruby
141 lines
4.6 KiB
Ruby
# File generated from our OpenAPI spec
|
|
# frozen_string_literal: true
|
|
|
|
module Stripe
|
|
class QuoteService < StripeService
|
|
attr_reader :computed_upfront_line_items, :lines, :line_items, :preview_invoices, :preview_subscription_schedules
|
|
|
|
def initialize(requestor)
|
|
super
|
|
@computed_upfront_line_items = Stripe::QuoteComputedUpfrontLineItemsService.new(@requestor)
|
|
@lines = Stripe::QuoteLineService.new(@requestor)
|
|
@line_items = Stripe::QuoteLineItemService.new(@requestor)
|
|
@preview_invoices = Stripe::QuotePreviewInvoiceService.new(@requestor)
|
|
@preview_subscription_schedules = Stripe::QuotePreviewSubscriptionScheduleService
|
|
.new(@requestor)
|
|
end
|
|
|
|
# Accepts the specified quote.
|
|
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
|
|
|
|
# Cancels the quote.
|
|
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
|
|
|
|
# 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](https://dashboard.stripe.com/settings/billing/quote).
|
|
def create(params = {}, opts = {})
|
|
request(method: :post, path: "/v1/quotes", params: params, opts: opts, base_address: :api)
|
|
end
|
|
|
|
# Finalizes the quote.
|
|
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
|
|
|
|
# Returns a list of your quotes.
|
|
def list(params = {}, opts = {})
|
|
request(method: :get, path: "/v1/quotes", params: params, opts: opts, base_address: :api)
|
|
end
|
|
|
|
# Preview the invoice line items that would be generated by accepting the quote.
|
|
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
|
|
|
|
# Converts a stale quote to draft.
|
|
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
|
|
|
|
# Converts a draft or open quote to stale.
|
|
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
|
|
|
|
# Download the PDF for a finalized quote. Explanation for special handling can be found [here](https://docs.stripe.com/quotes/overview#quote_pdf)
|
|
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
|
|
|
|
# Recompute the upcoming invoice estimate for the quote.
|
|
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
|
|
|
|
# Retrieves the quote with the given ID.
|
|
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
|
|
|
|
# A quote models prices and services for a customer.
|
|
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
|
|
end
|
|
end
|