Class: Pexels::Client::Collections

Inherits:
Object
  • Object
show all
Defined in:
lib/pexels/client/collections.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Collections

Returns a new instance of Collections.



2
3
4
# File 'lib/pexels/client/collections.rb', line 2

def initialize(client)
  @client = client
end

Instance Method Details

#[](id, type: nil, per_page: 15, page: 1, timeout: { open: nil, read: nil }) ⇒ Object Also known as: find



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/pexels/client/collections.rb', line 36

def [](id, type: nil, per_page: 15, page: 1, timeout: { open: nil, read: nil })
  response = @client.request(
    "#{Pexels.api_version}/collections/#{id}",
    params: {
      per_page: per_page,
      page: page,
      type: type
    },
    options: {
      open_timeout: timeout[:open],
      read_timeout: timeout[:read]
    })

  Pexels::CollectionMediaSet.new(response)
end

#all(per_page: 15, page: 1, timeout: { open: nil, read: nil }) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/pexels/client/collections.rb', line 6

def all(per_page: 15, page: 1, timeout: { open: nil, read: nil })
  response = @client.request(
    "#{Pexels.api_version}/collections",
    params: {
      per_page: per_page,
      page: page
    },
    options: {
      open_timeout: timeout[:open],
      read_timeout: timeout[:read]
    })

  Pexels::CollectionSet.new(response)
end


21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/pexels/client/collections.rb', line 21

def featured(per_page: 15, page: 1, timeout: { open: nil, read: nil })
  response = @client.request(
    "#{Pexels.api_version}/collections/featured",
    params: {
      per_page: per_page,
      page: page
    },
    options: {
      open_timeout: timeout[:open],
      read_timeout: timeout[:read]
    })

  Pexels::CollectionSet.new(response)
end