Class: Wallabee::API
- Inherits:
-
Object
- Object
- Wallabee::API
- Defined in:
- lib/wallabee/api.rb
Instance Method Summary collapse
- #achievements ⇒ Object
- #branded ⇒ Object
- #default_faraday ⇒ Object
-
#initialize(params) ⇒ API
constructor
Creates a new API client instance.
- #items ⇒ Object
Constructor Details
#initialize(params) ⇒ API
Creates a new API client instance.
15 16 17 18 19 20 21 22 23 |
# File 'lib/wallabee/api.rb', line 15 def initialize(params) @api_key = params[:api_key] @debug = params[:debug] @base_url = params[:base_url] || 'http://api.wallab.ee/' @faraday_adapter = params[:faraday_adapter] || Faraday.default_adapter @faraday = params[:faraday] || default_faraday raise ArgumentError, ':api_key missing' unless @api_key end |
Instance Method Details
#achievements ⇒ Object
25 26 27 |
# File 'lib/wallabee/api.rb', line 25 def achievements Wallabee::Resource::Achievements.new(@faraday) end |
#branded ⇒ Object
29 30 31 |
# File 'lib/wallabee/api.rb', line 29 def branded Wallabee::Resource::Branded.new(@faraday) end |
#default_faraday ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/wallabee/api.rb', line 37 def default_faraday Faraday.new(:url => @base_url) do |faraday| faraday.request :url_encoded faraday.response :rashify faraday.response :json faraday.response(:logger) if @debug faraday.adapter @faraday_adapter faraday.headers["X-WallaBee-API-Key"] = @api_key end end |