Class: Stripe::Tax::CalculationService

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from StripeService

#request, #request_stream

Constructor Details

#initialize(requestor) ⇒ CalculationService

Returns a new instance of CalculationService.



9
10
11
12
# File 'lib/stripe/services/tax/calculation_service.rb', line 9

def initialize(requestor)
  super(requestor)
  @line_items = Stripe::Tax::CalculationLineItemService.new(@requestor)
end

Instance Attribute Details

#line_itemsObject (readonly)

Returns the value of attribute line_items.



7
8
9
# File 'lib/stripe/services/tax/calculation_service.rb', line 7

def line_items
  @line_items
end

Instance Method Details

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

Calculates tax based on the input and returns a Tax Calculation object.



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

def create(params = {}, opts = {})
  request(
    method: :post,
    path: "/v1/tax/calculations",
    params: params,
    opts: opts,
    base_address: :api
  )
end

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

Retrieves a Tax Calculation object, if the calculation hasn’t expired.



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

def retrieve(calculation, params = {}, opts = {})
  request(
    method: :get,
    path: format("/v1/tax/calculations/%<calculation>s", { calculation: CGI.escape(calculation) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end