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



626
627
628
629
630
631
632
633
634
# File 'lib/stripe/services/quote_service.rb', line 626

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.



637
638
639
640
641
642
643
644
645
# File 'lib/stripe/services/quote_service.rb', line 637

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



648
649
650
# File 'lib/stripe/services/quote_service.rb', line 648

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.



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

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.



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

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)



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

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.



682
683
684
685
686
687
688
689
690
# File 'lib/stripe/services/quote_service.rb', line 682

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.



693
694
695
696
697
698
699
700
701
# File 'lib/stripe/services/quote_service.rb', line 693

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