Class: CampusIvy::Resources::Account
- Inherits:
-
Object
- Object
- CampusIvy::Resources::Account
- Extended by:
- T::Sig
- Defined in:
- lib/campus_ivy/resources/account.rb
Instance Method Summary collapse
-
#initialize(client) ⇒ Account
constructor
A new instance of Account.
- #logout ⇒ Object
- #token(institution_id:, client_key:, username:, password:) ⇒ Object
- #token_credentials(institution_id:, username:, password:) ⇒ Object
- #token_key(institution_id:, client_key:) ⇒ Object
Constructor Details
#initialize(client) ⇒ Account
Returns a new instance of Account.
9 10 11 |
# File 'lib/campus_ivy/resources/account.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#logout ⇒ Object
76 77 78 79 80 81 |
# File 'lib/campus_ivy/resources/account.rb', line 76 def logout response = @client.connection.post('account/logout') return nil if response.body.nil? || response.body.empty? CampusIvy::Object.new(response.body) end |
#token(institution_id:, client_key:, username:, password:) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/campus_ivy/resources/account.rb', line 21 def token(institution_id:, client_key:, username:, password:) response = @client.connection.post('account/token') do |req| req.body = { institutionId: institution_id, clientKey: client_key, userName: username, password: password } end CampusIvy::Object.new(response.body) end |
#token_credentials(institution_id:, username:, password:) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/campus_ivy/resources/account.rb', line 40 def token_credentials(institution_id:, username:, password:) response = @client.connection.post('account/token/credentials') do |req| req.body = { institutionId: institution_id, userName: username, password: password } end result = CampusIvy::Object.new(response.body) if result.token @client.config.token = result.token @client.reset_connection end result end |
#token_key(institution_id:, client_key:) ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/campus_ivy/resources/account.rb', line 65 def token_key(institution_id:, client_key:) response = @client.connection.post('account/token/key') do |req| req.body = { institutionId: institution_id, clientKey: client_key } end CampusIvy::Object.new(response.body) end |