Module: PayPal::SDK::Core::Authentication
- Includes:
- Configuration
- Included in:
- Util::HTTPHelper
- Defined in:
- lib/paypal-sdk/core/authentication.rb
Overview
Contains methods to format credentials for HTTP protocol.
Example
include Authentication
credential(url)
base_credential
third_party_credential(url)
add_certificate(http)
Instance Method Summary collapse
-
#add_certificate(http) ⇒ Object
Configure ssl certificate to HTTP object === Argument *
http
– Net::HTTP object. -
#base_credential ⇒ Object
Get base credential.
-
#base_credential_type ⇒ Object
Get base credential type.
-
#credential(url) ⇒ Object
Get credential object === Argument *
url
– API request url. -
#set_config(*args) ⇒ Object
Clear cached variables on changing the configuration.
-
#third_party_credential(url) ⇒ Object
Get third party credential.
Methods included from Configuration
Instance Method Details
#add_certificate(http) ⇒ Object
Configure ssl certificate to HTTP object
Argument
-
http
– Net::HTTP object
56 57 58 59 60 61 62 63 64 |
# File 'lib/paypal-sdk/core/authentication.rb', line 56 def add_certificate(http) if base_credential.is_a? Credential::Certificate http.cert = base_credential.cert http.key = base_credential.key else http.cert = nil http.key = nil end end |
#base_credential ⇒ Object
Get base credential
24 25 26 27 28 29 30 31 |
# File 'lib/paypal-sdk/core/authentication.rb', line 24 def base_credential @base_credential ||= if config.cert_path Credential::Certificate.new(config) else Credential::Signature.new(config) end end |
#base_credential_type ⇒ Object
Get base credential type
34 35 36 |
# File 'lib/paypal-sdk/core/authentication.rb', line 34 def base_credential_type config.cert_path ? :certificate : :three_token end |
#credential(url) ⇒ Object
Get credential object
Argument
-
url
– API request url
19 20 21 |
# File 'lib/paypal-sdk/core/authentication.rb', line 19 def credential(url) third_party_credential(url) || base_credential end |
#set_config(*args) ⇒ Object
Clear cached variables on changing the configuration.
48 49 50 51 |
# File 'lib/paypal-sdk/core/authentication.rb', line 48 def set_config(*args) @base_credential = nil super end |
#third_party_credential(url) ⇒ Object
Get third party credential
39 40 41 42 43 44 45 |
# File 'lib/paypal-sdk/core/authentication.rb', line 39 def third_party_credential(url) if config.token and config.token_secret Credential::ThirdParty::Token.new(base_credential, config, url) elsif config.subject Credential::ThirdParty::Subject.new(base_credential, config) end end |