Class: WooCommerce::ProductsResource
- Inherits:
-
Resource
- Object
- Resource
- WooCommerce::ProductsResource
show all
- Defined in:
- lib/woo_commerce/resources/products.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/products.rb', line 13
def create(name:, **params)
attributes = {name: name}
Product.new post_request("products", body: attributes.merge(params)).body
end
|
#delete(id:) ⇒ Object
22
23
24
25
|
# File 'lib/woo_commerce/resources/products.rb', line 22
def delete(id:)
response = delete_request("products/#{id}", params: {force: true})
return true if response.success?
end
|
#list(**params) ⇒ Object
4
5
6
7
|
# File 'lib/woo_commerce/resources/products.rb', line 4
def list(**params)
response = get_request("products", params: params)
Collection.from_response(response, type: Product)
end
|
#retrieve(id:) ⇒ Object
9
10
11
|
# File 'lib/woo_commerce/resources/products.rb', line 9
def retrieve(id:)
Product.new get_request("products/#{id}").body
end
|
#update(id:, **params) ⇒ Object
18
19
20
|
# File 'lib/woo_commerce/resources/products.rb', line 18
def update(id:, **params)
Product.new put_request("products/#{id}", body: params).body
end
|