Class: RunApi::Core::Files

Inherits:
Object
  • Object
show all
Includes:
ResourceHelpers
Defined in:
lib/runapi/core/files.rb

Defined Under Namespace

Classes: UploadResponse

Constant Summary collapse

ENDPOINT =
"/api/v1/files"
RESPONSE_CLASS =
UploadResponse

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ Files

Returns a new instance of Files.



21
22
23
# File 'lib/runapi/core/files.rb', line 21

def initialize(http)
  @http = http
end

Instance Method Details

#create(file: nil, source: nil, file_name: nil, options: nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/runapi/core/files.rb', line 25

def create(file: nil, source: nil, file_name: nil, options: nil)
  validate_source!(file:, source:)

  body = if file
    multipart_body(file, file_name:)
  else
    compact_params(source:, file_name:)
  end

  request(:post, ENDPOINT, body:, options:)
end