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(credentials = nil) ⇒ 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
42 43 44 |
# File 'lib/uboost-client/uboost_client.rb', line 42 def account @account ||= UboostClient::Account.new(self) end |
#badges ⇒ Object
50 51 52 |
# File 'lib/uboost-client/uboost_client.rb', line 50 def badges @badges ||= UboostClient::Badges.new(self) end |
#connection(credentials = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/uboost-client/uboost_client.rb', line 19 def connection(credentials = nil) if credentials basic_auth_creds = "#{credentials[:username]}:#{credentials[:password]}" else basic_auth_creds = "#{@api_credentials[:username]}:#{@api_credentials[:password]}" end url = "https://#{basic_auth_creds}@#{@subdomain}.uboost.com" Faraday.new(url) do |faraday| faraday.request :url_encoded # form-encode POST params faraday.response :logger if @debug # log requests to STDOUT faraday.adapter Faraday.default_adapter # make requests with Net::HTTP end end |
#connection_with_uboost_session(uboost_session_id) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/uboost-client/uboost_client.rb', line 33 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 if @debug # log requests to STDOUT faraday.adapter Faraday.default_adapter # make requests with Net::HTTP end end |
#points ⇒ Object
46 47 48 |
# File 'lib/uboost-client/uboost_client.rb', line 46 def points @points ||= UboostClient::Points.new(self) end |
#widgets(options = Hash.new) ⇒ Object
54 55 56 |
# File 'lib/uboost-client/uboost_client.rb', line 54 def ( = Hash.new) @widgets = UboostClient::Widgets.new(self, ) end |