Class: UspsApi::RefreshTokenCredentialsRequest
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::RefreshTokenCredentialsRequest
- Defined in:
- lib/usps_api/models/refresh_token_credentials_request.rb
Overview
The client credentials in addition to the refresh token received earlier are used to get access and refresh tokens. The credentials of the client application that are verified by the authorization server. The value of the grant_type is ‘refresh_token’.
Instance Attribute Summary collapse
-
#client_id ⇒ String
The unique identifier issued to the client application making the request.
-
#client_secret ⇒ String
The shared secret issued to the client application making the request.
-
#code ⇒ String
The authorization code previously received by the client application.
-
#grant_type ⇒ GrantType
The OAuth standard flow being requested by the client application.
-
#redirect_uri ⇒ String
The authorization code redirect Uniform Resource Identifier (URI) for the third-party application to receive the authorization code.
-
#refresh_token ⇒ String
The refresh token value to be used to issue a new access token.
-
#scope ⇒ String
The OAuth2 scope being requested.
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(redirect_uri:, code:, client_id:, client_secret:, refresh_token:, grant_type: SKIP, scope: SKIP) ⇒ RefreshTokenCredentialsRequest
constructor
A new instance of RefreshTokenCredentialsRequest.
-
#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(redirect_uri:, code:, client_id:, client_secret:, refresh_token:, grant_type: SKIP, scope: SKIP) ⇒ RefreshTokenCredentialsRequest
Returns a new instance of RefreshTokenCredentialsRequest.
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/usps_api/models/refresh_token_credentials_request.rb', line 85 def initialize(redirect_uri:, code:, client_id:, client_secret:, refresh_token:, grant_type: SKIP, scope: SKIP) @grant_type = grant_type unless grant_type == SKIP @scope = scope unless scope == SKIP @redirect_uri = redirect_uri @code = code @client_id = client_id @client_secret = client_secret @refresh_token = refresh_token end |
Instance Attribute Details
#client_id ⇒ String
The unique identifier issued to the client application making the request. Used for authenticating the client application. You will need to add an app to get a client Id and secret. These are the Consumer Key and Consumer Secret values respectfully in the API developer portal.
45 46 47 |
# File 'lib/usps_api/models/refresh_token_credentials_request.rb', line 45 def client_id @client_id end |
#client_secret ⇒ String
The shared secret issued to the client application making the request. Used for authenticating the client application. You will need to add an app to get a client Id and secret. These are the Consumer Key and Consumer Secret values respectfully in the API developer portal.
53 54 55 |
# File 'lib/usps_api/models/refresh_token_credentials_request.rb', line 53 def client_secret @client_secret end |
#code ⇒ String
The authorization code previously received by the client application.
37 38 39 |
# File 'lib/usps_api/models/refresh_token_credentials_request.rb', line 37 def code @code end |
#grant_type ⇒ GrantType
The OAuth standard flow being requested by the client application.
17 18 19 |
# File 'lib/usps_api/models/refresh_token_credentials_request.rb', line 17 def grant_type @grant_type end |
#redirect_uri ⇒ String
The authorization code redirect Uniform Resource Identifier (URI) for the third-party application to receive the authorization code. This is used to verify the identify of the requester. The request will not be redirected to this URI.
33 34 35 |
# File 'lib/usps_api/models/refresh_token_credentials_request.rb', line 33 def redirect_uri @redirect_uri end |
#refresh_token ⇒ String
The refresh token value to be used to issue a new access token.
57 58 59 |
# File 'lib/usps_api/models/refresh_token_credentials_request.rb', line 57 def refresh_token @refresh_token end |
#scope ⇒ String
The OAuth2 scope being requested. A client application may request a subset of scope that has already been configured during registration. The default scope registered for the client application is used as default when the scope is omitted. **Only specify the scope in the request when the client application requires less scope, i.e. less access to APIs, than the default.**
26 27 28 |
# File 'lib/usps_api/models/refresh_token_credentials_request.rb', line 26 def scope @scope end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
97 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/refresh_token_credentials_request.rb', line 97 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. redirect_uri = hash.key?('redirect_uri') ? hash['redirect_uri'] : nil code = hash.key?('code') ? hash['code'] : nil client_id = hash.key?('client_id') ? hash['client_id'] : nil client_secret = hash.key?('client_secret') ? hash['client_secret'] : nil refresh_token = hash.key?('refresh_token') ? hash['refresh_token'] : nil grant_type = hash.key?('grant_type') ? hash['grant_type'] : SKIP scope = hash.key?('scope') ? hash['scope'] : SKIP # Create object from extracted values. RefreshTokenCredentialsRequest.new(redirect_uri: redirect_uri, code: code, client_id: client_id, client_secret: client_secret, refresh_token: refresh_token, grant_type: grant_type, scope: scope) end |
.names ⇒ Object
A mapping from model property names to API property names.
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/usps_api/models/refresh_token_credentials_request.rb', line 60 def self.names @_hash = {} if @_hash.nil? @_hash['grant_type'] = 'grant_type' @_hash['scope'] = 'scope' @_hash['redirect_uri'] = 'redirect_uri' @_hash['code'] = 'code' @_hash['client_id'] = 'client_id' @_hash['client_secret'] = 'client_secret' @_hash['refresh_token'] = 'refresh_token' @_hash end |
.nullables ⇒ Object
An array for nullable fields
81 82 83 |
# File 'lib/usps_api/models/refresh_token_credentials_request.rb', line 81 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
73 74 75 76 77 78 |
# File 'lib/usps_api/models/refresh_token_credentials_request.rb', line 73 def self.optionals %w[ grant_type scope ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/usps_api/models/refresh_token_credentials_request.rb', line 121 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.redirect_uri, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.code, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.client_id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.client_secret, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.refresh_token, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['redirect_uri'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['code'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['client_id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['client_secret'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['refresh_token'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
162 163 164 165 166 167 |
# File 'lib/usps_api/models/refresh_token_credentials_request.rb', line 162 def inspect class_name = self.class.name.split('::').last "<#{class_name} grant_type: #{@grant_type.inspect}, scope: #{@scope.inspect}, redirect_uri:"\ " #{@redirect_uri.inspect}, code: #{@code.inspect}, client_id: #{@client_id.inspect},"\ " client_secret: #{@client_secret.inspect}, refresh_token: #{@refresh_token.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
154 155 156 157 158 159 |
# File 'lib/usps_api/models/refresh_token_credentials_request.rb', line 154 def to_s class_name = self.class.name.split('::').last "<#{class_name} grant_type: #{@grant_type}, scope: #{@scope}, redirect_uri:"\ " #{@redirect_uri}, code: #{@code}, client_id: #{@client_id}, client_secret:"\ " #{@client_secret}, refresh_token: #{@refresh_token}>" end |