Module: Croudia::API::Friendships

Included in:
Client
Defined in:
lib/croudia/api/friendships.rb

Instance Method Summary collapse

Instance Method Details

#follow(user, params = {}) ⇒ Croudia::User #follow(params = {}) ⇒ Croudia::User

Follow a user

Overloads:

  • #follow(user, params = {}) ⇒ Croudia::User

    Parameters:

    • user (String, Integer, Croudia::User)

      User to follow

    • params (Hash) (defaults to: {})

      Additional query parameters

  • #follow(params = {}) ⇒ Croudia::User

    Parameters:

    • params (Hash) (defaults to: {})

      Query parameters

    Options Hash (params):

    • :screen_name (String)

      Screen name of user to follow

    • :user_id (String, Integer)

      ID of user to follow

Returns:

See Also:



19
20
21
22
23
# File 'lib/croudia/api/friendships.rb', line 19

def follow(user, params={})
  merge_user!(params, user)
  resp = post('/friendships/create.json', params)
  Croudia::User.new(resp)
end

#follower_ids(user = current_user, params = {}) ⇒ Croudia::Cursor<Integer> #follower_ids(params = {}) ⇒ Croudia::Cursor<Integer>

Follower ids of specified user

Overloads:

  • #follower_ids(user = current_user, params = {}) ⇒ Croudia::Cursor<Integer>

    Parameters:

    • user (String, Integer, Croudia::User) (defaults to: current_user)

      User to look up followers of

    • params (Hash) (defaults to: {})

      Additional query parameters

    Options Hash (params):

    • :cursor (String, Integer)

      Cursor number, -1 to get the first page

  • #follower_ids(params = {}) ⇒ Croudia::Cursor<Integer>

    Parameters:

    • params (Hash) (defaults to: {})

      Query parameters

    Options Hash (params):

    • :cursor (String, Integer)

      Cursor number, -1 to get the first page

    • :screen_name (String)

      Screen name of the user to look up followers of

    • :user_id (String, Integer)

      ID of the user to look up followers of

Returns:

See Also:



112
113
114
115
116
# File 'lib/croudia/api/friendships.rb', line 112

def follower_ids(user=current_user, params={})
  merge_user!(params, user)
  resp = get('/followers/ids.json', params)
  Croudia::Cursor.new(:ids, nil, resp)
end

#followers(user = current_user, params = {}) ⇒ Croudia::Cursor<Croudia::User> #followers(params = {}) ⇒ Croudia::Cursor<Croudia::User>

Followers of specified user

Overloads:

  • #followers(user = current_user, params = {}) ⇒ Croudia::Cursor<Croudia::User>

    Parameters:

    • user (String, Integer, Croudia::User) (defaults to: current_user)

      User to look up followers of

    • params (Hash) (defaults to: {})

      Additional query parameters

    Options Hash (params):

    • :cursor (String, Integer)

      Cursor number, -1 to get the first page

    • :trim_user (String)

      Set true to return compact user objects

  • #followers(params = {}) ⇒ Croudia::Cursor<Croudia::User>

    Parameters:

    • params (Hash) (defaults to: {})

      Query parameters

    Options Hash (params):

    • :cursor (String, Integer)

      Cursor number, -1 to get the first page

    • :screen_name (String)

      Screen name of the user to look up followers of

    • :trim_user (String)

      Set true to return compact user objects

    • :user_id (String, Integer)

      ID of the user to look up followers of

Returns:

See Also:



154
155
156
157
158
# File 'lib/croudia/api/friendships.rb', line 154

def followers(user=current_user, params={})
  merge_user!(params, user)
  resp = get('/followers/list.json', params)
  Croudia::Cursor.new(:users, Croudia::User, resp)
end

#friend_ids(user = current_user, params = {}) ⇒ Croudia::Cursor<Integer> #friend_ids(params = {}) ⇒ Croudia::Cursor<Integer>

Friend ids of specified user

Overloads:

  • #friend_ids(user = current_user, params = {}) ⇒ Croudia::Cursor<Integer>

    Parameters:

    • user (String, Integer, Croudia::User) (defaults to: current_user)

      User to look up friends of

    • params (Hash) (defaults to: {})

      Additional query parameters

    Options Hash (params):

    • :cursor (String, Integer)

      Cursor number, -1 to get the first page

  • #friend_ids(params = {}) ⇒ Croudia::Cursor<Integer>

    Parameters:

    • params (Hash) (defaults to: {})

      Query parameters

    Options Hash (params):

    • :cursor (String, Integer)

      Cursor number, -1 to get the first page

    • :screen_name (String)

      Screen name of the user to look up friends of

    • :user_id (String, Integer)

      ID of the user to look up friends of

Returns:

See Also:



