Module: ApiResource::Formats::FileUploadFormat

Extended by:
FileUploadFormat
Included in:
FileUploadFormat
Defined in:
lib/api_resource/formats/file_upload_format.rb

Overview

Class to handle posting of multipart data to HTTPClient

Instance Method Summary collapse

Instance Method Details

#decode(json) ⇒ Hash

Implementation of #decode - decodes data back from the server We expect the data to be JSON-formatted

Returns:

  • (Hash)


54
55
56
# File 'lib/api_resource/formats/file_upload_format.rb', line 54

def decode(json)
  JSON.parse(json)
end

#encode(hash, options = nil) ⇒ Hash

Implementation of #encode - encodes data to POST to the server

Returns:

  • (Hash)


40
41
42
43
44
45
46
# File 'lib/api_resource/formats/file_upload_format.rb', line 40

def encode(hash, options = nil)
  ret = {}
  hash.each_pair do |k,v|
    ret[k] = self.encode_value(v)
  end
  ret
end

#extensionString

The extension for the request

Returns:

  • (String)


21
22
23
# File 'lib/api_resource/formats/file_upload_format.rb', line 21

def extension
  "json"
end

#mime_typeString

The mime_type header for the request

Returns:

  • (String)


30
31
32
# File 'lib/api_resource/formats/file_upload_format.rb', line 30

def mime_type
  "multipart/form-data"
end