Class: XporterOnDemand::Token
- Defined in:
- lib/xporter_on_demand/token.rb
Instance Attribute Summary
Attributes inherited from Client
#available_scopes, #estab, #token, #uri
Instance Method Summary collapse
-
#initialize(*args) ⇒ Token
constructor
A new instance of Token.
- #retrieve ⇒ Object
- #validate ⇒ Object
Methods inherited from Client
#edubase_client, #school_client
Methods included from Utils
#assign_attributes, #configure_request, #create_result, #dont_raise_exception, #handle_exceptions, #parameterize, #unwrap
Methods included from API
#changed_rows, #db_status, #fetch, #get_endpoint, #query
Constructor Details
#initialize(*args) ⇒ Token
Returns a new instance of Token.
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/xporter_on_demand/token.rb', line 3 def initialize(*args) @loaded = false @options = args.last.is_a?(Hash) ? args.pop : {} @options[:url] ||= STS_PATH @request_body = {} %w(estab relyingParty password thirdpartyid).each_with_index{ |k, i| @request_body[k] = args[i] } @request_body["thirdpartyid"] ||= "XporterOnDemand" raise ArgumentError, "must supply all the sniz" unless @request_body.none?{ |k, v| v.nil? } end |
Instance Method Details
#retrieve ⇒ Object
15 16 17 18 19 20 |
# File 'lib/xporter_on_demand/token.rb', line 15 def retrieve result = post(@options.merge(body: @request_body.to_json)) assign_attributes(result) @loaded = true self end |
#validate ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/xporter_on_demand/token.rb', line 22 def validate dont_raise_exception{ retrieve } if token :valid elsif try(:authorisation_paused) :paused else :invalid end end |