Class: RallyUp::Partner::Token
- Inherits:
-
Object
- Object
- RallyUp::Partner::Token
- Defined in:
- lib/rally_up/partner/token.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#expires ⇒ Object
Returns the value of attribute expires.
-
#expires_in ⇒ Object
Returns the value of attribute expires_in.
-
#issued ⇒ Object
Returns the value of attribute issued.
-
#token_type ⇒ Object
Returns the value of attribute token_type.
-
#user_name ⇒ Object
Returns the value of attribute user_name.
Class Method Summary collapse
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#initialize(json) ⇒ Token
constructor
A new instance of Token.
Constructor Details
#initialize(json) ⇒ Token
Returns a new instance of Token.
9 10 11 12 13 14 15 16 |
# File 'lib/rally_up/partner/token.rb', line 9 def initialize(json) @access_token = json[:access_token] @token_type = json[:token_type] @expires_in = json[:expires_in] @user_name = json[:UserName] @issued = json[:'.issued'] @expires = json[:'.expires'] end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
6 7 8 |
# File 'lib/rally_up/partner/token.rb', line 6 def access_token @access_token end |
#expires ⇒ Object
Returns the value of attribute expires.
6 7 8 |
# File 'lib/rally_up/partner/token.rb', line 6 def expires @expires end |
#expires_in ⇒ Object
Returns the value of attribute expires_in.
6 7 8 |
# File 'lib/rally_up/partner/token.rb', line 6 def expires_in @expires_in end |
#issued ⇒ Object
Returns the value of attribute issued.
6 7 8 |
# File 'lib/rally_up/partner/token.rb', line 6 def issued @issued end |
#token_type ⇒ Object
Returns the value of attribute token_type.
6 7 8 |
# File 'lib/rally_up/partner/token.rb', line 6 def token_type @token_type end |
#user_name ⇒ Object
Returns the value of attribute user_name.
6 7 8 |
# File 'lib/rally_up/partner/token.rb', line 6 def user_name @user_name end |
Class Method Details
.access_token_response ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/rally_up/partner/token.rb', line 30 def access_token_response params = { grant_type: 'password', username: RallyUp::Partner.login, password: RallyUp::Partner.secret } HTTP.post("https://#{RallyUp::Partner.domain}/v1/partnertoken", body: URI.encode_www_form(params)) .body.to_s end |
Instance Method Details
#expired? ⇒ Boolean
18 19 20 |
# File 'lib/rally_up/partner/token.rb', line 18 def expired? expires.nil? || Time.parse(expires).utc < Time.now.utc end |