Module: LoyverseApi::Endpoints::Categories

Included in:
Client
Defined in:
lib/loyverse_api/endpoints/categories.rb

Instance Method Summary collapse

Instance Method Details

#create_category(name:, color: nil) ⇒ Hash

Create a new category

Parameters:

  • name (String) —

    Category name

  • color (String) (defaults to: nil) —

    Color code (e.g., "ORANGE", "RED", "BLUE")

Returns:

  • (Hash) —

    Created category details



28
29
30
31
32
33
# File 'lib/loyverse_api/endpoints/categories.rb', line 28

def create_category(name:, color: nil)
  body = { name: name }
  body[:color] = color if color

  post("categories", body: body)
end

#delete_category(category_id) ⇒ Hash

Delete a category

Parameters:

  • category_id (String) —

    UUID of the category

Returns:

  • (Hash) —

    Response



38
39
40
# File 'lib/loyverse_api/endpoints/categories.rb', line 38

def delete_category(category_id)
  delete("categories/#{category_id}")
end

#get_category(category_id) ⇒ Hash

Get a specific category by ID

Parameters:

  • category_id (String) —

    UUID of the category

Returns:

  • (Hash) —

    Category details



7
8
9
# File 'lib/loyverse_api/endpoints/categories.rb', line 7

def get_category(category_id)
  get("categories/#{category_id}")
end

#list_categories(limit: 250, cursor: nil) ⇒ Hash

List all categories

Parameters:

  • limit (Integer) (defaults to: 250) —

    Maximum number of results per page (default: 250)

  • cursor (String) (defaults to: nil) —

    Pagination cursor for next page

Returns:

  • (Hash) —

    Response with categories array



15
16
17
18
19
20
21
22
# File 'lib/loyverse_api/endpoints/categories.rb', line 15

def list_categories(limit: 250, cursor: nil)
  params = {
    limit: limit,
    cursor: cursor
  }.compact

  get("categories", params: params)
end