Class: Braspag::Connection
- Inherits:
-
Object
- Object
- Braspag::Connection
- Includes:
- Singleton
- Defined in:
- lib/rbraspag/connection.rb
Defined Under Namespace
Classes: InvalidBraspagUrl, InvalidEnv, InvalidMerchantId
Instance Attribute Summary collapse
-
#braspag_url ⇒ Object
readonly
Returns the value of attribute braspag_url.
-
#crypto_key ⇒ Object
readonly
Returns the value of attribute crypto_key.
-
#crypto_url ⇒ Object
readonly
Returns the value of attribute crypto_url.
-
#merchant_id ⇒ Object
readonly
Returns the value of attribute merchant_id.
Instance Method Summary collapse
-
#initialize ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize ⇒ Connection
Returns a new instance of Connection.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rbraspag/connection.rb', line 10 def initialize raise InvalidEnv if ENV["RACK_ENV"].nil? || ENV["RACK_ENV"].empty? = YAML.load_file("config/braspag.yml") = [ENV["RACK_ENV"]] merchant_id = ["merchant_id"] raise InvalidMerchantId unless merchant_id.length == 38 raise InvalidMerchantId unless merchant_id.match /\{[a-z0-9]{8}-([a-z0-9]{4}-){3}[a-z0-9]{12}\}/i raise InvalidBraspagUrl if ["braspag_url"].nil? || ["braspag_url"].empty? @crypto_key = ["crypto_key"] @crypto_url = ["crypto_url"] @braspag_url = ["braspag_url"] @merchant_id = merchant_id end |
Instance Attribute Details
#braspag_url ⇒ Object (readonly)
Returns the value of attribute braspag_url.
8 9 10 |
# File 'lib/rbraspag/connection.rb', line 8 def braspag_url @braspag_url end |
#crypto_key ⇒ Object (readonly)
Returns the value of attribute crypto_key.
8 9 10 |
# File 'lib/rbraspag/connection.rb', line 8 def crypto_key @crypto_key end |
#crypto_url ⇒ Object (readonly)
Returns the value of attribute crypto_url.
8 9 10 |
# File 'lib/rbraspag/connection.rb', line 8 def crypto_url @crypto_url end |
#merchant_id ⇒ Object (readonly)
Returns the value of attribute merchant_id.
8 9 10 |
# File 'lib/rbraspag/connection.rb', line 8 def merchant_id @merchant_id end |