Class: Lomadee::Base
Instance Method Summary collapse
-
#initialize(application_id, sandbox = false) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(application_id, sandbox = false) ⇒ Base
Returns a new instance of Base.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/lomadee/base.rb', line 5 def initialize(application_id, sandbox = false) raise "You need to inform your :application_id" if application_id.nil? @env = (sandbox) ? 'sandbox' : 'bws' @application_id = application_id @uris = { :offers => "findOfferList", :products => "findProductList", :categories => "findCategoryList", :create_link => "createLinks" } @params = { :category => "categoryId", :product => "productId", :barcode => "barcode", :keyword => "keyword" } @data = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
31 32 33 34 35 36 37 38 39 |
# File 'lib/lomadee/base.rb', line 31 def method_missing(method, *args, &block) if @uris.map {|v, k| v }.include? method @data.merge!(args[0]) fetch_api(method) else @data.merge!({method => args[0]}) self end end |