Class: UboostClient::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/uboost-client/uboost_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options = Hash.new)
  @subdomain        = options[:subdomain]
  @api_credentials  = options[:api_credentials]
  @debug            = options[:debug] || false
end

Instance Attribute Details

#api_credentialsObject

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

#subdomainObject

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

#accountObject



37
38
39
# File 'lib/uboost-client/uboost_client.rb', line 37

def 
  @account ||= UboostClient::Account.new(self)
end

#badgesObject



45
46
47
# File 'lib/uboost-client/uboost_client.rb', line 45

def badges
  @badges ||= UboostClient::Badges.new(self)
end

#connectionObject



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

#pointsObject



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 widgets(options = Hash.new)
  @widgets = UboostClient::Widgets.new(self, options)
end