Class: Teligem

Inherits:
Object
  • Object
show all
Defined in:
lib/teligem.rb

Instance Method Summary collapse

Constructor Details

#initializeTeligem

Returns a new instance of Teligem.



6
7
8
# File 'lib/teligem.rb', line 6

def initialize
  @configs = YAML.load_file("config/secrets.yml")
end

Instance Method Details

#check_status(status) ⇒ Object

check_status(status)

Return true if status is 1 (valid) Otherwise return false



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/teligem.rb', line 36

def check_status(status)
  case status.to_i
  when 1 # Valid
    true
  when 2 # Rejected
    false
  when 3 # Differed
    false
  when 4 # Test
    false
  else
    false
  end
end

#get_earning(point_name) ⇒ Object

get_earning(point_name)

Get earning from the hash Teligem::EARNING Hash exemple: Teligem::EARNING = { “FRSMS10” => 10,

"FRSMS20" => 20

} Return 0 if key unknown



59
60
61
62
63
64
# File 'lib/teligem.rb', line 59

def get_earning(point_name)
  if Teligem::EARNING[point_name].nil?
    return 0
  end
  return Teligem::EARNING[point_name]
end

#security_check(params) ⇒ Object

security_check(params)

Hash that must at least contains:

  • security_code: the security code sent by telipass

  • enduser_ip: the enduser ip address

  • ntu: unique transaction number sent by telipass



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/teligem.rb', line 15

def security_check(params)
  security_code = params[:security_code]
  enduser_ip    = params[:enduser_ip]
  ntu           = params[:ntu]

  unless security_code.nil? || enduser_ip.nil? || ntu.nil?
    hash = get_security_code(enduser_ip, ntu)
  end

  if !hash.nil? && (security_code == hash)
    response = true
  else
    response = false
  end

  return response
end