Class: WooCommerce::ProductCategoriesResource
- Inherits:
-
Resource
- Object
- Resource
- WooCommerce::ProductCategoriesResource
show all
- Defined in:
- lib/woo_commerce/resources/product_categories.rb
Instance Attribute Summary
Attributes inherited from Resource
#client
Instance Method Summary
collapse
Methods inherited from Resource
#initialize
Instance Method Details
#create(name:, **params) ⇒ Object
13
14
15
16
|
# File 'lib/woo_commerce/resources/product_categories.rb', line 13
def create(name:, **params)
attributes = {name: name}
ProductCategory.new post_request("products/categories", body: attributes.merge(params)).body
end
|
#delete(id:) ⇒ Object
22
23
24
25
|
# File 'lib/woo_commerce/resources/product_categories.rb', line 22
def delete(id:)
response = delete_request("products/categories/#{id}", params: {force: true})
return true if response.success?
end
|
#list(**params) ⇒ Object
4
5
6
7
|
# File 'lib/woo_commerce/resources/product_categories.rb', line 4
def list(**params)
response = get_request("products/categories", params: params)
Collection.from_response(response, type: ProductCategory)
end
|
#retrieve(id:) ⇒ Object
9
10
11
|
# File 'lib/woo_commerce/resources/product_categories.rb', line 9
def retrieve(id:)
ProductCategory.new get_request("products/categories/#{id}").body
end
|
#update(id:, **params) ⇒ Object
18
19
20
|
# File 'lib/woo_commerce/resources/product_categories.rb', line 18
def update(id:, **params)
ProductCategory.new put_request("products/categories/#{id}", body: params).body
end
|