Class: Zype::Base::Playlists

Inherits:
Zype::BaseModel show all
Defined in:
lib/zype/models/base/playlists.rb

Overview

Any playlist nested routes will inherit from this class

Direct Known Subclasses

PlaylistContentRules

Constant Summary

Constants inherited from Zype::BaseModel

Zype::BaseModel::ACCEPTED_KEYS

Instance Attribute Summary

Attributes inherited from Zype::BaseModel

#client, #path

Instance Method Summary collapse

Methods inherited from Zype::BaseModel

#auth=, #initialize

Constructor Details

This class inherits a constructor from Zype::BaseModel

Instance Method Details

#all(playlist_id:) ⇒ Array<Hash>

Returns all objects for given class

Parameters:

  • playlist_id (String)

    the ID of the playlist

Returns:

  • (Array<Hash>)

    the objects returned from the API



9
10
11
# File 'lib/zype/models/base/playlists.rb', line 9

def all(playlist_id:)
  client.execute(method: :get, path: "/playlists/#{playlist_id}/#{path}")
end

#create(playlist_id:, params:) ⇒ Hash

Creates a new object via the API.

Parameters:

  • playlist_id (String)

    ID of the playlist to assign to the object

  • params (Hash)

    the properties of the object

Returns:

  • (Hash)

    the newly created object



27
28
29
# File 'lib/zype/models/base/playlists.rb', line 27

def create(playlist_id:, params:)
  client.execute(method: :post, path: "/playlists/#{playlist_id}/#{path}", params: params)
end

#delete(playlist_id:, id:) ⇒ Hash

Deletes an existing object via the API

Parameters:

  • playlist_id (String)

    the ID of the playlist

  • id (String)

    the ID of the object

Returns:

  • (Hash)

    the deleted object



45
46
47
# File 'lib/zype/models/base/playlists.rb', line 45

def delete(playlist_id:, id:)
  client.execute(method: :delete, path: "/playlists/#{playlist_id}/#{path}/#{id}")
end

#find(playlist_id:, id:) ⇒ Hash

Returns object matching ID

Parameters:

  • playlist_id (String)

    the ID of the playlist

  • id (String)

    the ID of the object

Returns:

  • (Hash)

    the object returned from the API



18
19
20
# File 'lib/zype/models/base/playlists.rb', line 18

def find(playlist_id:, id:)
  client.execute(method: :get, path: "/playlists/#{playlist_id}/#{path}/#{id}")
end

#update(playlist_id:, id:, params:) ⇒ Hash

Updates an existing object via the API

Parameters:

  • playlist_id (String)

    the ID of the playlist

  • params (Hash)

    the properties to be updated

Returns:

  • (Hash)

    the updated object



36
37
38
# File 'lib/zype/models/base/playlists.rb', line 36

def update(playlist_id:, id:, params:)
  client.execute(method: :put, path: "/playlists/#{playlist_id}/#{path}/#{id}", params: params)
end