Class: Pago::V2026_04::Services::CustomFields

Inherits:
Service
  • Object
show all
Defined in:
lib/pago/v2026_04/services/custom_fields.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: {}) ⇒ Object

Create a custom field.

Scopes: custom_fields:write

Parameters:

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

    the request body.

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

Returns:

  • (Object)

Raises:



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

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

#delete(id) ⇒ nil

Delete a custom field.

Scopes: custom_fields:write

Parameters:

  • id (String)

    The custom field ID.

Returns:

  • (nil)

Raises:



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

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

#get(id) ⇒ Object

Get a custom field by ID.

Scopes: custom_fields:read custom_fields:write

Parameters:

  • id (String)

    The custom field ID.

Returns:

  • (Object)

Raises:



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

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

#list(organization_id: nil, query: nil, type: nil, page: 1, limit: 10, sorting: ["slug"]) ⇒ Models::ListResourceCustomField

List custom fields.

Scopes: custom_fields:read custom_fields:write

Parameters:

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

    Filter by organization ID.

  • query (String, nil) (defaults to: nil)

    Filter by custom field name or slug.

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

    Filter by custom field type.

  • 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: ["slug"])

    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)
  • query: (String, nil) (defaults to: nil)
  • type: (Object) (defaults to: nil)
  • page: (Integer, nil) (defaults to: 1)
  • limit: (Integer, nil) (defaults to: 10)
  • sorting: (Array[String], nil) (defaults to: ["slug"])

Returns:

Raises:



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

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

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

Enumerate every item of list, fetching pages on demand.

Parameters:

  • organization_id: (Object) (defaults to: nil)
  • query: (String, nil) (defaults to: nil)
  • type: (Object) (defaults to: nil)
  • limit: (Integer, nil) (defaults to: 10)
  • sorting: (Array[String], nil) (defaults to: ["slug"])

Yield Parameters:

  • item (Object)

Returns:



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

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

#update(id, body: {}) ⇒ Object

Update a custom field.

Scopes: custom_fields:write

Parameters:

  • id (String)

    The custom field ID.

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

    the request body.

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

Returns:

  • (Object)

Raises:



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

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