Class: Pago::V2026_04::Services::Organizations
- Defined in:
- lib/pago/v2026_04/services/organizations.rb,
sig/pago/v2026_04/generated.rbs
Instance Attribute Summary
Attributes inherited from Service
Instance Method Summary collapse
-
#create(body: {}) ⇒ Models::Organization
Create an organization.
-
#get(id) ⇒ Models::Organization
Get an organization by ID.
-
#list(slug: nil, page: 1, limit: 10, sorting: ["created_at"]) ⇒ Models::ListResourceOrganization
List organizations.
-
#list_each(slug: nil, limit: 10, sorting: ["created_at"]) {|item| ... } ⇒ Pago::Paginator
Enumerate every item of
list, fetching pages on demand. -
#update(id, body: {}) ⇒ Models::Organization
Update an organization.
Methods inherited from Service
Constructor Details
This class inherits a constructor from Pago::Service
Instance Method Details
#create(body: {}) ⇒ Models::Organization
Create an organization.
Scopes: organizations:write
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
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
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.
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
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 |