Class: Pago::V2026_04::Services::CheckoutLinks

Inherits:
Service
  • Object
show all
Defined in:
lib/pago/v2026_04/services/checkout_links.rb,
sig/pago/v2026_04/generated.rbs

Instance Attribute Summary

Attributes inherited from Service

#client

Instance Method Summary collapse

Methods inherited from Service

#initialize

Constructor Details

This class inherits a constructor from Pago::Service

Instance Method Details

#create(body: {}) ⇒ Models::CheckoutLink

Create a checkout link.

Scopes: checkout_links:write

Parameters:

  • body (Hash, Object) (defaults to: {})

    the request body.

  • body: (Object) (defaults to: {})

Returns:

Raises:



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/pago/v2026_04/services/checkout_links.rb', line 50

def create(body: {})
  data = client.request(
    http_method: "POST",
    path: "/v1/checkout-links/",
    path_params: {},
    query: {},
    body: body,
    response_type: :json,
    errors: { 422 => Errors::HTTPValidationError }
  )
  Models::CheckoutLink.from_json(data)
end

#delete(id) ⇒ nil

Delete a checkout link.

Scopes: checkout_links:write

Parameters:

  • id (String)

    The checkout link ID.

Returns:

  • (nil)

Raises:



93
94
95
96
97
98
99
100
101
102
# File 'lib/pago/v2026_04/services/checkout_links.rb', line 93

def delete(id)
  client.request(
    http_method: "DELETE",
    path: "/v1/checkout-links/{id}",
    path_params: { "id" => id },
    query: {},
    response_type: :none,
    errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
end

#get(id) ⇒ Models::CheckoutLink

Get a checkout link by ID.

Scopes: checkout_links:read checkout_links:write

Parameters:

  • id (String)

    The checkout link ID.

Returns:

Raises:



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/pago/v2026_04/services/checkout_links.rb', line 72

def get(id)
  data = client.request(
    http_method: "GET",
    path: "/v1/checkout-links/{id}",
    path_params: { "id" => id },
    query: {},
    response_type: :json,
    errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
  Models::CheckoutLink.from_json(data)
end

#list(organization_id: nil, product_id: nil, page: 1, limit: 10, sorting: ["created_at"]) ⇒ Models::ListResourceCheckoutLink

List checkout links.

Scopes: checkout_links:read checkout_links:write

Parameters:

  • organization_id (String, Array<String>, nil) (defaults to: nil)

    Filter by organization ID.

  • product_id (String, Array<String>, nil) (defaults to: nil)

    Filter by product ID.

  • page (Integer) (defaults to: 1)

    Page number, defaults to 1.

  • limit (Integer) (defaults to: 10)

    Size of a page, defaults to 10. Maximum is 100.

  • sorting (Array<String>, nil) (defaults to: ["created_at"])

    Sorting criterion. Several criteria can be used simultaneously and will be applied in order. Add a minus sign - before the criteria name to sort by descending order.

  • organization_id: (Object) (defaults to: nil)
  • product_id: (Object) (defaults to: nil)
  • page: (Integer, nil) (defaults to: 1)
  • limit: (Integer, nil) (defaults to: 10)
  • sorting: (Array[String], nil) (defaults to: ["created_at"])

Returns:

Raises:



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/pago/v2026_04/services/checkout_links.rb', line 19

def list(organization_id: nil, product_id: nil, page: 1, limit: 10, sorting: ["created_at"])
  data = client.request(
    http_method: "GET",
    path: "/v1/checkout-links/",
    path_params: {},
    query: { "organization_id" => organization_id, "product_id" => product_id, "page" => page, "limit" => limit, "sorting" => sorting },
    response_type: :json,
    errors: { 422 => Errors::HTTPValidationError }
  )
  Models::ListResourceCheckoutLink.from_json(data)
end

#list_each(organization_id: nil, product_id: nil, limit: 10, sorting: ["created_at"]) {|item| ... } ⇒ Pago::Paginator

Enumerate every item of list, fetching pages on demand.

Parameters:

  • organization_id: (Object) (defaults to: nil)
  • product_id: (Object) (defaults to: nil)
  • limit: (Integer, nil) (defaults to: 10)
  • sorting: (Array[String], nil) (defaults to: ["created_at"])

Yield Parameters:

Returns:



35
36
37
38
39
40
# File 'lib/pago/v2026_04/services/checkout_links.rb', line 35

def list_each(organization_id: nil, product_id: nil, limit: 10, sorting: ["created_at"], &block)
  paginator = ::Pago::Paginator.new do |page_number|
    list(organization_id: organization_id, product_id: product_id, page: page_number, limit: limit, sorting: sorting)
  end
  block ? paginator.each(&block) : paginator
end

#update(id, body: {}) ⇒ Models::CheckoutLink

Update a checkout link.

Scopes: checkout_links:write

Parameters:

  • id (String)

    The checkout link ID.

  • body (Hash, Models::CheckoutLinkUpdate) (defaults to: {})

    the request body.

  • body: (Object) (defaults to: {})

Returns:

Raises:



114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/pago/v2026_04/services/checkout_links.rb', line 114

def update(id, body: {})
  data = client.request(
    http_method: "PATCH",
    path: "/v1/checkout-links/{id}",
    path_params: { "id" => id },
    query: {},
    body: body,
    response_type: :json,
    errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
  Models::CheckoutLink.from_json(data)
end