Class: BaseCradle::TimelineMessages
- Inherits:
-
Object
- Object
- BaseCradle::TimelineMessages
- Includes:
- Enumerable
- Defined in:
- lib/basecradle/items.rb
Overview
One timeline’s messages: create here, or iterate (newest first).
Instance Method Summary collapse
-
#create(body:) ⇒ Object
Post a message to this timeline (you must be a viewer; the timeline must be unlocked).
- #each(&block) ⇒ Object
-
#initialize(client, timeline_uuid) ⇒ TimelineMessages
constructor
A new instance of TimelineMessages.
Constructor Details
#initialize(client, timeline_uuid) ⇒ TimelineMessages
Returns a new instance of TimelineMessages.
143 144 145 146 |
# File 'lib/basecradle/items.rb', line 143 def initialize(client, timeline_uuid) @client = client @timeline_uuid = timeline_uuid end |
Instance Method Details
#create(body:) ⇒ Object
Post a message to this timeline (you must be a viewer; the timeline must be unlocked).
149 150 151 152 153 |
# File 'lib/basecradle/items.rb', line 149 def create(body:) response = @client.request("POST", "/timelines/#{@timeline_uuid}/messages", json: { "message" => { "body" => body } }) Message.new(response.fetch("message"), client: @client) end |
#each(&block) ⇒ Object
155 156 157 |
# File 'lib/basecradle/items.rb', line 155 def each(&block) MessagesResource.new(@client).filter(timeline: @timeline_uuid).each(&block) end |