class Ohmage::Client
Attributes
client_string[RW]
password[RW]
path[RW]
port[RW]
server_config[RW]
server_debug[RW]
server_url[RW]
token[RW]
user[RW]
Public Class Methods
new(options = {}) { |self| ... }
click to toggle source
# File lib/ohmage/client.rb, line 8 def initialize(options = {}) # 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 options.each do |k, v| instance_variable_set("@#{k}", v) end yield(self) if block_given? server_config_read self end
Public Instance Methods
auth_token()
click to toggle source
ohmage user/auth_token call @see github.com/ohmage/server/wiki/User-Authentication#statefulAuthentication @returns String: auth_token
valid for server’s auth_token_lifetime param
# 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
Also aliased as: auth
inspect()
click to toggle source
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 @return [String]
Calls superclass method
# File lib/ohmage/client.rb, line 55 def inspect inspected = super inspected.gsub! @password, '*******' if @password end
server_config_read()
click to toggle source
ohmage config/read call @returns [Hash] of server config details
# File lib/ohmage/client.rb, line 28 def server_config_read request = Ohmage::Request.new(self, :get, 'config/read', {}) resp = request.perform self.server_config = resp[:data] end