lib/statraptor/client/users.rb in statraptor-0.2.2 vs lib/statraptor/client/users.rb in statraptor-0.2.3
- old
+ new
@@ -10,8 +10,20 @@
end
def get_users
get("/api/v1/users.json")
end
+
+ def find_or_create_user(params = {})
+ users = get_users
+ user = users.detect{|u| (u['email'] == params[:email]) && (u['chargify_api_key'] == params[:chargify_api_key])}
+ !!user ? user : create_user(params)
+ end
+
+ # This StatRaptor API endpoint isn't available yet
+ def get_user(user_credentials)
+ raise NotImplementedError
+ get("/api/v1/users/#{user_credentials}.json")
+ end
end
end
end