class Ittybit::AsyncFilesClient

def create(url:, media_id: nil, folder: nil, filename: nil, ref: nil, metadata: nil, request_options: nil)

Returns:
  • (Ittybit::FileResponse) -

Parameters:
  • request_options (Ittybit::RequestOptions) --
  • metadata (Hash{String => Object}) --
  • ref (String) --
  • filename (String) --
  • folder (String) --
  • media_id (String) --
  • url (String) --
def create(url:, media_id: nil, folder: nil, filename: nil, ref: nil, metadata: nil, request_options: nil)
  Async do
    response = @request_client.conn.post do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      unless request_options.nil? || request_options&.additional_query_parameters.nil?
        req.params = { **(request_options&.additional_query_parameters || {}) }.compact
      end
      req.body = {
        **(request_options&.additional_body_parameters || {}),
        url: url,
        media_id: media_id,
        folder: folder,
        filename: filename,
        ref: ref,
        metadata: metadata
      }.compact
      req.url "#{@request_client.get_url(request_options: request_options)}/files"
    end
    Ittybit::FileResponse.from_json(json_object: response.body)
  end
end

def delete(id:, request_options: nil)

Returns:
  • (Ittybit::ConfirmationResponse) -

Parameters:
  • request_options (Ittybit::RequestOptions) --
  • id (String) --
def delete(id:, request_options: nil)
  Async do
    response = @request_client.conn.delete do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      unless request_options.nil? || request_options&.additional_query_parameters.nil?
        req.params = { **(request_options&.additional_query_parameters || {}) }.compact
      end
      unless request_options.nil? || request_options&.additional_body_parameters.nil?
        req.body = { **(request_options&.additional_body_parameters || {}) }.compact
      end
      req.url "#{@request_client.get_url(request_options: request_options)}/files/#{id}"
    end
    Ittybit::ConfirmationResponse.from_json(json_object: response.body)
  end
end

def get(id:, request_options: nil)

Returns:
  • (Ittybit::FileResponse) -

Parameters:
  • request_options (Ittybit::RequestOptions) --
  • id (String) --
def get(id:, request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      unless request_options.nil? || request_options&.additional_query_parameters.nil?
        req.params = { **(request_options&.additional_query_parameters || {}) }.compact
      end
      unless request_options.nil? || request_options&.additional_body_parameters.nil?
        req.body = { **(request_options&.additional_body_parameters || {}) }.compact
      end
      req.url "#{@request_client.get_url(request_options: request_options)}/files/#{id}"
    end
    Ittybit::FileResponse.from_json(json_object: response.body)
  end
end

def initialize(request_client:)

Returns:
  • (Ittybit::AsyncFilesClient) -

Parameters:
  • request_client (Ittybit::AsyncRequestClient) --
def initialize(request_client:)
  @request_client = request_client
end

def list(limit: nil, request_options: nil)

Returns:
  • (Ittybit::FileListResponse) -

Parameters:
  • request_options (Ittybit::RequestOptions) --
  • limit (Integer) --
def list(limit: nil, request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      req.params = { **(request_options&.additional_query_parameters || {}), "limit": limit }.compact
      unless request_options.nil? || request_options&.additional_body_parameters.nil?
        req.body = { **(request_options&.additional_body_parameters || {}) }.compact
      end
      req.url "#{@request_client.get_url(request_options: request_options)}/files"
    end
    Ittybit::FileListResponse.from_json(json_object: response.body)
  end
end

def update(id:, folder: nil, filename: nil, ref: nil, metadata: nil, request_options: nil)

Returns:
  • (Ittybit::FileResponse) -

Parameters:
  • request_options (Ittybit::RequestOptions) --
  • metadata (Hash{String => Object}) --
  • ref (String) --
  • filename (String) --
  • folder (String) --
  • id (String) --
def update(id:, folder: nil, filename: nil, ref: nil, metadata: nil, request_options: nil)
  Async do
    response = @request_client.conn.patch do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      unless request_options.nil? || request_options&.additional_query_parameters.nil?
        req.params = { **(request_options&.additional_query_parameters || {}) }.compact
      end
      req.body = {
        **(request_options&.additional_body_parameters || {}),
        folder: folder,
        filename: filename,
        ref: ref,
        metadata: metadata
      }.compact
      req.url "#{@request_client.get_url(request_options: request_options)}/files/#{id}"
    end
    Ittybit::FileResponse.from_json(json_object: response.body)
  end
end