class MdNotes::OAuthToken

OAuth 2 Authorization endpoint response

Attributes

access_token[RW]

Access token @return [String]

expires_in[RW]

Time in seconds before the access token expires @return [Long]

expiry[RW]

Time of token expiry as unix timestamp (UTC) @return [Long]

refresh_token[RW]

Refresh token Used to get a new access token when it expires. @return [String]

scope[RW]

List of scopes granted This is a space-delimited list of strings. @return [String]

token_type[RW]

Type of access token @return [String]

Public Class Methods

from_hash(hash) click to toggle source

Creates an instance of the object from a hash.

# File lib/md_notes/models/o_auth_token.rb, line 68
def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  access_token = hash['access_token']
  token_type = hash['token_type']
  expires_in = hash['expires_in']
  scope = hash['scope']
  expiry = hash['expiry']
  refresh_token = hash['refresh_token']

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  OAuthToken.new(access_token,
                 token_type,
                 expires_in,
                 scope,
                 expiry,
                 refresh_token,
                 hash)
end
names() click to toggle source

A mapping from model property names to API property names.

# File lib/md_notes/models/o_auth_token.rb, line 36
def self.names
  @_hash = {} if @_hash.nil?
  @_hash['access_token'] = 'access_token'
  @_hash['token_type'] = 'token_type'
  @_hash['expires_in'] = 'expires_in'
  @_hash['scope'] = 'scope'
  @_hash['expiry'] = 'expiry'
  @_hash['refresh_token'] = 'refresh_token'
  @_hash
end
new(access_token = nil, token_type = nil, expires_in = nil, scope = nil, expiry = nil, refresh_token = nil, additional_properties = {}) click to toggle source
# File lib/md_notes/models/o_auth_token.rb, line 47
def initialize(access_token = nil,
               token_type = nil,
               expires_in = nil,
               scope = nil,
               expiry = nil,
               refresh_token = nil,
               additional_properties = {})
  @access_token = access_token
  @token_type = token_type
  @expires_in = expires_in
  @scope = scope
  @expiry = expiry
  @refresh_token = refresh_token

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end