class Twocheckout::Product
Public Class Methods
create(opts)
click to toggle source
Creates a new product and returns the Product
object
# File lib/twocheckout/product.rb, line 19 def self.create(opts) response = Twocheckout::API.request(:post, 'products/create_product', opts) find(:product_id => response['product_id']) end
find(opts)
click to toggle source
Finds product by ID and returns a Product
object
# File lib/twocheckout/product.rb, line 7 def self.find(opts) response = Twocheckout::API.request(:get, 'products/detail_product', opts) Product.new(response['product']) end
list(opts)
click to toggle source
Get product list in an array
# File lib/twocheckout/product.rb, line 45 def self.list(opts) response = Twocheckout::API.request(:get, 'products/list_products', opts) response['products'] end
with_product_id(product_id)
click to toggle source
# File lib/twocheckout/product.rb, line 12 def self.with_product_id(product_id) find(:product_id => product_id) end
Public Instance Methods
delete!()
click to toggle source
Deletes the product and returns the response
# File lib/twocheckout/product.rb, line 37 def delete! opts = {:product_id => self.product_id} Twocheckout::API.request(:post, 'products/delete_product', opts) end
update(opts)
click to toggle source
Updates product and returns a new Product
object
# File lib/twocheckout/product.rb, line 27 def update(opts) opts = opts.merge(:product_id => self.product_id) Twocheckout::API.request(:post, 'products/update_product', opts) response = Twocheckout::API.request(:get, 'products/detail_product', opts) Product.new(response['product']) end
Protected Instance Methods
_key()
click to toggle source
# File lib/twocheckout/product.rb, line 52 def _key self.product_id end