Class: Zype::Base::Categories

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

Overview

Any categories nested routes will inherit from this class

Direct Known Subclasses

CategoryContentRules

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(category_id:) ⇒ Array<Hash>

Returns all objects for given class

Parameters:

  • category_id (String)

    the ID of the category

Returns:

  • (Array<Hash>)

    the objects returned from the API



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

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

#create(category_id:, params:) ⇒ Hash

Creates a new object via the API.

Parameters:

  • category_id (String)

    ID of the category 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/categories.rb', line 27

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

#delete(category_id:, id:) ⇒ Hash

Deletes an existing object via the API

Parameters:

  • category_id (String)

    the ID of the category

  • id (String)

    the ID of the object

Returns:

  • (Hash)

    the deleted object



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

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

#find(category_id:, id:) ⇒ Hash

Returns object matching ID

Parameters:

  • category_id (String)

    the ID of the category

  • id (String)

    the ID of the object

Returns:

  • (Hash)

    the object returned from the API



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

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

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

Updates an existing object via the API

Parameters:

  • category_id (String)

    the ID of the category

  • params (Hash)

    the properties to be updated

Returns:

  • (Hash)

    the updated object



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

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