class Redd::Models::LiveThread
Represents a live thread.
Public Class Methods
Get a LiveThread
from its id. @param id [String] the id @return [LiveThread]
# File lib/redd/models/live_thread.rb, line 16 def self.from_id(client, id) new(client, id: id) end
Public Instance Methods
Configure the settings of this live thread @param params [Hash] a list of params to send with the request @option params [String] :description the new description @option params [Boolean] :nsfw whether the thread is for users 18 and above @option params [String] :resources the new resources @option params [String] :title the thread title
# File lib/redd/models/live_thread.rb, line 37 def configure(**params) @client.post("/api/live/#{get_attribute(:id)}/edit", params) end
@return [Array<User>] the contributors to this thread
# File lib/redd/models/live_thread.rb, line 48 def contributors @client.get("/live/#{get_attribute(:id)}/contributors").body[0][:data].map do |user| User.new(@client, user) end end
Returns all discussions that link to this live thread. @param params [Hash] a list of params to send with the request @option params [String] :after return results after the given fullname @option params [String] :before return results before the given fullname @option params [Integer] :count the number of items already seen in the listing @option params [1..100] :limit the maximum number of things to return
@return [Listing<Submission>]
# File lib/redd/models/live_thread.rb, line 69 def discussions(**params) @client.model(:get, "/live/#{get_attribute(:id)}/discussions", params) end
@return [Array<User>] users invited to contribute to this thread
# File lib/redd/models/live_thread.rb, line 55 def invited_contributors @client.get("/live/#{get_attribute(:id)}/contributors").body[1][:data].map do |user| User.new(@client, user) end end
Add an update to this live event. @param body [String] the update text
# File lib/redd/models/live_thread.rb, line 43 def update(body) @client.post("/api/live/#{get_attribute(:id)}/update", body: body) end
Get the updates from the thread. @param params [Hash] a list of params to send with the request @option params [String] :after return results after the given fullname @option params [String] :before return results before the given fullname @option params [Integer] :count the number of items already seen in the listing @option params [1..100] :limit the maximum number of things to return @return [Listing]
# File lib/redd/models/live_thread.rb, line 27 def updates(**params) @client.model(:get, "/live/#{get_attribute(:id)}", params) end
Private Instance Methods
# File lib/redd/models/live_thread.rb, line 75 def default_loader @client.get("/live/#{@attributes.fetch(:id)}/about").body[:data] end