Class: Gensee::Client
- Inherits:
-
Object
- Object
- Gensee::Client
- Includes:
- Training
- Defined in:
- lib/gensee/client.rb,
lib/gensee/client/training.rb
Overview
Client for Gensee API
@params: uri [String], the URI/endpoint which Gensee created for you
username [String], Your Gensee login in name. might be an email address
password [String], Your Gensee password
Defined Under Namespace
Modules: Training
Instance Method Summary collapse
- #app_client ⇒ Object
- #default_options ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
Methods included from Training
#classroom_info, #courseware_info, #courseware_list, #create_classroom, #create_teacher, #delete_classroom, #delete_courseware, #modify_classroom, #modify_courseware
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
19 20 21 22 23 24 |
# File 'lib/gensee/client.rb', line 19 def initialize( = {}) opts = .dup @endpoint = opts[:endpoint].start_with?('http://') ? opts[:endpoint] : "http://#{opts[:endpoint]}" @username = opts[:login] @password = Digest::MD5.hexdigest(opts[:password]) end |
Instance Method Details
#app_client ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gensee/client.rb', line 30 def app_client @client ||= Faraday.new(@endpoint) do |conn| conn.params = conn.headers = { content_type: 'application/json', user_agent: Gensee::Configurable.user_agent } conn.request :url_encoded # conn.response :logger conn.adapter Faraday.default_adapter end end |
#default_options ⇒ Object
26 27 28 |
# File 'lib/gensee/client.rb', line 26 def { loginName: @username, password: @password, sec: 'true' } end |