Module: X::Objects::Actions::Lists

Included in:
X::Objects::API
Defined in:
x-objects/lib/x/objects/actions/lists.rb

Overview

Create, update, delete, follow, and pin lists as the authenticated user

Internal to x-objects: X::Objects::API includes it, and its methods are public API of the client that includes API, but the module is only how they are grouped, and some of them need the methods of another, so include API rather than this module alone.

Instance Method Summary collapse

Instance Method Details

#add_list_member(list, user) ⇒ Boolean

Add a member to a list as the authenticated user

Examples:

Add a member to a list

client.add_list_member("1234567890", user)

Parameters:

  • list (List, String, Integer) —

    the list or its identifier

  • user (User, String, Integer) —

    the user or their identifier

Returns:

  • (Boolean) —

    true if the user is now a member



62
63
64
# File 'x-objects/lib/x/objects/actions/lists.rb', line 62

def add_list_member(list, user)
  List.from_id(list, client: self).add_member(user)
end

#create_list(name, **params) ⇒ List

Create a list owned by the authenticated user

Examples:

Create a private list

client.create_list("Rubyists", private: true)

Parameters:

  • name (String) —

    the name of the list

  • params (Hash) —

    additional request body fields: description and private

Returns:

  • (List) —

    the created list, holding only its identifier and name

Raises:



26
27
28
# File 'x-objects/lib/x/objects/actions/lists.rb', line 26

def create_list(name, **params)
  List.create(name, client: self, **params)
end

#delete_list(list) ⇒ Boolean

Delete a list as the authenticated user

Examples:

Delete a list

client.delete_list("1234567890")

Parameters:

  • list (List, String, Integer) —

    the list or its identifier

Returns:

  • (Boolean) —

    true if the list was deleted



50
51
52
# File 'x-objects/lib/x/objects/actions/lists.rb', line 50

def delete_list(list)
  List.delete(list, client: self)
end

#follow_list(list) ⇒ Boolean

Follow a list as the authenticated user

Examples:

Follow a list

client.follow_list("1234567890")

Parameters:

  • list (List, String, Integer) —

    the list or its identifier

Returns:

  • (Boolean) —

    true if the authenticated user now follows the list



85
86
87
# File 'x-objects/lib/x/objects/actions/lists.rb', line 85

def follow_list(list)
  User.from_id(current_user_id, client: self).follow_list(list)
end

#pin_list(list) ⇒ Boolean

Pin a list as the authenticated user

Examples:

Pin a list

client.pin_list("1234567890")

Parameters:

  • list (List, String, Integer) —

    the list or its identifier

Returns:

  • (Boolean) —

    true if the authenticated user has pinned the list



107
108
109
# File 'x-objects/lib/x/objects/actions/lists.rb', line 107

def pin_list(list)
  User.from_id(current_user_id, client: self).pin_list(list)
end

#remove_list_member(list, user) ⇒ Boolean

Remove a member from a list as the authenticated user

Examples:

Remove a member from a list

client.remove_list_member("1234567890", user)

Parameters:

  • list (List, String, Integer) —

    the list or its identifier

  • user (User, String, Integer) —

    the user or their identifier

Returns:

  • (Boolean) —

    true if the user is no longer a member



74
75
76
# File 'x-objects/lib/x/objects/actions/lists.rb', line 74

def remove_list_member(list, user)
  List.from_id(list, client: self).remove_member(user)
end

#unfollow_list(list) ⇒ Boolean

Unfollow a list as the authenticated user

Examples:

Unfollow a list

client.unfollow_list("1234567890")

Parameters:

  • list (List, String, Integer) —

    the list or its identifier

Returns:

  • (Boolean) —

    true if the authenticated user no longer follows the list



96
97
98
# File 'x-objects/lib/x/objects/actions/lists.rb', line 96

def unfollow_list(list)
  User.from_id(current_user_id, client: self).unfollow_list(list)
end

#unpin_list(list) ⇒ Boolean

Unpin a list as the authenticated user

Examples:

Unpin a list

client.unpin_list("1234567890")

Parameters:

  • list (List, String, Integer) —

    the list or its identifier

Returns:

  • (Boolean) —

    true if the authenticated user no longer has the list pinned



118
119
120
# File 'x-objects/lib/x/objects/actions/lists.rb', line 118

def unpin_list(list)
  User.from_id(current_user_id, client: self).unpin_list(list)
end

#update_list(list, **params) ⇒ Boolean

Update the name, description, or privacy of a list as the authenticated user

Examples:

Make a list private

client.update_list("1234567890", private: true)

Parameters:

  • list (List, String, Integer) —

    the list or its identifier

  • params (Hash) —

    the request body fields to change: name, description, and private

Returns:

  • (Boolean) —

    true if the list was updated

Raises:

  • (ArgumentError) —

    if no field is given to change, before any request



39
40
41
# File 'x-objects/lib/x/objects/actions/lists.rb', line 39

def update_list(list, **params)
  List.update(list, client: self, **params)
end