93
94
95
96
97
# File 'lib/croudia/api/friendships.rb', line 93

def friend_ids(user=current_user, params={})
  merge_user!(params, user)
  resp = get('/friends/ids.json', params)
  Croudia::Cursor.new(:ids, nil, resp)
end

#friends(user = current_user, params = {}) ⇒ Croudia::Cursor<Croudia::User> #friends(params = {}) ⇒ Croudia::Cursor<Croudia::User>

Friends of specified user

Overloads:

  • #friends(user = current_user, params = {}) ⇒ Croudia::Cursor<Croudia::User>

    Parameters:

    • user (String, Integer, Croudia::User) (defaults to: current_user)

      User to look up friends of

    • params (Hash) (defaults to: {})

      Additional query parameters

    Options Hash (params):

    • :cursor (String, Integer)

      Cursor number, -1 to get the first page

    • :trim_user (String)

      Set true to return compact user objects

  • #friends(params = {}) ⇒ Croudia::Cursor<Croudia::User>

    Parameters:

    • params (Hash) (defaults to: {})

      Query parameters

    Options Hash (params):

    • :cursor (String, Integer)

      Cursor number, -1 to get the first page

    • :screen_name (String)

      Screen name of the user to look up friends of

    • :trim_user (String)

      Set true to return compact user objects

    • :user_id (String, Integer)

      ID of the user to look up friends of

Returns:

See Also:



133
134
135
136
137
# File 'lib/croudia/api/friendships.rb', line 133

def friends(user=current_user, params={})
  merge_user!(params, user)
  resp = get('/friends/list.json', params)
  Croudia::Cursor.new(:users, Croudia::User, resp)
end

#friendship(source, target, params = {}) ⇒ Croudia::Relationship #friendship(params = {}) ⇒ Croudia::Relationship

Show relationship between two users

Overloads:

  • #friendship(source, target, params = {}) ⇒ Croudia::Relationship

    Parameters:

    • source (String, Integer, Croudia::User)

      Source of the relationship

    • target (String, Integer, Croudia::User)

      Target of the relationship

    • params (Hash) (defaults to: {})

      Additional query parameters

  • #friendship(params = {}) ⇒ Croudia::Relationship

    Parameters:

    • params (Hash) (defaults to: {})

      Query parameters

    Options Hash (params):

    • :source_id (String, Integer)

      ID of the source user

    • :source_screen_name (String)

      Screen name of the source user

    • :target_id (String, Integer)

      ID of the target user

    • :target_screen_name (String)

      Screen name of the target user

Returns:

See Also:



56
57
58
59
60
61
# File 'lib/croudia/api/friendships.rb', line 56

def friendship(source, target={}, params={})
  merge_user!(params, source, :source_screen_name, :source_id)
  merge_user!(params, target, :target_screen_name, :target_id)
  resp = get('/friendships/show.json', params)
  Croudia::Relationship.new(resp)
end

#friendships(*users, params = {}) ⇒ Array<Croudia::User> #friendships(params = {}) ⇒ Array<Croudia::User>

Lookup friendships between the current user and others

Overloads:

  • #friendships(*users, params = {}) ⇒ Array<Croudia::User>

    Parameters:

    • users (String, Integer, Croudia::User)

      Users to lookup friendships to them

    • params (Hash) (defaults to: {})

      Additional query parameters

  • #friendships(params = {}) ⇒ Array<Croudia::User>

    Parameters:

    • params (Hash) (defaults to: {})

      Query parameters

    Options Hash (params):

    • :screen_name (String)

      Comma-separated screen names

Returns:

See Also:



74
75
76
77
78
# File 'lib/croudia/api/friendships.rb', line 74

def friendships(*args)
  merge_users!(params = {}, args)
  resp = get('/friendships/lookup.json', params)
  objects(Croudia::User, resp)
end

#unfollow(user, params = {}) ⇒ Croudia::User #unfollow(params = {}) ⇒ Croudia::User

Unfollow a user

Overloads:

  • #unfollow(user, params = {}) ⇒ Croudia::User

    Parameters:

    • user (String, Integer, Croudia::User)

      User to unfollow

    • params (Hash) (defaults to: {})

      Additional query parameters

  • #unfollow(params = {}) ⇒ Croudia::User

    Parameters:

    • params (Hash) (defaults to: {})

      Query parameters

    Options Hash (params):

    • :screen_name (String)

      Screen name of user to unfollow

    • :user_id (String, Integer)

      ID of user to unfollow

Returns:

See Also:



36
37
38
39
40
# File 'lib/croudia/api/friendships.rb', line 36

def unfollow(user, params={})
  merge_user!(params, user)
  resp = post('/friendships/destroy.json', params)
  Croudia::User.new(resp)
end