module Trubl::API::Me

Public Instance Methods

friends(order=nil, per_page=nil, page=nil) click to toggle source

returns Array of Trubl::User instances or nil

# File lib/trubl/api/me.rb, line 55
def friends(order=nil, per_page=nil, page=nil)
  response = get("me/friends", query: {order: order, per_page: per_page, page: page})
  Trubl::Users.new.from_response(response)
end
get_me() click to toggle source

implements developer.tout.com/api/me-api/apimethod/retrieve-authenticated-user returns Trubl::User instance or nil

# File lib/trubl/api/me.rb, line 11
def get_me
  Trubl::User.new.from_response(get("me"))
end
get_my_authorizations() click to toggle source

implements me/authorizations

# File lib/trubl/api/me.rb, line 30
def get_my_authorizations
  response = get("me/authorizations")
  Trubl::Authorizations.new.from_response(response)
end
get_my_fb_sharing_settings() click to toggle source

implements developer.tout.com/api/me-api/apimethod/retrieve-sharing-settings

# File lib/trubl/api/me.rb, line 36
def get_my_fb_sharing_settings
  response = get("me/sharing/facebook")
  JSON.parse(response.body)
end
get_my_liked_touts(order="most_recent_first", per_page=nil, page=nil) click to toggle source

returns Array of Trubl::Tout instances or nil

# File lib/trubl/api/me.rb, line 49
def get_my_liked_touts(order="most_recent_first", per_page=nil, page=nil)
  response = get("me/likes", query: {order: order, per_page: per_page, page: page})
  Trubl::Touts.new.from_response(response)
end
get_my_touts(order="most_recent_first", per_page=nil, page=nil) click to toggle source

implements developer.tout.com/api/me-api/apimethod/retrieve-list-touts-authenticated-user returns Array of Trubl::Tout instances or nil

# File lib/trubl/api/me.rb, line 43
def get_my_touts(order="most_recent_first", per_page=nil, page=nil)
  response = get("me/touts", query: {order: order, per_page: per_page, page: page})
  Trubl::Touts.new.from_response(response)
end
update_me(params={}) click to toggle source

TODO update_me should return meaningful exceptions instead of nil

# File lib/trubl/api/me.rb, line 16
def update_me(params={})
  return nil if params.blank? or params[:user].blank?

  allowed_properties = [:email, :password, :password_confirmation, :username, :avatar, :fullname, :location, :bio, :headline]
  unallowed_properties = params[:user].keys.map(&:to_sym) - allowed_properties

  raise "#{unallowed_properties.join(', ')} are not supported" if unallowed_properties.present?

  response = put("me", {body: params})

  Trubl::User.new.from_response(response)
end
widgets(order=nil, per_page=nil, page=nil) click to toggle source

order, per_page, page arent supported at the moment

# File lib/trubl/api/me.rb, line 61
def widgets(order=nil, per_page=nil, page=nil)
  response = get("me/widgets")
  Trubl::Widgets.new.from_response(response)
end