class OmniAuth::Strategies::Yhd
Public Instance Methods
client()
click to toggle source
# File lib/omniauth/strategies/yhd.rb, line 33 def client ::OAuth2::YhdClient.new(options.client_id, options.client_secret, deep_symbolize(options.client_options)) end
raw_info()
click to toggle source
# File lib/omniauth/strategies/yhd.rb, line 37 def raw_info access_token.options[:mode] = :query @raw_info ||= ::OAuth2::Response.new(conn.post('/app/api/rest/router', signed_params), parse: :json).parsed['response']['storeMerchantStoreInfo'] rescue {} end
Private Instance Methods
conn()
click to toggle source
# File lib/omniauth/strategies/yhd.rb, line 44 def conn @conn ||= Faraday.new(url: "http://openapi.yhd.com") do |b| b.response :logger b.adapter :typhoeus end end
params()
click to toggle source
# File lib/omniauth/strategies/yhd.rb, line 51 def params { method: 'yhd.store.get', sessionKey: access_token.token, appKey: client.id, timestamp: timestamp, format: 'json', ver: '1.0' } end
signed_params()
click to toggle source
# File lib/omniauth/strategies/yhd.rb, line 62 def signed_params rand = client.secret + params.sort.flatten.join + client.secret token = Digest::MD5.hexdigest(rand) params.merge(sign: token)# 數字簽名 end
timestamp()
click to toggle source
# File lib/omniauth/strategies/yhd.rb, line 68 def timestamp # 时间戳 Time.now.strftime("%Y-%m-%d %H:%M:%S") end