lib/DataSift/apiclient.rb in datasift-1.3.1 vs lib/DataSift/apiclient.rb in datasift-1.4.0
- old
+ new
@@ -25,13 +25,13 @@
#
# * +endpoint+ - The endpoint of the API call.
# * +params+ - The parameters to be passed along with the request.
# * +username+ - The username for the Auth header
# * +api_key+ - The API key for the Auth header
- def call(username, api_key, endpoint, params = {}, user_agent = 'DataSiftPHP/0.0')
+ def call(username, api_key, endpoint, params = {}, user_agent = 'DataSiftPHP/0.0', ssl = true)
# Build the full endpoint URL
- url = 'http://' + User::API_BASE_URL + endpoint
+ url = 'http' + (ssl ? 's' : '') + '://' + User::API_BASE_URL + endpoint
retval = {
'response_code' => 500,
'data' => { 'error' => 'Unknown error' },
'rate_limit' => -1,
@@ -45,9 +45,10 @@
# Success
retval['response_code'] = 200
# Parse the JSON response
retval['data'] = Yajl::Parser.parse(res)
+
# Rate limit headers
if (res.headers[:x_ratelimit_limit])
retval['rate_limit'] = res.headers[:x_ratelimit_limit]
end