class Voucherify::Service::Products
Attributes
client[R]
Public Class Methods
new(client)
click to toggle source
# File lib/voucherify/service/products.rb, line 8 def initialize(client) @client = client end
Public Instance Methods
create(product)
click to toggle source
# File lib/voucherify/service/products.rb, line 12 def create(product) @client.post('/products', product.to_json) end
create_sku(product_id, sku)
click to toggle source
# File lib/voucherify/service/products.rb, line 32 def create_sku(product_id, sku) @client.post("/products/#{ERB::Util.url_encode(product_id)}/skus", sku.to_json) end
delete(product_id)
click to toggle source
# File lib/voucherify/service/products.rb, line 24 def delete(product_id) @client.delete("/products/#{ERB::Util.url_encode(product_id)}") end
delete_sku(product_id, sku_id)
click to toggle source
# File lib/voucherify/service/products.rb, line 44 def delete_sku(product_id, sku_id) @client.delete("/products/#{ERB::Util.url_encode(product_id)}/skus/#{ERB::Util.url_encode(sku_id)}") end
get(product_id)
click to toggle source
# File lib/voucherify/service/products.rb, line 16 def get(product_id) @client.get("/products/#{ERB::Util.url_encode(product_id)}") end
get_sku(product_id, sku_id)
click to toggle source
# File lib/voucherify/service/products.rb, line 36 def get_sku(product_id, sku_id) @client.get("/products/#{ERB::Util.url_encode(product_id)}/skus/#{ERB::Util.url_encode(sku_id)}") end
list(query = {})
click to toggle source
# File lib/voucherify/service/products.rb, line 28 def list(query = {}) @client.get('/products', query) end
list_skus(product_id)
click to toggle source
# File lib/voucherify/service/products.rb, line 48 def list_skus(product_id) @client.get("/products/#{ERB::Util.url_encode(product_id)}/skus") end
update(product)
click to toggle source
# File lib/voucherify/service/products.rb, line 20 def update(product) @client.put("/products/#{ERB::Util.url_encode(product['id'] || product[:id])}", product.to_json) end
update_sku(product_id, sku)
click to toggle source
# File lib/voucherify/service/products.rb, line 40 def update_sku(product_id, sku) @client.put("/products/#{ERB::Util.url_encode(product_id)}/skus/#{ERB::Util.url_encode(sku['id'] || sku[:id])}", sku.to_json) end