Sha256: 5782e4c61bf7757ed05c65a3185ec24d2a3bd17b4473d105adfb258949530ac2
Contents?: true
Size: 725 Bytes
Versions: 19
Compression:
Stored size: 725 Bytes
Contents
module DHLEcommerceAPI class Authentication < ActiveResource::Base # self.prefix set in configuration.rb def self.get_token token = DHLEcommerceAPI.cache.read("DHLEcommerceAPI::AuthenticationToken") if token.present? return token else path = "/rest/v1/OAuth/AccessToken?clientId=#{DHLEcommerceAPI.config.client_id}&password=#{DHLEcommerceAPI.config.password}&returnFormat=json" response = connection.get(path) response_body = JSON.parse(response.body)["accessTokenResponse"] DHLEcommerceAPI.cache.write("DHLEcommerceAPI::AuthenticationToken", response_body["token"], {expires_in: 12.hours}) return response_body["token"] end end end end
Version data entries
19 entries across 19 versions & 1 rubygems