class Vendor::Product
Attributes
block[R]
buy[R]
exists[R]
info[R]
params[R]
Public Class Methods
new(options, buy_class, &block)
click to toggle source
# File lib/project/product.rb, line 5 def initialize(options, buy_class, &block) # Set params and block @buy = buy_class @params = options @block = block # Raise argument error if id is not included raise ArgumentError, "VENDOR WARNING: You forgot to write in your item id. You can't sell item without an id." if @params.id == "no_id" raise ArgumentError, "VENDOR WARNING: You're missing your subscriptions shared secret. Subscriptions must have a shared secret." if @params.subscription && @params.secret == "no_secret" # Update product and set exists variable @info = Vendor::Info.new(@params) do |block| @exists = block.success @params[:sk_product] = block.response.products.first if block.success @block.call(block) unless @block.nil? end end
Public Instance Methods
bought?()
click to toggle source
# File lib/project/product.rb, line 58 def bought? @info.bought? end
description()
click to toggle source
# File lib/project/product.rb, line 50 def description @info.description end
exists?()
click to toggle source
# File lib/project/product.rb, line 54 def exists? @exists || false end
price()
click to toggle source
INFO METHODS
# File lib/project/product.rb, line 38 def price @info.price end
price_locale()
click to toggle source
# File lib/project/product.rb, line 42 def price_locale @info.price_locale end
purchase(&block)
click to toggle source
PURCHASE METHODS
# File lib/project/product.rb, line 27 def purchase(&block) @buy.purchase(@params) { |result| block.call(result)} end
restore(&block)
click to toggle source
# File lib/project/product.rb, line 31 def restore(&block) @buy.restore(@params) { |result| block.call(result)} end
subscribed?()
click to toggle source
# File lib/project/product.rb, line 66 def subscribed? @info.subscribed? end
subscription?()
click to toggle source
# File lib/project/product.rb, line 62 def subscription? @info.subscription? end
title()
click to toggle source
# File lib/project/product.rb, line 46 def title @info.title end