Class: Increase::Resources::Files
- Inherits:
-
Object
- Object
- Increase::Resources::Files
- Defined in:
- lib/increase/resources/files.rb,
sig/increase/resources/files.rbs
Instance Method Summary collapse
-
#contents(file_id, request_options: {}) ⇒ StringIO
Download the contents of a File.
-
#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. -
#initialize(client:) ⇒ Files
constructor
private
A new instance of Files.
-
#list(created_at: nil, cursor: nil, idempotency_key: nil, limit: nil, purpose: nil, request_options: {}) ⇒ Increase::Internal::Page<Increase::Models::File>
List Files.
-
#retrieve(file_id, request_options: {}) ⇒ Increase::Models::File
Retrieve a File.
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.
128 129 130 |
# File 'lib/increase/resources/files.rb', line 128 def initialize(client:) @client = client end |
Instance Method Details
#contents(file_id, request_options: {}) ⇒ StringIO
Download the contents of a File. Responds with a 307 redirect whose Location
header points at a short-lived, pre-signed URL. Our
SDKs follow the redirect and return
the File's contents; if you call the API directly, follow the redirect to
download it. The pre-signed URL serves the File with a Content-Type matching
its mime and a Content-Disposition header set to its filename. It expires
in 10 minutes. To share a File with someone who doesn't have access to your API
key, create a File Link.
115 116 117 118 119 120 121 122 123 |
# File 'lib/increase/resources/files.rb', line 115 def contents(file_id, params = {}) @client.request( method: :get, path: ["files/%1$s/contents", file_id], headers: {"accept" => "application/octet-stream"}, model: StringIO, options: params[:request_options] ) end |
#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.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/increase/resources/files.rb', line 27 def create(params) parsed, = Increase::FileCreateParams.dump_request(params) @client.request( method: :post, path: "files", headers: {"content-type" => "multipart/form-data"}, body: parsed, model: Increase::File, 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
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/increase/resources/files.rb', line 84 def list(params = {}) parsed, = 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: ) end |
#retrieve(file_id, request_options: {}) ⇒ Increase::Models::File
Retrieve a File
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 |