Class: ProductHunt::Client
- Inherits:
-
Object
- Object
- ProductHunt::Client
- Includes:
- HTTParty, API
- Defined in:
- lib/product_hunt/client.rb
Constant Summary
Constants included from API::Users
Constants included from API::Posts
Instance Method Summary collapse
- #config ⇒ Object
- #fetch(path, params) ⇒ Object
-
#initialize(token) ⇒ Client
constructor
A new instance of Client.
Methods included from API::Users
Methods included from API::Posts
#comments_for_post, #post, #posts, #votes_for_post
Constructor Details
#initialize(token) ⇒ Client
Returns a new instance of Client.
12 13 14 |
# File 'lib/product_hunt/client.rb', line 12 def initialize(token) @config = { headers: { "Authorization" => "Bearer #{token}" } } end |
Instance Method Details
#config ⇒ Object
16 17 18 |
# File 'lib/product_hunt/client.rb', line 16 def config @config end |
#fetch(path, params) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/product_hunt/client.rb', line 20 def fetch(path, params) queryopts = if params.is_a?(Enumerable) && params.size > 0 "?" + URI.encode_www_form(params) end self.class.get(path + (queryopts || ""), @config) end |