Class: PayPal::SDK::Core::OpenIDConnect::DataTypes::Tokeninfo

Inherits:
Base show all
Includes:
RequestDataType
Defined in:
lib/paypal-sdk/core/openid_connect.rb,
lib/paypal-sdk/core/openid_connect/data_types.rb

Constant Summary collapse

PATH =
"v1/identity/openidconnect/tokenservice"

Constants inherited from API::DataTypes::Base

API::DataTypes::Base::ContentKey, API::DataTypes::Base::HashOptions

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RequestDataType

#api, api, client_id, client_secret, included

Methods included from SetAPI

#client_id=, #client_secret=, #set_config

Methods inherited from API::DataTypes::Base

add_attribute, add_member, array_of, #convert_array, #convert_object, define_alias_methods, #hash_key, #initialize, #member_names, members, #members, #merge!, object_of, #set, #skip_value?, snakecase, #to_hash, #value_to_hash

Methods included from Logging

#log_event, #logger, logger, logger=

Constructor Details

This class inherits a constructor from PayPal::SDK::Core::API::DataTypes::Base

Class Method Details

.authorize_url(options = {}) ⇒ Object



82
83
84
# File 'lib/paypal-sdk/core/openid_connect.rb', line 82

def authorize_url(options = {})
  OpenIDConnect.authorize_url(options)
end

.create_from_authorization_code(options, http_header = {}) ⇒ Object Also known as: create



60
61
62
63
64
# File 'lib/paypal-sdk/core/openid_connect.rb', line 60

def create_from_authorization_code(options, http_header = {})
  options = { :code => options } if options.is_a? String
  options = options.merge( :grant_type => "authorization_code" )
  Tokeninfo.new(api.post(PATH, with_credentials(options), http_header))
end

.create_from_refresh_token(options, http_header = {}) ⇒ Object Also known as: refresh



67
68
69
70
71
# File 'lib/paypal-sdk/core/openid_connect.rb', line 67

def create_from_refresh_token(options, http_header = {})
  options = { :refresh_token => options } if options.is_a? String
  options = options.merge( :grant_type => "refresh_token" )
  Tokeninfo.new(api.post(PATH, with_credentials(options), http_header))
end

.load_membersObject



47
48
49
50
51
52
53
54
# File 'lib/paypal-sdk/core/openid_connect/data_types.rb', line 47

def self.load_members
  object_of :scope, String
  object_of :access_token, String
  object_of :refresh_token, String
  object_of :token_type, String
  object_of :id_token, String
  object_of :expires_in, Integer
end

.with_credentials(options = {}) ⇒ Object



74
75
76
77
78
79
80
# File 'lib/paypal-sdk/core/openid_connect.rb', line 74

def with_credentials(options = {})
  options = options.dup
  [ :client_id, :client_secret ].each do |key|
    options[key] = self.send(key) unless options[key] or options[key.to_s]
  end
  options
end

Instance Method Details

#logout_url(options = {}) ⇒ Object



97
98
99
# File 'lib/paypal-sdk/core/openid_connect.rb', line 97

def logout_url(options = {})
  OpenIDConnect.logout_url({ :id_token => self.id_token }.merge(options))
end

#refresh(options = {}) ⇒ Object



87
88
89
90
91
# File 'lib/paypal-sdk/core/openid_connect.rb', line 87

def refresh(options = {})
  tokeninfo = self.class.refresh({
    :refresh_token => self.refresh_token}.merge(options))
  self.merge!(tokeninfo.to_hash)
end

#userinfo(options = {}) ⇒ Object



93
94
95
# File 'lib/paypal-sdk/core/openid_connect.rb', line 93

def userinfo(options = {})
  Userinfo.get({ :access_token => self.access_token }.merge(options))
end