Class: Pago::V2026_04::Services::Files

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

Create a file.

Scopes: files:write

Parameters:

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

    the request body.

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

Returns:

Raises:



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

Parameters:

  • id (String)

Returns:

  • (nil)

Raises:



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

Parameters:

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

    Filter by organization ID.

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

    Filter by file ID.

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

  • organization_id: (Object) (defaults to: nil)
  • ids: (Object) (defaults to: nil)
  • page: (Integer, nil) (defaults to: 1)
  • limit: (Integer, nil) (defaults to: 10)

Returns:

Raises:



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.

Parameters:

  • organization_id: (Object) (defaults to: nil)
  • ids: (Object) (defaults to: nil)
  • limit: (Integer, nil) (defaults to: 10)

Yield Parameters:

  • item (Object)

Returns:



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

Parameters:

  • id (String)

    The file ID.

  • body (Hash, Models::FilePatch) (defaults to: {})

    the request body.

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

Returns:

  • (Object)

Raises:



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

Parameters:

  • id_path (String)

    The file ID.

  • body (Hash, Models::FileUploadCompleted) (defaults to: {})

    the request body.

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

Returns:

  • (Object)

Raises:



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