Class: Calendlyr::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/calendlyr/collection.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data:, count:, next_page:, client:) ⇒ Collection

Returns a new instance of Collection.



17
18
19
20
21
22
23
# File 'lib/calendlyr/collection.rb', line 17

def initialize(data:, count:, next_page:, client:)
  @data = data
  @count = count
  @next_page = next_page
  @next_page_token = get_params(next_page)["page_token"]&.first
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



6
7
8
# File 'lib/calendlyr/collection.rb', line 6

def client
  @client
end

#countObject (readonly)

Returns the value of attribute count.



6
7
8
# File 'lib/calendlyr/collection.rb', line 6

def count
  @count
end

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/calendlyr/collection.rb', line 6

def data
  @data
end

#next_pageObject (readonly)

Returns the value of attribute next_page.



6
7
8
# File 'lib/calendlyr/collection.rb', line 6

def next_page
  @next_page
end

#next_page_tokenObject (readonly)

Returns the value of attribute next_page_token.



6
7
8
# File 'lib/calendlyr/collection.rb', line 6

def next_page_token
  @next_page_token
end

Class Method Details

.from_response(response, type:, client:) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/calendlyr/collection.rb', line 8

def self.from_response(response, type:, client:)
  new(
    data: response["collection"].map { |attrs| type.new(attrs.merge(client: client)) },
    count: response.dig("pagination", "count"),
    next_page: response.dig("pagination", "next_page"),
    client: client
  )
end