Sha256: 8046dc93f5c4f0697a33e5db4df94e0724edf63504dbf25e551e54efa9a08739
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
module Access class Request include HTTParty def get(path, api_type, options={}) set_format results = self.class.get(set_base(api_type) + path, headers: headers, query: options) handle_results(results) end def get_json(path, api_type, options={}) set_format results = self.class.get(set_base(api_type) + path, headers: headers.merge({ 'Content-Type' => 'application/json', 'Accept' => 'application/json'}), body: options) handle_results(results) end private def handle_results(results) Access.config.hashify == "true" ? results.hashify : results end def set_base(api_type) "https://#{ api_type }#{ Access.config.api_environment == 'production' ? '' : '-demo' }.adcrws.com/#{Access.config.api_version}" end def set_format raise Access::Error::InvalidResponseFormat unless [:json, :xml].include?(Access.config.format.to_sym) self.class.format Access.config.format.to_sym end def headers raise Access::Error::NoAccessToken unless Access.config.access_token {"Access-Token" => Access.config.access_token} end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
access-1.1.2 | lib/access/request.rb |