Class: Pixabay::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/pixabay.rb

Instance Method Summary collapse

Constructor Details

#initialize(key: nil, timeout: 10) ⇒ Client

Returns a new instance of Client.



17
18
19
20
# File 'lib/pixabay.rb', line 17

def initialize(key: nil, timeout: 10)
  @key = key
  @timeout = timeout
end

Instance Method Details

#photos(**options) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/pixabay.rb', line 22

def photos(**options)
  default_options = {
    q: nil, lang: "en", id: nil,
    response_group: "image_details", image_type: "all", orientation: "all", category: nil,
    min_width: 0, min_height: 0, editors_choice: false, safesearch: false,
    order: "popular", page: 1, per_page: 20, callback: nil, pretty: false
  }

  options = { query: { key: @key }.merge(options) }
  self.class.get("", options)
end

#videos(**options) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/pixabay.rb', line 34

def videos(**options)
  default_options = {
    q: nil, lang: "en", id: nil,
    video_type: "all", category: nil,
    min_width: 0, min_height: 0, editors_choice: false, safesearch: false,
    order: "popular", page: 1, per_page: 20, callback: nil, pretty: false
  }

  options = { query: { key: @key }.merge(options) }
  self.class.get("/videos", options)
end