Class: SwaggerPetstoreOpenApi30::OAuthToken

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/swagger_petstore_open_api30/models/o_auth_token.rb

Overview

OAuth 2 Authorization endpoint response

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(access_token = nil, token_type = nil, expires_in = SKIP, scope = SKIP, expiry = SKIP, refresh_token = SKIP) ⇒ OAuthToken

Returns a new instance of OAuthToken.



65
66
67
68
69
70
71
72
73
# File 'lib/swagger_petstore_open_api30/models/o_auth_token.rb', line 65

def initialize(access_token = nil, token_type = nil, expires_in = SKIP,
               scope = SKIP, expiry = SKIP, refresh_token = SKIP)
  @access_token = access_token
  @token_type = token_type
  @expires_in = expires_in unless expires_in == SKIP
  @scope = scope unless scope == SKIP
  @expiry = expiry unless expiry == SKIP
  @refresh_token = refresh_token unless refresh_token == SKIP
end

Instance Attribute Details

#access_tokenString

Access token

Returns:

  • (String)


14
15
16
# File 'lib/swagger_petstore_open_api30/models/o_auth_token.rb', line 14

def access_token
  @access_token
end

#expires_inInteger

Time in seconds before the access token expires

Returns:

  • (Integer)


22
23
24
# File 'lib/swagger_petstore_open_api30/models/o_auth_token.rb', line 22

def expires_in
  @expires_in
end

#expiryInteger

Time of token expiry as unix timestamp (UTC)

Returns:

  • (Integer)


31
32
33
# File 'lib/swagger_petstore_open_api30/models/o_auth_token.rb', line 31

def expiry
  @expiry
end

#refresh_tokenString

Refresh token Used to get a new access token when it expires.

Returns:

  • (String)


36
37
38
# File 'lib/swagger_petstore_open_api30/models/o_auth_token.rb', line 36

def refresh_token
  @refresh_token
end

#scopeString

List of scopes granted This is a space-delimited list of strings.

Returns:

  • (String)


27
28
29
# File 'lib/swagger_petstore_open_api30/models/o_auth_token.rb', line 27

def scope
  @scope
end

#token_typeString

Type of access token

Returns:

  • (String)


18
19
20
# File 'lib/swagger_petstore_open_api30/models/o_auth_token.rb', line 18

def token_type
  @token_type
end

Class Method Details

.from_element(root) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/swagger_petstore_open_api30/models/o_auth_token.rb', line 96

def self.from_element(root)
  access_token = XmlUtilities.from_element(root, 'access_token', String)
  token_type = XmlUtilities.from_element(root, 'token_type', String)
  expires_in = XmlUtilities.from_element(root, 'expires_in', Integer)
  scope = XmlUtilities.from_element(root, 'scope', String)
  expiry = XmlUtilities.from_element(root, 'expiry', Integer)
  refresh_token = XmlUtilities.from_element(root, 'refresh_token', String)

  new(access_token,
      token_type,
      expires_in,
      scope,
      expiry,
      refresh_token)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/swagger_petstore_open_api30/models/o_auth_token.rb', line 76

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  access_token = hash.key?('access_token') ? hash['access_token'] : nil
  token_type = hash.key?('token_type') ? hash['token_type'] : nil
  expires_in = hash.key?('expires_in') ? hash['expires_in'] : SKIP
  scope = hash.key?('scope') ? hash['scope'] : SKIP
  expiry = hash.key?('expiry') ? hash['expiry'] : SKIP
  refresh_token = hash.key?('refresh_token') ? hash['refresh_token'] : SKIP

  # Create object from extracted values.
  OAuthToken.new(access_token,
                 token_type,
                 expires_in,
                 scope,
                 expiry,
                 refresh_token)
end

.namesObject

A mapping from model property names to API property names.



39
40
41
42
43
44
45
46
47
48
# File 'lib/swagger_petstore_open_api30/models/o_auth_token.rb', line 39

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

.nullablesObject

An array for nullable fields



61
62
63
# File 'lib/swagger_petstore_open_api30/models/o_auth_token.rb', line 61

def self.nullables
  []
end

.optionalsObject

An array for optional fields



51
52
53
54
55
56
57
58
# File 'lib/swagger_petstore_open_api30/models/o_auth_token.rb', line 51

def self.optionals
  %w[
    expires_in
    scope
    expiry
    refresh_token
  ]
end

Instance Method Details

#to_xml_element(doc, root_name) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/swagger_petstore_open_api30/models/o_auth_token.rb', line 112

def to_xml_element(doc, root_name)
  root = doc.create_element(root_name)

  XmlUtilities.add_as_subelement(doc, root, 'access_token', access_token)
  XmlUtilities.add_as_subelement(doc, root, 'token_type', token_type)
  XmlUtilities.add_as_subelement(doc, root, 'expires_in', expires_in)
  XmlUtilities.add_as_subelement(doc, root, 'scope', scope)
  XmlUtilities.add_as_subelement(doc, root, 'expiry', expiry)
  XmlUtilities.add_as_subelement(doc, root, 'refresh_token', refresh_token)

  root
end