Sha256: 4b15d50563fd417cdf8baeac0c5e18670ae678ff47d300816a0866ba4f58ed43
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
require 'uri' module Voucherify module Service class Products attr_reader :client def initialize(client) @client = client end def create(product) @client.post('/products', product.to_json) end def get(product_id) @client.get("/products/#{ERB::Util.url_encode(product_id)}") end def update(product) @client.put("/products/#{ERB::Util.url_encode(product['id'] || product[:id])}", product.to_json) end def delete(product_id) @client.delete("/products/#{ERB::Util.url_encode(product_id)}") end def list(query = {}) @client.get('/products', query) end def create_sku(product_id, sku) @client.post("/products/#{ERB::Util.url_encode(product_id)}/skus", sku.to_json) end def get_sku(product_id, sku_id) @client.get("/products/#{ERB::Util.url_encode(product_id)}/skus/#{ERB::Util.url_encode(sku_id)}") end 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 def delete_sku(product_id, sku_id) @client.delete("/products/#{ERB::Util.url_encode(product_id)}/skus/#{ERB::Util.url_encode(sku_id)}") end def list_skus(product_id) @client.get("/products/#{ERB::Util.url_encode(product_id)}/skus") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
voucherify-4.1.0 | lib/voucherify/service/products.rb |
voucherify-4.0.0 | lib/voucherify/service/products.rb |