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
# File 'lib/stripe/services/quote_service.rb', line 8

def initialize(requestor)
  super
  @computed_upfront_line_items = Stripe::QuoteComputedUpfrontLineItemsService.new(@requestor)
  @line_items = Stripe::QuoteLineItemService.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

Instance Method Details

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

Accepts the specified quote.



15
16
17
18
19
20
21
22
23
# File 'lib/stripe/services/quote_service.rb', line 15

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.



26
27
28
29
30
31
32
33
34
# File 'lib/stripe/services/quote_service.rb', line 26

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.



37
38
39
40
41
# File 'lib/stripe/services/quote_service.rb', line 37

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.



44
45
46
47
48
49
50
51
52
# File 'lib/stripe/services/quote_service.rb', line 44

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.



55
56
57
# File 'lib/stripe/services/quote_service.rb', line 55

def list(params = {}, opts = {})
  request(method: :get, path: "/v1/quotes", 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



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/stripe/services/quote_service.rb', line 60

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

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

Retrieves the quote with the given ID.



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

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.



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

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