Class: Stripe::QuoteService

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

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
  @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

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.



19
20
21
22
23
24
25
26
27
# File 'lib/stripe/services/quote_service.rb', line 19

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.



30
31
32
33
34
35
36
37
38
# File 'lib/stripe/services/quote_service.rb', line 30

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).



41
42
43
44
45
# File 'lib/stripe/services/quote_service.rb', line 41

def create(params = {}, opts = {})
  params = ::Stripe::QuoteCreateParams.coerce_params(params) unless params.is_a?(Stripe::RequestParams)

  request(method: :post, path: "/v1/quotes", params: params, opts: opts, base_address: :api)
end

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

Finalizes the quote.



48
49
50
51
52
53
54
55
56
# File 'lib/stripe/services/quote_service.rb', line 48

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.



59
60
61
# File 'lib/stripe/services/quote_service.rb', line 59

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.



64
65
66
67
68
69
70
71
72
# File 'lib/stripe/services/quote_service.rb', line 64

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.



75
76
77
78
79
80
81
82
83
# File 'lib/stripe/services/quote_service.rb', line 75

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.



86
87
88
89
90
91
92
93
94
# File 'lib/stripe/services/quote_service.rb', line 86

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)



97
98
99
100
101
102
103
104
105
106
107
# File 'lib/stripe/services/quote_service.rb', line 97

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.



110
111
112
113
114
115
116
117
118
# File 'lib/stripe/services/quote_service.rb', line 110

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.



121
122
123
124
125
126
127
128
129
# File 'lib/stripe/services/quote_service.rb', line 121

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.



132
133
134
135
136
137
138
139
140
141
142
# File 'lib/stripe/services/quote_service.rb', line 132

def update(quote, params = {}, opts = {})
  params = ::Stripe::QuoteUpdateParams.coerce_params(params) unless params.is_a?(Stripe::RequestParams)

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