Class: Ohmage::Client
Instance Attribute Summary collapse
-
#client_string ⇒ Object
Returns the value of attribute client_string.
-
#password ⇒ Object
Returns the value of attribute password.
-
#path ⇒ Object
Returns the value of attribute path.
-
#port ⇒ Object
Returns the value of attribute port.
-
#server_config ⇒ Object
Returns the value of attribute server_config.
-
#server_debug ⇒ Object
Returns the value of attribute server_debug.
-
#server_url ⇒ Object
Returns the value of attribute server_url.
-
#token ⇒ Object
Returns the value of attribute token.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#auth_token ⇒ Object
(also: #auth)
ohmage user/auth_token call.
-
#initialize(options = {}) {|_self| ... } ⇒ Client
constructor
rubocop:disable MethodLength.
-
#inspect ⇒ String
Masking password from inspected client.
-
#server_config_read ⇒ Object
ohmage config/read call.
Methods included from API::Audit
Methods included from API::Survey
#survey_response_delete, #survey_response_read, #survey_response_update, #survey_upload
Methods included from API::Media
Methods included from API::Document
#document_contents, #document_create, #document_delete, #document_read, #document_update
Methods included from API::Campaign
#campaign_create, #campaign_delete, #campaign_read, #campaign_search, #campaign_update
Methods included from API::Clazz
#class_create, #class_delete, #class_read, #class_search, #class_update
Methods included from API::User
#user_create, #user_delete, #user_info_read, #user_password, #user_read, #user_search, #user_setup, #user_update
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Client
rubocop:disable MethodLength
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ohmage/client.rb', line 8 def initialize( = {}) # rubocop:disable MethodLength self.server_url = ENV['OHMAGE_SERVER_URL'] self.user = ENV['OHMAGE_USER'] self.password = ENV['OHMAGE_PASSWORD'] self.client_string = 'ruby-ohmage' self.path = 'app/' self.port = 443 self.server_debug = false .each do |k, v| instance_variable_set("@#{k}", v) end yield(self) if block_given? server_config_read self end |
Instance Attribute Details
#client_string ⇒ Object
Returns the value of attribute client_string.
7 8 9 |
# File 'lib/ohmage/client.rb', line 7 def client_string @client_string end |
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'lib/ohmage/client.rb', line 7 def password @password end |
#path ⇒ Object
Returns the value of attribute path.
7 8 9 |
# File 'lib/ohmage/client.rb', line 7 def path @path end |
#port ⇒ Object
Returns the value of attribute port.
7 8 9 |
# File 'lib/ohmage/client.rb', line 7 def port @port end |
#server_config ⇒ Object
Returns the value of attribute server_config.
7 8 9 |
# File 'lib/ohmage/client.rb', line 7 def server_config @server_config end |
#server_debug ⇒ Object
Returns the value of attribute server_debug.
7 8 9 |
# File 'lib/ohmage/client.rb', line 7 def server_debug @server_debug end |
#server_url ⇒ Object
Returns the value of attribute server_url.
7 8 9 |
# File 'lib/ohmage/client.rb', line 7 def server_url @server_url end |
#token ⇒ Object
Returns the value of attribute token.
7 8 9 |
# File 'lib/ohmage/client.rb', line 7 def token @token end |
#user ⇒ Object
Returns the value of attribute user.
7 8 9 |
# File 'lib/ohmage/client.rb', line 7 def user @user end |
Instance Method Details
#auth_token ⇒ Object Also known as: auth
ohmage user/auth_token call
39 40 41 42 43 44 45 46 47 |
# File 'lib/ohmage/client.rb', line 39 def auth_token params = {} params['user'] = user params['password'] = password request = Ohmage::Request.new(self, :post, 'user/auth_token', params) resp = request.perform self.token = resp[:token] resp[:token] end |
#inspect ⇒ String
Masking password from inspected client. Lovingly lifted from github.com/octokit/octokit.rb, The full text of the license for this work (MIT) can be found at opensource.org/licenses/mit
55 56 57 58 |
# File 'lib/ohmage/client.rb', line 55 def inspect inspected = super inspected.gsub! @password, '*******' if @password end |