Class: Increase::Resources::Files

Inherits:
Object
  • Object
show all
Defined in:
lib/increase/resources/files.rb,
sig/increase/resources/files.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Files

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Files.

Parameters:



100
101
102
# File 'lib/increase/resources/files.rb', line 100

def initialize(client:)
  @client = client
end

Instance Method Details

#create(file:, purpose:, description: nil, request_options: {}) ⇒ Increase::Models::File

To upload a file to Increase, you'll need to send a request of Content-Type multipart/form-data. The request should contain the file you would like to upload, as well as the parameters for creating a file.

Parameters:

Returns:

See Also:



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/increase/resources/files.rb', line 27

def create(params)
  parsed, options = Increase::FileCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "files",
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: Increase::File,
    options: options
  )
end

#list(created_at: nil, cursor: nil, idempotency_key: nil, limit: nil, purpose: nil, request_options: {}) ⇒ Increase::Internal::Page<Increase::Models::File>

List Files

Parameters:

  • created_at (Increase::Models::FileListParams::CreatedAt)
  • cursor (String)

    Return the page of entries after this one.

  • idempotency_key (String)

    Filter records to the one with the specified idempotency_key you chose for that object. This value is unique across Increase and is used to ensure that a request is only processed once. Learn more about idempotency.

  • limit (Integer)

    Limit the size of the list that is returned. The default (and maximum) is 100 objects.

  • purpose (Increase::Models::FileListParams::Purpose)
  • request_options (Increase::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/increase/resources/files.rb', line 84

def list(params = {})
  parsed, options = Increase::FileListParams.dump_request(params)
  query = Increase::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "files",
    query: query,
    page: Increase::Internal::Page,
    model: Increase::File,
    options: options
  )
end

#retrieve(file_id, request_options: {}) ⇒ Increase::Models::File

Retrieve a File

Parameters:

  • file_id (String)

    The identifier of the File.

  • request_options (Increase::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



50
51
52
53
54
55
56
57
# File 'lib/increase/resources/files.rb', line 50

def retrieve(file_id, params = {})
  @client.request(
    method: :get,
    path: ["files/%1$s", file_id],
    model: Increase::File,
    options: params[:request_options]
  )
end