Class: BaseCradle::TimelinesResource

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/basecradle/timelines.rb

Overview

Your timelines — the ones you own plus the ones you participate in.

Iterable (auto-paginating, newest first): bc.timelines.each, or any Enumerable method (map, find, first — which stop early without fetching every page).

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ TimelinesResource

Returns a new instance of TimelinesResource.



14
15
16
# File 'lib/basecradle/timelines.rb', line 14

def initialize(client)
  @client = client
end

Instance Method Details

#create(name:) ⇒ Object

Create a timeline owned by you (subject to your max_timelines cap).



25
26
27
28
# File 'lib/basecradle/timelines.rb', line 25

def create(name:)
  response = @client.request("POST", "/timelines", json: { "timeline" => { "name" => name } })
  subject_timeline(response)
end

#each(&block) ⇒ Object



18
19
20
21
22
# File 'lib/basecradle/timelines.rb', line 18

def each(&block)
  return enum_for(:each) unless block_given?

  Paginator.new(@client, "/timelines", envelope_key: "timelines", model: Timeline).each(&block)
end

#get(uuid) ⇒ Object

Fetch one timeline with its items inline (you must be a viewer).



31
32
33
# File 'lib/basecradle/timelines.rb', line 31

def get(uuid)
  subject_timeline(@client.request("GET", "/timelines/#{uuid}"))
end