Class: Pago::V2026_04::Services::Organizations

Inherits:
Service
  • Object
show all
Defined in:
lib/pago/v2026_04/services/organizations.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::Organization

Create an organization.

Scopes: organizations:write

Parameters:

Returns:

Raises:



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

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

#get(id) ⇒ Models::Organization

Get an organization by ID.

Scopes: organizations:read organizations:write

Parameters:

  • id (String)

Returns:

Raises:



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

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

#list(slug: nil, page: 1, limit: 10, sorting: ["created_at"]) ⇒ Models::ListResourceOrganization

List organizations.

Scopes: organizations:read organizations:write

Parameters:

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

    Filter by slug.

  • 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.

  • slug: (String, nil) (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:



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

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

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

Enumerate every item of list, fetching pages on demand.

Parameters:

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

Yield Parameters:

Returns:



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

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

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

Update an organization.

Scopes: organizations:write

Parameters:

Returns:

Raises:



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/pago/v2026_04/services/organizations.rb', line 96

def update(id, body: {})
  data = client.request(
    http_method: "PATCH",
    path: "/v1/organizations/{id}",
    path_params: { "id" => id },
    query: {},
    body: body,
    response_type: :json,
    errors: { 403 => Errors::NotPermitted, 404 => Errors::ResourceNotFound, 409 => Errors::SSOEnforcementRequiresConnection, 422 => Errors::HTTPValidationError }
  )
  Models::Organization.from_json(data)
end