Class: UspsApi::ResourceOwnerTokenResponse
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::ResourceOwnerTokenResponse
- Defined in:
- lib/usps_api/models/resource_owner_token_response.rb
Overview
The OAuth token response for third-party client applications to use to access USPS APIs on behalf of USPS customers. Both access and refresh tokens are returned in the response. You may use [The Unix Epoch Time Converter](www.epochconverter.com/) to convert access token issued at values to human readable formats. Use the public key provided in the response to verify the access token signature.
Instance Attribute Summary collapse
-
#access_token ⇒ String
The access token issued to use to acess protected resources.
-
#api_products ⇒ String
The list of API products approved for use by the client application.
-
#application_name ⇒ String
The name of the client application.
-
#client_id ⇒ String
The unique identifier for the client application.
-
#expires_in ⇒ Integer
The expiration time of the issued access token, in seconds.
-
#issued_at ⇒ Integer
The date and time the access token was issued, expressed in Unix epoch time in milliseconds.
-
#issuer ⇒ String
The authority that issued the token(s).
-
#public_key ⇒ String
The base64-encoded public cryptographic key used to validate the signature of the access token.
-
#refresh_count ⇒ Integer
The number of times the refresh token operation has been used.
-
#refresh_token ⇒ String
The refresh token.
-
#refresh_token_expires_in ⇒ Integer
The refresh token expiration, in seconds.
-
#refresh_token_issued_at ⇒ Integer
The date and time the refresh token was issued expressed in Unix epoch time in milliseconds.
-
#refresh_token_status ⇒ RefreshTokenStatus
The current state of the refresh token.
-
#scope ⇒ String
The OAuth scope being requested by the client application, specified as a list of space-delimited, case-sensitive strings.
-
#status ⇒ Status4
The status of the access token.
-
#token_type ⇒ String
readonly
The access token type provides the client with the information required to successfully utilize the access token to make a protected resource request (along with type-specific attributes).
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(access_token:, expires_in:, refresh_token:, refresh_token_expires_in:, issued_at: SKIP, status: SKIP, issuer: SKIP, scope: SKIP, refresh_token_issued_at: SKIP, refresh_count: SKIP, refresh_token_status: SKIP, client_id: SKIP, application_name: SKIP, api_products: SKIP, public_key: SKIP) ⇒ ResourceOwnerTokenResponse
constructor
A new instance of ResourceOwnerTokenResponse.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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:, expires_in:, refresh_token:, refresh_token_expires_in:, issued_at: SKIP, status: SKIP, issuer: SKIP, scope: SKIP, refresh_token_issued_at: SKIP, refresh_count: SKIP, refresh_token_status: SKIP, client_id: SKIP, application_name: SKIP, api_products: SKIP, public_key: SKIP) ⇒ ResourceOwnerTokenResponse
Returns a new instance of ResourceOwnerTokenResponse.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 141 def initialize(access_token:, expires_in:, refresh_token:, refresh_token_expires_in:, issued_at: SKIP, status: SKIP, issuer: SKIP, scope: SKIP, refresh_token_issued_at: SKIP, refresh_count: SKIP, refresh_token_status: SKIP, client_id: SKIP, application_name: SKIP, api_products: SKIP, public_key: SKIP) @access_token = access_token @issued_at = issued_at unless issued_at == SKIP @expires_in = expires_in @token_type = 'Bearer' @status = status unless status == SKIP @issuer = issuer unless issuer == SKIP @scope = scope unless scope == SKIP @refresh_token = refresh_token @refresh_token_issued_at = refresh_token_issued_at unless refresh_token_issued_at == SKIP @refresh_token_expires_in = refresh_token_expires_in @refresh_count = refresh_count unless refresh_count == SKIP @refresh_token_status = refresh_token_status unless refresh_token_status == SKIP @client_id = client_id unless client_id == SKIP @application_name = application_name unless application_name == SKIP @api_products = api_products unless api_products == SKIP @public_key = public_key unless public_key == SKIP end |
Instance Attribute Details
#access_token ⇒ String
The access token issued to use to acess protected resources.
19 20 21 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 19 def access_token @access_token end |
#api_products ⇒ String
The list of API products approved for use by the client application.
89 90 91 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 89 def api_products @api_products end |
#application_name ⇒ String
The name of the client application.
85 86 87 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 85 def application_name @application_name end |
#client_id ⇒ String
The unique identifier for the client application.
81 82 83 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 81 def client_id @client_id end |
#expires_in ⇒ Integer
The expiration time of the issued access token, in seconds.
31 32 33 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 31 def expires_in @expires_in end |
#issued_at ⇒ Integer
The date and time the access token was issued, expressed in Unix epoch time in milliseconds. You may use [The Unix Epoch Time Converter](www.epochconverter.com/) to convert access token issued at values to human readable formats.
27 28 29 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 27 def issued_at @issued_at end |
#issuer ⇒ String
The authority that issued the token(s).
46 47 48 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 46 def issuer @issuer end |
#public_key ⇒ String
The base64-encoded public cryptographic key used to validate the signature of the access token. Validation ensures that the access token has not been tampered with and it originated from a known, trusted source.
95 96 97 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 95 def public_key @public_key end |
#refresh_count ⇒ Integer
The number of times the refresh token operation has been used.
73 74 75 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 73 def refresh_count @refresh_count end |
#refresh_token ⇒ String
The refresh token.
57 58 59 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 57 def refresh_token @refresh_token end |
#refresh_token_expires_in ⇒ Integer
The refresh token expiration, in seconds.
69 70 71 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 69 def refresh_token_expires_in @refresh_token_expires_in end |
#refresh_token_issued_at ⇒ Integer
The date and time the refresh token was issued expressed in Unix epoch time in milliseconds. You may use [The Unix Epoch Time Converter](www.epochconverter.com/) to convert refresh token issued at values to human readable formats.
65 66 67 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 65 def refresh_token_issued_at @refresh_token_issued_at end |
#refresh_token_status ⇒ RefreshTokenStatus
The current state of the refresh token.
77 78 79 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 77 def refresh_token_status @refresh_token_status end |
#scope ⇒ String
The OAuth scope being requested by the client application, specified as a list of space-delimited, case-sensitive strings. If ommitted from the token request then the default scope configured for the client application is used.
53 54 55 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 53 def scope @scope end |
#status ⇒ Status4
The status of the access token.
42 43 44 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 42 def status @status end |
#token_type ⇒ String (readonly)
The access token type provides the client with the information required to successfully utilize the access token to make a protected resource request (along with type-specific attributes). The client MUST NOT use an access token if it does not understand the token type.
38 39 40 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 38 def token_type @token_type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 166 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. access_token = hash.key?('access_token') ? hash['access_token'] : nil expires_in = hash.key?('expires_in') ? hash['expires_in'] : nil refresh_token = hash.key?('refresh_token') ? hash['refresh_token'] : nil refresh_token_expires_in = hash.key?('refresh_token_expires_in') ? hash['refresh_token_expires_in'] : nil issued_at = hash.key?('issued_at') ? hash['issued_at'] : SKIP status = hash.key?('status') ? hash['status'] : SKIP issuer = hash.key?('issuer') ? hash['issuer'] : SKIP scope = hash.key?('scope') ? hash['scope'] : SKIP refresh_token_issued_at = hash.key?('refresh_token_issued_at') ? hash['refresh_token_issued_at'] : SKIP refresh_count = hash.key?('refresh_count') ? hash['refresh_count'] : SKIP refresh_token_status = hash.key?('refresh_token_status') ? hash['refresh_token_status'] : SKIP client_id = hash.key?('client_id') ? hash['client_id'] : SKIP application_name = hash.key?('application_name') ? hash['application_name'] : SKIP api_products = hash.key?('api_products') ? hash['api_products'] : SKIP public_key = hash.key?('public_key') ? hash['public_key'] : SKIP # Create object from extracted values. ResourceOwnerTokenResponse.new(access_token: access_token, expires_in: expires_in, refresh_token: refresh_token, refresh_token_expires_in: refresh_token_expires_in, issued_at: issued_at, status: status, issuer: issuer, scope: scope, refresh_token_issued_at: refresh_token_issued_at, refresh_count: refresh_count, refresh_token_status: refresh_token_status, client_id: client_id, application_name: application_name, api_products: api_products, public_key: public_key) end |
.names ⇒ Object
A mapping from model property names to API property names.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 98 def self.names @_hash = {} if @_hash.nil? @_hash['access_token'] = 'access_token' @_hash['issued_at'] = 'issued_at' @_hash['expires_in'] = 'expires_in' @_hash['token_type'] = 'token_type' @_hash['status'] = 'status' @_hash['issuer'] = 'issuer' @_hash['scope'] = 'scope' @_hash['refresh_token'] = 'refresh_token' @_hash['refresh_token_issued_at'] = 'refresh_token_issued_at' @_hash['refresh_token_expires_in'] = 'refresh_token_expires_in' @_hash['refresh_count'] = 'refresh_count' @_hash['refresh_token_status'] = 'refresh_token_status' @_hash['client_id'] = 'client_id' @_hash['application_name'] = 'application_name' @_hash['api_products'] = 'api_products' @_hash['public_key'] = 'public_key' @_hash end |
.nullables ⇒ Object
An array for nullable fields
137 138 139 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 137 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 120 def self.optionals %w[ issued_at status issuer scope refresh_token_issued_at refresh_count refresh_token_status client_id application_name api_products public_key ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 210 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.access_token, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.expires_in, ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value.token_type, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.refresh_token, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.refresh_token_expires_in, ->(val) { val.instance_of? Integer }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['access_token'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['expires_in'], ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value['token_type'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['refresh_token'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['refresh_token_expires_in'], ->(val) { val.instance_of? Integer }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 255 def inspect class_name = self.class.name.split('::').last "<#{class_name} access_token: #{@access_token.inspect}, issued_at: #{@issued_at.inspect},"\ " expires_in: #{@expires_in.inspect}, token_type: #{@token_type.inspect}, status:"\ " #{@status.inspect}, issuer: #{@issuer.inspect}, scope: #{@scope.inspect}, refresh_token:"\ " #{@refresh_token.inspect}, refresh_token_issued_at: #{@refresh_token_issued_at.inspect},"\ " refresh_token_expires_in: #{@refresh_token_expires_in.inspect}, refresh_count:"\ " #{@refresh_count.inspect}, refresh_token_status: #{@refresh_token_status.inspect},"\ " client_id: #{@client_id.inspect}, application_name: #{@application_name.inspect},"\ " api_products: #{@api_products.inspect}, public_key: #{@public_key.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
243 244 245 246 247 248 249 250 251 252 |
# File 'lib/usps_api/models/resource_owner_token_response.rb', line 243 def to_s class_name = self.class.name.split('::').last "<#{class_name} access_token: #{@access_token}, issued_at: #{@issued_at}, expires_in:"\ " #{@expires_in}, token_type: #{@token_type}, status: #{@status}, issuer: #{@issuer}, scope:"\ " #{@scope}, refresh_token: #{@refresh_token}, refresh_token_issued_at:"\ " #{@refresh_token_issued_at}, refresh_token_expires_in: #{@refresh_token_expires_in},"\ " refresh_count: #{@refresh_count}, refresh_token_status: #{@refresh_token_status},"\ " client_id: #{@client_id}, application_name: #{@application_name}, api_products:"\ " #{@api_products}, public_key: #{@public_key}>" end |