Class: Pago::V2026_04::Services::Files
- Defined in:
- lib/pago/v2026_04/services/files.rb,
sig/pago/v2026_04/generated.rbs
Instance Attribute Summary
Attributes inherited from Service
Instance Method Summary collapse
-
#create(body: {}) ⇒ Models::FileUpload
Create a file.
-
#delete(id) ⇒ nil
Delete a file.
-
#list(organization_id: nil, ids: nil, page: 1, limit: 10) ⇒ Models::ListResourceFileRead
List files.
-
#list_each(organization_id: nil, ids: nil, limit: 10) {|item| ... } ⇒ Pago::Paginator
Enumerate every item of
list, fetching pages on demand. -
#update(id, body: {}) ⇒ Object
Update a file.
-
#uploaded(id_path, body: {}) ⇒ Object
Complete a file upload.
Methods inherited from Service
Constructor Details
This class inherits a constructor from Pago::Service
Instance Method Details
#create(body: {}) ⇒ Models::FileUpload
Create a file.
Scopes: files:write
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pago/v2026_04/services/files.rb', line 49 def create(body: {}) data = client.request( http_method: "POST", path: "/v1/files/", path_params: {}, query: {}, body: body, response_type: :json, errors: { 422 => Errors::HTTPValidationError } ) Models::FileUpload.from_json(data) end |
#delete(id) ⇒ nil
Delete a file.
Scopes: files:write
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/pago/v2026_04/services/files.rb', line 96 def delete(id) client.request( http_method: "DELETE", path: "/v1/files/{id}", path_params: { "id" => id }, query: {}, response_type: :none, errors: { 403 => Errors::NotPermitted, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError } ) end |
#list(organization_id: nil, ids: nil, page: 1, limit: 10) ⇒ Models::ListResourceFileRead
List files.
Scopes: files:read files:write
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pago/v2026_04/services/files.rb', line 18 def list(organization_id: nil, ids: nil, page: 1, limit: 10) data = client.request( http_method: "GET", path: "/v1/files/", path_params: {}, query: { "organization_id" => organization_id, "ids" => ids, "page" => page, "limit" => limit }, response_type: :json, errors: { 422 => Errors::HTTPValidationError } ) Models::ListResourceFileRead.from_json(data) end |
#list_each(organization_id: nil, ids: nil, limit: 10) {|item| ... } ⇒ Pago::Paginator
Enumerate every item of list, fetching pages on demand.
34 35 36 37 38 39 |
# File 'lib/pago/v2026_04/services/files.rb', line 34 def list_each(organization_id: nil, ids: nil, limit: 10, &block) paginator = ::Pago::Paginator.new do |page_number| list(organization_id: organization_id, ids: ids, page: page_number, limit: limit) end block ? paginator.each(&block) : paginator end |
#update(id, body: {}) ⇒ Object
Update a file.
Scopes: files:write
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/pago/v2026_04/services/files.rb', line 118 def update(id, body: {}) data = client.request( http_method: "PATCH", path: "/v1/files/{id}", path_params: { "id" => id }, query: {}, body: body, response_type: :json, errors: { 403 => Errors::NotPermitted, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError } ) Unions::FileRead.from_json(data) end |
#uploaded(id_path, body: {}) ⇒ Object
Complete a file upload.
Scopes: files:write
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/pago/v2026_04/services/files.rb', line 73 def uploaded(id_path, body: {}) data = client.request( http_method: "POST", path: "/v1/files/{id}/uploaded", path_params: { "id" => id_path }, query: {}, body: body, response_type: :json, errors: { 403 => Errors::NotPermitted, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError } ) Unions::FileRead.from_json(data) end |