Module: LocoBill::Configuration

Defined in:
lib/loco_bill/configuration.rb

Constant Summary collapse

API_VERSION =

:nodoc:

"1.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

._session_idObject

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_timeObject

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

Parameters:

  • value

    the value to set the attribute application_key to.



7
8
9
# File 'lib/loco_bill/configuration.rb', line 7

def application_key=(value)
  @application_key = value
end

.debugObject

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

Parameters:

  • value

    the value to set the attribute org_id to.



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

Parameters:

  • value

    the value to set the attribute password to.



7
8
9
# File 'lib/loco_bill/configuration.rb', line 7

def password=(value)
  @password = value
end

.transaction_idObject

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

Parameters:

  • value

    the value to set the attribute username to.



7
8
9
# File 'lib/loco_bill/configuration.rb', line 7

def username=(value)
  @username = value
end

Class Method Details

.api_endpointObject



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

.serverObject

: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_idObject



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