Sha256: d91f76c6ca3bd0e02d794916d38ec0c7f4d9ef018268c2087eea5c6f07dfc260

Contents?: true

Size: 1.83 KB

Versions: 8

Compression:

Stored size: 1.83 KB

Contents

module Zype
  module Base
    # Any playlist nested routes will inherit from this class
    class Playlists < Zype::BaseModel
      # Returns all objects for given class
      #
      # @param playlist_id [String] the ID of the playlist
      # @return [Array<Hash>] the objects returned from the API
      def all(playlist_id:)
        client.execute(method: :get, path: "/playlists/#{playlist_id}/#{path}")
      end

      # Returns object matching ID
      #
      # @param playlist_id [String] the ID of the playlist
      # @param id [String] the ID of the object
      # @return [Hash] the object returned from the API
      def find(playlist_id:, id:)
        client.execute(method: :get, path: "/playlists/#{playlist_id}/#{path}/#{id}")
      end

      # Creates a new object via the API.
      #
      # @param playlist_id [String] ID of the playlist to assign to the object
      # @param params [Hash] the properties of the object
      # @return [Hash] the newly created object
      def create(playlist_id:, params:)
        client.execute(method: :post, path: "/playlists/#{playlist_id}/#{path}", params: params)
      end

      # Updates an existing object via the API
      #
      # @param playlist_id [String] the ID of the playlist
      # @param params [Hash] the properties to be updated
      # @return [Hash] the updated object
      def update(playlist_id:, id:, params:)
        client.execute(method: :put, path: "/playlists/#{playlist_id}/#{path}/#{id}", params: params)
      end

      # Deletes an existing object via the API
      #
      # @param playlist_id [String] the ID of the playlist
      # @param id [String] the ID of the object
      # @return [Hash] the deleted object
      def delete(playlist_id:, id:)
        client.execute(method: :delete, path: "/playlists/#{playlist_id}/#{path}/#{id}")
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
zype-0.20.0 lib/zype/models/base/playlists.rb
zype-0.19.0 lib/zype/models/base/playlists.rb
zype-0.18.0 lib/zype/models/base/playlists.rb
zype-0.17.0 lib/zype/models/base/playlists.rb
zype-0.16.1 lib/zype/models/base/playlists.rb
zype-0.16.0 lib/zype/models/base/playlists.rb
zype-0.15.0 lib/zype/models/base/playlists.rb
zype-0.14.0 lib/zype/models/base/playlists.rb