Class: Inttegro::Resources::Refunds

Inherits:
Object
  • Object
show all
Defined in:
lib/inttegro/resources/refunds.rb

Overview

Client for creating, canceling, and observing refunds.

Access this resource through Client#refunds.

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ Refunds

Returns a new instance of Refunds.

Parameters:



11
12
13
# File 'lib/inttegro/resources/refunds.rb', line 11

def initialize(http)
  @http = T.let(http, Inttegro::HTTPClient)
end

Instance Method Details

#cancel(refund_id:, reason: nil) ⇒ Inttegro::Refund

Cancel a pending refund before processing claims it.

Parameters:

  • refund_id (String) —

    unique refund identifier

  • reason (String, nil) (defaults to: nil) —

    optional explanation for canceling the refund

Returns:



28
29
30
31
32
33
34
35
36
# File 'lib/inttegro/resources/refunds.rb', line 28

def cancel(refund_id:, reason: nil)
  payload = T.let({ refund_id: refund_id }, Inttegro::Types::Payload)
  payload[:reason] = reason unless reason.nil?
  @http.post_resource(
    "/refunds/cancel",
    Inttegro::Refund, :refund,
    payload
  )
end

#create(payload) ⇒ Inttegro::Refund

Start a refund for paid order line items.

Parameters:

Returns:



19
20
21
# File 'lib/inttegro/resources/refunds.rb', line 19

def create(payload)
  @http.post_resource("/refunds/create", Inttegro::Refund, :refund, payload)
end

#lookup(refund_id:) ⇒ Inttegro::Refund

Retrieve the current lifecycle state and amounts for one refund.

Parameters:

  • refund_id (String) —

    unique refund identifier

Returns:



42
43
44
45
46
47
48
# File 'lib/inttegro/resources/refunds.rb', line 42

def lookup(refund_id:)
  @http.post_resource(
    "/refunds/lookup",
    Inttegro::Refund, :refund,
    { refund_id: refund_id }
  )
end

#page(payload) ⇒ Inttegro::Refund::Page

Retrieve a page of refunds.

Parameters:

Returns:



54
55
56
# File 'lib/inttegro/resources/refunds.rb', line 54

def page(payload)
  @http.post_resource("/refunds/page", Inttegro::Refund::Page, :page, payload)
end