Class: TranslationCms::Api::Customers::ReferenceMaterial

Inherits:
Attachment
  • Object
show all
Defined in:
lib/translation_cms/api/customers/reference_material.rb

Class Method Summary collapse

Class Method Details

.path(params = {}) ⇒ Object



9
10
11
12
13
14
# File 'lib/translation_cms/api/customers/reference_material.rb', line 9

def path(params = {})
  id = params['number'] if params.key?('number')
  id = params['order_id'] if params.key?('order_id')
  id ||= params
  "customers/orders/#{id}/reference_materials"
end

.payload(file, _guid) ⇒ Object



20
21
22
23
# File 'lib/translation_cms/api/customers/reference_material.rb', line 20

def payload(file, _guid)
  upload_io = Faraday::UploadIO.new(file.file, file.content_type)
  { data: upload_io, fileupload_token: random_guid }
end

.random_guidObject



16
17
18
# File 'lib/translation_cms/api/customers/reference_material.rb', line 16

def random_guid
  SecureRandom.base64(15).tr('+/=', 'xyz')
end