Class: Petra
- Inherits:
-
Object
- Object
- Petra
- Defined in:
- lib/petra_sdk.rb
Instance Attribute Summary collapse
-
#production ⇒ Object
Returns the value of attribute production.
-
#secret_key ⇒ Object
Returns the value of attribute secret_key.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #base_url ⇒ Object
-
#initialize(secret_key = nil) ⇒ Petra
constructor
A new instance of Petra.
Constructor Details
#initialize(secret_key = nil) ⇒ Petra
Returns a new instance of Petra.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/petra_sdk.rb', line 12 def initialize(secret_key = nil) @secret_key = secret_key petra_base_url = BASE_ENDPOINTS::PETRA_BASE_URL @url = petra_base_url def base_url url end @secret_key = if secret_key.nil? ENV['PETRA_SECRET_KEY'] else secret_key end warn 'Warning: To ensure your petra_sdk account api keys are safe, It is best to always set your keys in the environment variable' # raise this error if no secret key is passed if @secret_key.nil? raise PetraBadKeyError, "No secret key supplied and couldn't find any in environment variables. Make sure to set secret key as an environment variable PETRA_SECRET_KEY" end # raise this error if invalid secret key is passed # unless @secret_key[0..7] == 'sk_live' || @secret_key[0..7] == 'sk_test' # raise PetraBadKeyError, "Invalid secret key #{@secret_key}" # end end |
Instance Attribute Details
#production ⇒ Object
Returns the value of attribute production.
10 11 12 |
# File 'lib/petra_sdk.rb', line 10 def production @production end |
#secret_key ⇒ Object
Returns the value of attribute secret_key.
10 11 12 |
# File 'lib/petra_sdk.rb', line 10 def secret_key @secret_key end |
#url ⇒ Object
Returns the value of attribute url.
10 11 12 |
# File 'lib/petra_sdk.rb', line 10 def url @url end |
Instance Method Details
#base_url ⇒ Object
17 18 19 |
# File 'lib/petra_sdk.rb', line 17 def base_url url end |