lib/vimeo_ruby/user.rb in vimeo_ruby-0.4.3 vs lib/vimeo_ruby/user.rb in vimeo_ruby-0.5.0

- old
+ new

@@ -1,24 +1,26 @@ module VimeoRuby class User < Base - attr_reader :vimeo_id, :video_collection, :available_for_hire, :bio, :can_work_remotely, :location, :name, :profile_link, :additional_info + attr_reader :video_collection, :available_for_hire, :bio, :can_work_remotely, :location, :name, :profile_link - def initialize(attrs: {}) - @vimeo_id = extract_vimeo_id_from_uri(attrs.delete("uri")) + def initialize(access_token: nil, attrs: {}) @available_for_hire = attrs.delete("available_for_hire") @bio = attrs.delete("bio") @can_work_remotely = attrs.delete("can_work_remotely") @location = attrs.delete("location") @name = attrs.delete("name") @profile_link = attrs.delete("link") @video_collection = nil - @additional_info = OpenStruct.new(attrs) + vimeo_uri_with_id = attrs.delete("uri") + super(access_token: access_token, vimeo_id: vimeo_uri_with_id, remaining_attrs: attrs) end - def self.get_user(user_id) - user_info = get("#{base_uri}/users/#{user_id}") - new(attrs: user_info) + class << self + def get_user(access_token: nil) + user_info = get("#{base_uri}/me", access_token: access_token) + new(access_token: access_token, attrs: user_info) + end end def base_uri self.class.base_uri end @@ -40,10 +42,11 @@ end private def retrieve_video_collection(query_params) - uploaded_videos_response = self.class.get("#{base_uri}/users/#{vimeo_id}/videos", query_params: query_params) + uploaded_videos_response = self.class.get("#{base_uri}/me/videos", query_params: query_params, access_token: access_token) + uploaded_videos = uploaded_videos_response["data"] UploadedVideoCollection.new(uploaded_videos) end end end