Sha256: 7e347b696f6d752ad9aade4034e2e43e40596e5e760d8864c00442662277f9be

Contents?: true

Size: 1.62 KB

Versions: 2

Compression:

Stored size: 1.62 KB

Contents

module Kloudless
  # https://developers.kloudless.com/docs#folders
  class Folder < Model
    # https://developers.kloudless.com/docs#folders-create-a-folder
    def self.create(account_id:, params: {}, **data)
      path = "/accounts/#{account_id}/folders"
      new(http.post(path, params: params, data: data))
    end

    # https://developers.kloudless.com/docs#folders-retrieve-folder-metadata
    def self.metadata(account_id:, folder_id:, **params)
      path = "/accounts/#{account_id}/folders/#{folder_id}"
      new(http.get(path, params: params))
    end

    # https://developers.kloudless.com/docs#folders-retrieve-folder-contents
    def self.retrieve(account_id:, folder_id:, **params)
      path = "/accounts/#{account_id}/folders/#{folder_id}/contents"
      Kloudless::Collection.new(self, http.get(path, params: params))
    end

    # https://developers.kloudless.com/docs#folders-rename/move-a-folder
    def self.rename(account_id:, folder_id:, params: {}, **data)
      path = "/accounts/#{account_id}/folders/#{folder_id}"
      new(http.patch(path, params: params, data: data))
    end

    # https://developers.kloudless.com/docs#folders-copy-a-folder
    def self.copy(account_id:, folder_id:, parent_id:, params: {}, **data)
      path = "/accounts/#{account_id}/folders/#{folder_id}/copy"
      data[:parent_id] = parent_id
      new(http.post(path, params: params, data: data))
    end

    # https://developers.kloudless.com/docs#folders-delete-a-folder
    def self.delete(account_id:, folder_id:, **params)
      path = "/accounts/#{account_id}/folders/#{folder_id}"
      new(http.delete(path, params: params))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kloudless-0.2.1 lib/kloudless/folder.rb
kloudless-0.2.0 lib/kloudless/folder.rb