Class: MojFileUploaderApiClient::AddFile

Inherits:
HttpClient
  • Object
show all
Defined in:
lib/mojfile_uploader_api_client/add_file.rb

Constant Summary

Constants inherited from HttpClient

HttpClient::DEFAULT_OPTIONS

Instance Attribute Summary collapse

Attributes inherited from HttpClient

#response

Instance Method Summary collapse

Methods inherited from HttpClient

#call, configure, #options, #payload?

Constructor Details

#initialize(collection_ref: nil, folder: nil, filename:, data:) ⇒ AddFile

Returns a new instance of AddFile.



5
6
7
8
9
10
# File 'lib/mojfile_uploader_api_client/add_file.rb', line 5

def initialize(collection_ref: nil, folder: nil, filename:, data:)
  self.collection_ref = collection_ref
  self.folder = folder
  self.filename = filename
  self.data = data
end

Instance Attribute Details

#collection_refObject

Returns the value of attribute collection_ref.



3
4
5
# File 'lib/mojfile_uploader_api_client/add_file.rb', line 3

def collection_ref
  @collection_ref
end

#dataObject

Returns the value of attribute data.



3
4
5
# File 'lib/mojfile_uploader_api_client/add_file.rb', line 3

def data
  @data
end

#filenameObject

Returns the value of attribute filename.



3
4
5
# File 'lib/mojfile_uploader_api_client/add_file.rb', line 3

def filename
  @filename
end

#folderObject

Returns the value of attribute folder.



3
4
5
# File 'lib/mojfile_uploader_api_client/add_file.rb', line 3

def folder
  @folder
end

Instance Method Details

#endpointObject



22
23
24
# File 'lib/mojfile_uploader_api_client/add_file.rb', line 22

def endpoint
  File.join(collection_ref.to_s, 'new')
end

#payloadObject



16
17
18
19
20
# File 'lib/mojfile_uploader_api_client/add_file.rb', line 16

def payload
  payload = {file_filename: filename, file_data: data}
  payload[:folder] = folder if folder
  payload
end

#verbObject



12
13
14
# File 'lib/mojfile_uploader_api_client/add_file.rb', line 12

def verb
  :post
end