Class: Pexels::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/pexels/client.rb,
lib/pexels/client/photos.rb,
lib/pexels/client/videos.rb,
lib/pexels/client/request.rb,
lib/pexels/client/response.rb,
lib/pexels/client/search_filters.rb

Defined Under Namespace

Modules: SearchFilters Classes: Collections, Photos, Request, Response, Videos

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key = ENV['PEXELS_API_KEY']) ⇒ Client

Returns a new instance of Client.


6
7
8
# File 'lib/pexels/client.rb', line 6

def initialize(api_key = ENV['PEXELS_API_KEY'])
  @api_key = api_key
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.


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

def api_key
  @api_key
end

#ratelimit_remainingObject (readonly)

Returns the value of attribute ratelimit_remaining.


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

def ratelimit_remaining
  @ratelimit_remaining
end

Instance Method Details

#collectionsObject


18
19
20
# File 'lib/pexels/client.rb', line 18

def collections
  @collections ||= Pexels::Client::Collections.new(self)
end

#photosObject


10
11
12
# File 'lib/pexels/client.rb', line 10

def photos
  @photos ||= Pexels::Client::Photos.new(self)
end

#request(path, method: 'GET', params: {}) ⇒ Object


22
23
24
25
26
27
# File 'lib/pexels/client.rb', line 22

def request(path, method: 'GET', params: {})
  request = Request.new(api_key, path, method, params)
  request.call.tap do |response|
    @ratelimit_remaining = response.ratelimit_remaining
  end
end

#videosObject


14
15
16
# File 'lib/pexels/client.rb', line 14

def videos
  @videos ||= Pexels::Client::Videos.new(self)
end