Class: TeamSnap::Client
- Inherits:
-
Object
- Object
- TeamSnap::Client
- Defined in:
- lib/teamsnap/client.rb
Instance Attribute Summary collapse
-
#faraday_client ⇒ Object
Returns the value of attribute faraday_client.
Class Method Summary collapse
Instance Method Summary collapse
- #api(method, klass, sent_args = {}) ⇒ Object
-
#initialize(opts = {}) ⇒ Client
constructor
A new instance of Client.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Client
Returns a new instance of Client.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/teamsnap/client.rb', line 22 def initialize(opts = {}) con_url = opts.fetch(:url) {} con_token = opts.fetch(:token) {} con_id = opts.fetch(:client_id) {} con_secret = opts.fetch(:client_secret) {} self.faraday_client = TeamSnap::Client.set_faraday_client( con_url || TeamSnap.url, con_token, con_id || TeamSnap.client_id, con_secret || TeamSnap.client_secret, ) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
36 37 38 |
# File 'lib/teamsnap/client.rb', line 36 def method_missing(method, *args, &block) self.faraday_client.send(method, *args, &block) end |
Instance Attribute Details
#faraday_client ⇒ Object
Returns the value of attribute faraday_client.
20 21 22 |
# File 'lib/teamsnap/client.rb', line 20 def faraday_client @faraday_client end |
Class Method Details
.set_faraday_client(url, token, client_id, client_secret) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/teamsnap/client.rb', line 4 def set_faraday_client(url, token, client_id, client_secret) Faraday.new( :url => url, :parallel_manager => Typhoeus::Hydra.new ) do |con| con.request :multipart con.request :teamsnap_auth_middleware, { :token => token, :client_id => client_id, :client_secret => client_secret } con.adapter :typhoeus end end |