Sha256: f664f02ca2d99549fec8a9ea272ab625bb4b87baabc2ae0c77990328589eadd6

Contents?: true

Size: 1015 Bytes

Versions: 8

Compression:

Stored size: 1015 Bytes

Contents

# frozen_string_literal: true
require 'dato/site/repo/base'

module Dato
  module Site
    module Repo
      class Upload < Base
        def create(resource_attributes)
          body = JsonApiSerializer.new(
            type: :upload,
            attributes: %i(alt format height path size title width),
            required_attributes: %i(format path size)
          ).serialize(resource_attributes)

          post_request '/uploads', body
        end

        def all(query)
          get_request '/uploads', query
        end

        def find(upload_id)
          get_request "/uploads/#{upload_id}"
        end

        def destroy(upload_id)
          delete_request "/uploads/#{upload_id}"
        end

        def update(upload_id, resource_attributes)
          body = JsonApiSerializer.new(
            type: :upload,
            attributes: %i(alt title)
          ).serialize(resource_attributes, upload_id)

          put_request "/uploads/#{upload_id}", body
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dato-0.3.28 lib/dato/site/repo/upload.rb
dato-0.3.27 lib/dato/site/repo/upload.rb
dato-0.3.26 lib/dato/site/repo/upload.rb
dato-0.3.25 lib/dato/site/repo/upload.rb
dato-0.3.24 lib/dato/site/repo/upload.rb
dato-0.3.23 lib/dato/site/repo/upload.rb
dato-0.3.22 lib/dato/site/repo/upload.rb
dato-0.3.21 lib/dato/site/repo/upload.rb