Method: Shopifydev::Shop#initialize
- Defined in:
- lib/shopifydev/shop.rb
#initialize(credentials) ⇒ Shop
Returns a new instance of Shop.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/shopifydev/shop.rb', line 8 def initialize(credentials) @credentials = credentials @logger = Logger.new(STDOUT) ShopifyAPI::Base.clear_session if credentials['token'] session = ShopifyAPI::Session.new(credentials['url'], credentials['token']) session.valid? # returns true ShopifyAPI::Base.activate_session(session) else ShopifyAPI::Base.site = "https://" + credentials['api_key'] + ':' + credentials['password'] + '@' + credentials['url'] + '/admin' logger.debug("set shopify site to #{ShopifyAPI::Base.site}") end end |