Permalink
Browse files

Force SSL API calls per #30

  • Loading branch information...
maxbeizer committed Aug 7, 2014
1 parent 94ccd3a commit 6596fb53d075ac1af8f2efa1ee2e5831f38983d7
Showing with 1 addition and 43 deletions.
  1. +1 −15 lib/fitgem/client.rb
  2. +0 −28 spec/fitgem_spec.rb
View
@@ -30,11 +30,6 @@ class Client
# @return [String]
attr_accessor :api_version
# Sets or gets the ssl settings
#
# @return [Boolean]
attr_accessor :ssl
# Sets or gets the api unit system to be used in API calls
#
# @return [String]
@@ -103,8 +98,6 @@ def initialize(opts)
@consumer_key = opts[:consumer_key]
@consumer_secret = opts[:consumer_secret]
@ssl = opts[:ssl]
@token = opts[:token]
@secret = opts[:secret]
@@ -182,19 +175,12 @@ def authentication_request_token(opts={})
consumer.options[:authorize_path] = '/oauth/authenticate'
request_token(opts)
end
# The protocol to be used for the API requests
#
# @return [String], 'http', or 'https' if ssl == true
def protocol
ssl ? "https" : "http"
end
private
def consumer
@consumer ||= OAuth::Consumer.new(@consumer_key, @consumer_secret, {
:site => "#{protocol}://api.fitbit.com",
:site => 'https://api.fitbit.com',
:proxy => @proxy
})
end
View
@@ -32,33 +32,5 @@
it 'should default to a user id of \'-\', the currently-logged in user' do
@client.user_id.should == '-'
end
it "returns the protocol to be used" do
@client.protocol.should eq "http"
end
describe "ssl" do
it "should expose the ssl setting" do
@client.ssl.should eq nil
end
context "when true" do
let(:client) { Fitgem::Client.new({
:consumer_key => '12345',
:consumer_secret => '67890',
:ssl => true
}) }
it "can set the ssl setting to true" do
client.ssl.should be_true
end
it "uses https protocol" do
client.protocol.should eq "https"
end
end
end
end
end

0 comments on commit 6596fb5

Please sign in to comment.