Module: LocoBill::Configuration
- Defined in:
- lib/loco_bill/configuration.rb
Constant Summary collapse
- API_VERSION =
:nodoc:
"1.0"
Class Attribute Summary collapse
-
._session_id ⇒ Object
Returns the value of attribute _session_id.
-
._session_id_expiration_time ⇒ Object
Returns the value of attribute _session_id_expiration_time.
-
.application_key ⇒ Object
writeonly
Sets the attribute application_key.
-
.debug ⇒ Object
Returns the value of attribute debug.
-
.org_id ⇒ Object
writeonly
Sets the attribute org_id.
-
.password ⇒ Object
writeonly
Sets the attribute password.
-
.transaction_id ⇒ Object
Returns the value of attribute transaction_id.
-
.username ⇒ Object
writeonly
Sets the attribute username.
Class Method Summary collapse
- .api_endpoint ⇒ Object
- .environment=(env) ⇒ Object
-
.expectant_reader(*attributes) ⇒ Object
:nodoc:.
-
.server ⇒ Object
:nodoc:.
- .session_id ⇒ Object
- .session_id=(session_id) ⇒ Object
Class Attribute Details
._session_id ⇒ Object
Returns the value of attribute _session_id.
6 7 8 |
# File 'lib/loco_bill/configuration.rb', line 6 def _session_id @_session_id end |
._session_id_expiration_time ⇒ Object
Returns the value of attribute _session_id_expiration_time.
6 7 8 |
# File 'lib/loco_bill/configuration.rb', line 6 def _session_id_expiration_time @_session_id_expiration_time end |
.application_key=(value) ⇒ Object (writeonly)
Sets the attribute application_key
7 8 9 |
# File 'lib/loco_bill/configuration.rb', line 7 def application_key=(value) @application_key = value end |
.debug ⇒ Object
Returns the value of attribute debug.
6 7 8 |
# File 'lib/loco_bill/configuration.rb', line 6 def debug @debug end |
.org_id=(value) ⇒ Object (writeonly)
Sets the attribute org_id
7 8 9 |
# File 'lib/loco_bill/configuration.rb', line 7 def org_id=(value) @org_id = value end |
.password=(value) ⇒ Object (writeonly)
Sets the attribute password
7 8 9 |
# File 'lib/loco_bill/configuration.rb', line 7 def password=(value) @password = value end |
.transaction_id ⇒ Object
Returns the value of attribute transaction_id.
6 7 8 |
# File 'lib/loco_bill/configuration.rb', line 6 def transaction_id @transaction_id end |
.username=(value) ⇒ Object (writeonly)
Sets the attribute username
7 8 9 |
# File 'lib/loco_bill/configuration.rb', line 7 def username=(value) @username = value end |
Class Method Details
.api_endpoint ⇒ Object
28 29 30 |
# File 'lib/loco_bill/configuration.rb', line 28 def self.api_endpoint "/crudApi" end |
.environment=(env) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/loco_bill/configuration.rb', line 21 def self.environment=(env) unless [:sandbox, :production].include?(env) raise ArgumentError, "#{env.inspect} is not a valid environment" end @environment = env end |
.expectant_reader(*attributes) ⇒ Object
:nodoc:
10 11 12 13 14 15 16 17 18 |
# File 'lib/loco_bill/configuration.rb', line 10 def self.expectant_reader(*attributes) # :nodoc: attributes.each do |attribute| (class << self; self; end).send(:define_method, attribute) do attribute_value = instance_variable_get("@#{attribute}") raise "#{attribute} needs to be set" unless attribute_value attribute_value end end end |
.server ⇒ Object
:nodoc:
44 45 46 47 48 49 50 51 |
# File 'lib/loco_bill/configuration.rb', line 44 def self.server # :nodoc: case environment when :production "api.bill.com" when :sandbox "api-test.cashview.com" end end |
.session_id ⇒ Object
32 33 34 35 |
# File 'lib/loco_bill/configuration.rb', line 32 def self.session_id # only return a session_id if we have one + it hasn't expired self._session_id.present? && Time.now < self._session_id_expiration_time ? self._session_id : nil end |
.session_id=(session_id) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/loco_bill/configuration.rb', line 37 def self.session_id=(session_id) self._session_id=session_id self._session_id_expiration_time=Time.now+30.minutes # 35 minutes is the actual session expiration time, but we just rounded it off... self._session_id end |