Class: Stripe::Quote

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List
Includes:
APIOperations::Save
Defined in:
lib/stripe/resources/quote.rb

Overview

A Quote is a way to model prices that you’d like to provide to a customer. Once accepted, it will automatically create an invoice, subscription or subscription schedule.

Constant Summary collapse

OBJECT_NAME =
"quote"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary

Attributes inherited from APIResource

#save_with_parent

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

Methods included from APIOperations::Save

included, #save

Methods inherited from APIResource

class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource

Methods included from APIOperations::Request

included

Methods inherited from StripeObject

#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values

Constructor Details

This class inherits a constructor from Stripe::StripeObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject

Class Method Details

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

Accepts the specified quote.



78
79
80
81
82
83
84
85
# File 'lib/stripe/resources/quote.rb', line 78

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

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

Cancels the quote.



88
89
90
91
92
93
94
95
# File 'lib/stripe/resources/quote.rb', line 88

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

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

Finalizes the quote.



98
99
100
101
102
103
104
105
# File 'lib/stripe/resources/quote.rb', line 98

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

.list_computed_upfront_line_items(quote, params = {}, opts = {}) ⇒ Object

When retrieving a quote, there is an includable [computed.upfront.line_items](stripe.com/docs/api/quotes/object#quote_object-computed-upfront-line_items) property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of upfront line items.



108
109
110
111
112
113
114
115
# File 'lib/stripe/resources/quote.rb', line 108

def self.list_computed_upfront_line_items(quote, params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/quotes/%<quote>s/computed_upfront_line_items", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts
  )
end

.list_line_items(quote, params = {}, opts = {}) ⇒ Object

When retrieving a quote, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.



118
119
120
121
122
123
124
125
# File 'lib/stripe/resources/quote.rb', line 118

def self.list_line_items(quote, params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/quotes/%<quote>s/line_items", { quote: CGI.escape(quote) }),
    params: params,
    opts: opts
  )
end

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

Download the PDF for a finalized quote



128
129
130
131
132
133
134
135
136
137
138
# File 'lib/stripe/resources/quote.rb', line 128

def self.pdf(quote, params = {}, opts = {}, &read_body_chunk_block)
  config = opts[:client]&.config || Stripe.config
  opts = { api_base: config.uploads_base }.merge(opts)
  execute_resource_request_stream(
    :get,
    format("/v1/quotes/%<quote>s/pdf", { quote: CGI.escape(quote) }),
    params,
    opts,
    &read_body_chunk_block
  )
end

Instance Method Details

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

Accepts the specified quote.



15
16
17
18
19
20
21
22
# File 'lib/stripe/resources/quote.rb', line 15

def accept(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/quotes/%<quote>s/accept", { quote: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

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

Cancels the quote.



25
26
27
28
29
30
31
32
# File 'lib/stripe/resources/quote.rb', line 25

def cancel(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/quotes/%<quote>s/cancel", { quote: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

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

Finalizes the quote.



35
36
37
38
39
40
41
42
# File 'lib/stripe/resources/quote.rb', line 35

def finalize_quote(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/quotes/%<quote>s/finalize", { quote: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

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

When retrieving a quote, there is an includable [computed.upfront.line_items](stripe.com/docs/api/quotes/object#quote_object-computed-upfront-line_items) property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of upfront line items.



45
46
47
48
49
50
51
52
# File 'lib/stripe/resources/quote.rb', line 45

def list_computed_upfront_line_items(params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/quotes/%<quote>s/computed_upfront_line_items", { quote: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

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

When retrieving a quote, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.



55
56
57
58
59
60
61
62
# File 'lib/stripe/resources/quote.rb', line 55

def list_line_items(params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/quotes/%<quote>s/line_items", { quote: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

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

Download the PDF for a finalized quote



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/stripe/resources/quote.rb', line 65

def pdf(params = {}, opts = {}, &read_body_chunk_block)
  config = opts[:client]&.config || Stripe.config
  opts = { api_base: config.uploads_base }.merge(opts)
  request_stream(
    method: :get,
    path: format("/v1/quotes/%<quote>s/pdf", { quote: CGI.escape(self["id"]) }),
    params: params,
    opts: opts,
    &read_body_chunk_block
  )
end