Class: Shop

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/shop.rb,
lib/generators/shopqi_app/templates/app/models/shop.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_for_shopqi_oauth(data) ⇒ Object



4
5
6
7
8
9
# File 'app/models/shop.rb', line 4

def self.find_for_shopqi_oauth(data)
  shop_data = data.extra.raw_info.shop
  shop = where(shop_id: shop_data.id).first_or_create! name: shop_data.name, shopqi_domain: shop_data.shopqi_domain
  shop.access_token = data.credentials.token
  shop.tap(&:save)
end

Instance Method Details

#admin_urlObject

后台



15
16
17
# File 'app/models/shop.rb', line 15

def admin_url # 后台
  "#{SecretSetting.shopqi_domain.protocol}#{self.shopqi_domain}/admin"
end

#front_urlObject

前台



19
20
21
# File 'app/models/shop.rb', line 19

def front_url # 前台
  "http://#{self.shopqi_domain}"
end

#use_shopkitObject



11
12
13
# File 'app/models/shop.rb', line 11

def use_shopkit
  Shopkit.setup url: self.shopqi_domain, access_token: self.access_token
end