Class: Hark::API
Class Attribute Summary collapse
-
.configuration ⇒ Object
The configuration object.
Class Method Summary collapse
-
.api ⇒ Object
The api object.
-
.clip(clip_id) ⇒ Object
Queries the API for the clip JSON.
-
.configure {|configuration| ... } ⇒ Object
Call this method to configure the library at runtime.
-
.search(search_term) ⇒ Object
Queries the API for the search term.
Instance Method Summary collapse
-
#clip(clip_id) ⇒ String
Queries the API for the clip JSON.
-
#options ⇒ Hash
Default options passed back to in a HTTParty call.
-
#search(search_term) ⇒ String
Queries the API for the search term.
Class Attribute Details
.configuration ⇒ Object
The configuration object.
54 55 56 |
# File 'lib/hark/api.rb', line 54 def configuration @configuration ||= Configuration.new end |
Class Method Details
.api ⇒ Object
The api object.
60 61 62 63 |
# File 'lib/hark/api.rb', line 60 def api raise ArgumentError if configuration.api_key.blank? @api end |
.clip(clip_id) ⇒ Object
Queries the API for the clip JSON.
67 68 69 |
# File 'lib/hark/api.rb', line 67 def clip(clip_id) api.clip(clip_id) end |
.configure {|configuration| ... } ⇒ Object
Call this method to configure the library at runtime.
47 48 49 50 |
# File 'lib/hark/api.rb', line 47 def configure yield(configuration) @api ||= API.new end |
.search(search_term) ⇒ Object
Queries the API for the search term
73 74 75 |
# File 'lib/hark/api.rb', line 73 def search(search_term) api.search(search_term) end |
Instance Method Details
#clip(clip_id) ⇒ String
Queries the API for the clip JSON
15 16 17 |
# File 'lib/hark/api.rb', line 15 def clip( clip_id ) self.class.get("/clips/#{clip_id}.json", ) end |
#options ⇒ Hash
Default options passed back to in a HTTParty call.
31 32 33 |
# File 'lib/hark/api.rb', line 31 def { :headers => { 'X-HarkToken' => self.class.configuration.api_key } } end |
#search(search_term) ⇒ String
Queries the API for the search term
22 23 24 25 26 27 |
# File 'lib/hark/api.rb', line 22 def search(search_term) = [:query] = { 'keywords' => search_term } puts self.class.get("/clips/search.json", ) end |