Class: UboostClient::Client
- Inherits:
-
Object
- Object
- UboostClient::Client
- Defined in:
- lib/uboost-client/uboost_client.rb
Instance Attribute Summary collapse
-
#api_credentials ⇒ Object
Returns the value of attribute api_credentials.
-
#subdomain ⇒ Object
Returns the value of attribute subdomain.
Instance Method Summary collapse
- #account ⇒ Object
- #badges ⇒ Object
- #connection ⇒ Object
- #connection_with_uboost_session(uboost_session_id) ⇒ Object
-
#initialize(options = Hash.new) ⇒ Client
constructor
A new instance of Client.
- #points ⇒ Object
- #widgets(options = Hash.new) ⇒ Object
Constructor Details
#initialize(options = Hash.new) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 |
# File 'lib/uboost-client/uboost_client.rb', line 13 def initialize( = Hash.new) @subdomain = [:subdomain] @api_credentials = [:api_credentials] @debug = [:debug] || false end |
Instance Attribute Details
#api_credentials ⇒ Object
Returns the value of attribute api_credentials.
11 12 13 |
# File 'lib/uboost-client/uboost_client.rb', line 11 def api_credentials @api_credentials end |
#subdomain ⇒ Object
Returns the value of attribute subdomain.
11 12 13 |
# File 'lib/uboost-client/uboost_client.rb', line 11 def subdomain @subdomain end |
Instance Method Details
#account ⇒ Object
37 38 39 |
# File 'lib/uboost-client/uboost_client.rb', line 37 def account @account ||= UboostClient::Account.new(self) end |
#badges ⇒ Object
45 46 47 |
# File 'lib/uboost-client/uboost_client.rb', line 45 def badges @badges ||= UboostClient::Badges.new(self) end |
#connection ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/uboost-client/uboost_client.rb', line 19 def connection url = "https://#{@api_credentials[:username]}:#{@api_credentials[:password]}@#{@subdomain}.uboost.com" Faraday.new(url) do |faraday| faraday.request :url_encoded # form-encode POST params faraday.response :logger # log requests to STDOUT faraday.adapter Faraday.default_adapter # make requests with Net::HTTP end end |
#connection_with_uboost_session(uboost_session_id) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/uboost-client/uboost_client.rb', line 28 def connection_with_uboost_session(uboost_session_id) url = "https://#{@subdomain}.uboost.com" Faraday.new(url, {:headers=>{'Cookie'=> uboost_session_id}}) do |faraday| faraday.request :url_encoded # form-encode POST params faraday.response :logger # log requests to STDOUT faraday.adapter Faraday.default_adapter # make requests with Net::HTTP end end |
#points ⇒ Object
41 42 43 |
# File 'lib/uboost-client/uboost_client.rb', line 41 def points @points ||= UboostClient::Points.new(self) end |
#widgets(options = Hash.new) ⇒ Object
49 50 51 |
# File 'lib/uboost-client/uboost_client.rb', line 49 def ( = Hash.new) @widgets = UboostClient::Widgets.new(self, ) end |