Class: PaypalAPI::Environment
- Inherits:
-
Object
- Object
- PaypalAPI::Environment
- Defined in:
- lib/paypal-api/environment.rb
Overview
PayPal environment info
Instance Attribute Summary collapse
-
#api_url ⇒ Object
readonly
PayPal API base URL.
-
#client_id ⇒ Object
PayPal client_id.
-
#client_secret ⇒ Object
readonly
PayPal client_secret.
-
#web_url ⇒ Object
readonly
PayPal web URL.
Instance Method Summary collapse
-
#initialize(client_id:, client_secret:, live: false) ⇒ Client
constructor
Initializes Environment.
-
#inspect ⇒ String
(also: #to_s)
Instance representation string.
-
#live? ⇒ Boolean
Checks if live environment enabled.
-
#sandbox? ⇒ Boolean
Checks if sandbox environment enabled.
Constructor Details
#initialize(client_id:, client_secret:, live: false) ⇒ Client
Initializes Environment
40 41 42 43 44 45 46 47 |
# File 'lib/paypal-api/environment.rb', line 40 def initialize(client_id:, client_secret:, live: false) @live = live || false @api_url = live ? LIVE_API_URL : SANDBOX_API_URL @web_url = live ? LIVE_WEB_URL : SANDBOX_WEB_URL @client_id = client_id @client_secret = client_secret freeze end |
Instance Attribute Details
#api_url ⇒ Object (readonly)
PayPal API base URL
27 28 29 |
# File 'lib/paypal-api/environment.rb', line 27 def api_url @api_url end |
#client_id ⇒ Object
PayPal client_id
21 22 23 |
# File 'lib/paypal-api/environment.rb', line 21 def client_id @client_id end |
#client_secret ⇒ Object (readonly)
PayPal client_secret
24 25 26 |
# File 'lib/paypal-api/environment.rb', line 24 def client_secret @client_secret end |
#web_url ⇒ Object (readonly)
PayPal web URL
30 31 32 |
# File 'lib/paypal-api/environment.rb', line 30 def web_url @web_url end |
Instance Method Details
#inspect ⇒ String Also known as: to_s
Instance representation string. Default was overwritten to hide secrets
53 54 55 |
# File 'lib/paypal-api/environment.rb', line 53 def inspect "#<#{self.class.name} live: #{@live}>" end |
#live? ⇒ Boolean
Checks if live environment enabled
63 64 65 |
# File 'lib/paypal-api/environment.rb', line 63 def live? @live end |
#sandbox? ⇒ Boolean
Checks if sandbox environment enabled
71 72 73 |
# File 'lib/paypal-api/environment.rb', line 71 def sandbox? !live? end |