Skip to content

Commit 7866361

Browse files
committed
Second code climate cleanup
1 parent 2eae115 commit 7866361

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

lib/api/auth_api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class AuthApi < BaseApi
88
def get_auth_token
99
return nil unless verify_user_code && verify_env_vars
1010

11-
oauth_url = "#{API_URL}/#{API_VERSION}/#{OAUTH_PATH}"
11+
oauth_url = build_url(OAUTH_PATH, false)
1212

1313
post_data = "client_id=#{ENV['BUFFER_KEY']}&" +
1414
"client_secret=#{ENV['BUFFER_SECRET']}&" +

lib/api/helpers/api_helpers.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ def log_or_print(msg, method = :error)
1212
end
1313
end
1414

15+
def build_url(path, auth_token = true)
16+
url = "#{API_URL}/#{API_VERSION}/#{path}"
17+
url += "?access_token=#{@auth_token}" if auth_token
18+
end
19+
1520
def has_data?(response)
1621
response.present? && response.body.present?
1722
end

lib/api/profile_api.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ class ProfileApi < BaseApi
77

88
def get_profiles
99
return nil unless verify_token
10-
11-
profile_url = "#{API_URL}/#{API_VERSION}/#{PROFILES_PATH}?access_token=#{@auth_token}"
12-
get_get_response(profile_url)
10+
get_get_response( build_url(PROFILES_PATH) )
1311
end
1412
end

lib/api/user_api.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ def get_user_id
1111

1212
def get_user_json
1313
return nil unless verify_token
14-
15-
user_url = "#{API_URL}/#{API_VERSION}/#{USER_PATH}?access_token=#{@auth_token}"
16-
get_get_response(user_url)
14+
get_get_response( build_url(USER_PATH) )
1715
end
1816
end

0 commit comments

Comments
 (0)