lib/codewars_api/user.rb in codewars_api-0.1.1 vs lib/codewars_api/user.rb in codewars_api-0.2.1
- old
+ new
@@ -1,10 +1,12 @@
module CodewarsApi
class User
- def initialize(username)
- fail 'Username is not set' unless username
- @response = RequestHelper.get("#{CodewarsApi::API_URL}/users/#{username}")
+ include Common
+
+ def initialize(id_or_username)
+ fail 'Username or id is not set' unless id_or_username
+ @response = RequestHelper.get("#{CodewarsApi::API_URL}/users/#{id_or_username}")
end
def username
@response.to_h['username']
end
@@ -41,12 +43,8 @@
@response.to_h['codeChallenges'].andand['totalAuthored']
end
def katas_completed
@response.to_h['codeChallenges'].andand['totalCompleted']
- end
-
- def to_h
- @response.to_h
end
end
end