Module: LoyverseApi::Endpoints::Categories
- Included in:
- Client
- Defined in:
- lib/loyverse_api/endpoints/categories.rb
Instance Method Summary collapse
-
#create_category(name:, color: nil) ⇒ Hash
Create a new category.
-
#delete_category(category_id) ⇒ Hash
Delete a category.
-
#get_category(category_id) ⇒ Hash
Get a specific category by ID.
-
#list_categories(limit: 250, cursor: nil) ⇒ Hash
List all categories.
Instance Method Details
#create_category(name:, color: nil) ⇒ Hash
Create a new category
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
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
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
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 |