Class: Pago::V2026_04::Services::CustomFields
- Defined in:
- lib/pago/v2026_04/services/custom_fields.rb,
sig/pago/v2026_04/generated.rbs
Instance Attribute Summary
Attributes inherited from Service
Instance Method Summary collapse
-
#create(body: {}) ⇒ Object
Create a custom field.
-
#delete(id) ⇒ nil
Delete a custom field.
-
#get(id) ⇒ Object
Get a custom field by ID.
-
#list(organization_id: nil, query: nil, type: nil, page: 1, limit: 10, sorting: ["slug"]) ⇒ Models::ListResourceCustomField
List custom fields.
-
#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. -
#update(id, body: {}) ⇒ Object
Update a custom field.
Methods inherited from Service
Constructor Details
This class inherits a constructor from Pago::Service
Instance Method Details
#create(body: {}) ⇒ Object
Create a custom field.
Scopes: custom_fields:write
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
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
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
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.
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
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 |