Class: Stripe::QuoteService

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

Defined Under Namespace

Classes: AcceptParams, CancelParams, CreateParams, FinalizeQuoteParams, ListParams, PdfParams, 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
# 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.



643
644
645
646
647
648
649
650
651
# File 'lib/stripe/services/quote_service.rb', line 643

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.



654
655
656
657
658
659
660
661
662
# File 'lib/stripe/services/quote_service.rb', line 654

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



665
666
667
# File 'lib/stripe/services/quote_service.rb', line 665

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.



670
671
672
673
674
675
676
677
678
# File 'lib/stripe/services/quote_service.rb', line 670

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.



681
682
683
# File 'lib/stripe/services/quote_service.rb', line 681

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](docs.stripe.com/quotes/overview#quote_pdf)



686
687
688
689
690
691
692
693
694
695
696
# File 'lib/stripe/services/quote_service.rb', line 686

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.



699
700
701
702
703
704
705
706
707
# File 'lib/stripe/services/quote_service.rb', line 699

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.



710
711
712
713
714
715
716
717
718
# File 'lib/stripe/services/quote_service.rb', line 710

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