Class: Braspag::Connection
- Inherits:
-
Object
- Object
- Braspag::Connection
- Defined in:
- lib/rbraspag/connection.rb
Defined Under Namespace
Classes: InvalidMerchantId
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#merchant_id ⇒ Object
readonly
Returns the value of attribute merchant_id.
Instance Method Summary collapse
-
#initialize(merchant_id, environment = :production) ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize(merchant_id, environment = :production) ⇒ Connection
Returns a new instance of Connection.
7 8 9 10 11 12 13 14 15 |
# File 'lib/rbraspag/connection.rb', line 7 def initialize(merchant_id, environment = :production) 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 environment = :test unless environment.eql? :production @environment = eval(environment.to_s.capitalize) @base_url = @environment::BASE_URL @merchant_id = merchant_id end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
5 6 7 |
# File 'lib/rbraspag/connection.rb', line 5 def base_url @base_url end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
5 6 7 |
# File 'lib/rbraspag/connection.rb', line 5 def environment @environment end |
#merchant_id ⇒ Object (readonly)
Returns the value of attribute merchant_id.
5 6 7 |
# File 'lib/rbraspag/connection.rb', line 5 def merchant_id @merchant_id end |