Class: ManyfoldApi::V0::UploadedFileDeserializer

Inherits:
BaseDeserializer show all
Defined in:
app/deserializers/manyfold_api/v0/uploaded_file_deserializer.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseDeserializer

#dereference, #initialize, schema_ref, schema_ref_name

Constructor Details

This class inherits a constructor from ManyfoldApi::V0::BaseDeserializer

Class Method Details

.schema ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/deserializers/manyfold_api/v0/uploaded_file_deserializer.rb', line 12

def self.schema
  {
    type: :object,
    properties: {
      files: {
        type: :array,
        items: {
          type: :object,
          properties: {
            id: {type: :string, description: "The ID of a completed upload, obtained from the upload endpoints", example: "http://example.com/uploads/abc123456def"},
            name: {type: :string, example: "model.stl"}
          },
          required: [:id, :name, :type, :size]
        }
      }
    },
    required: [:files]
  }
end

Instance Method Details

#deserialize ⇒ Object



3
4
5
6
7
8
9
10
# File 'app/deserializers/manyfold_api/v0/uploaded_file_deserializer.rb', line 3

def deserialize
  return unless @object
  {
    model: {
      file: @object.dig("files")&.each_with_index.to_h.invert
    }
  }.compact
end