codecal 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -6
- data/lib/codecal/version.rb +1 -1
- data/lib/codecal.rb +11 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5455c8859db022c360849abcefa90d96a59bf093
|
4
|
+
data.tar.gz: 245f49ddaa195a53bd274e3a983e7f59ae3a09c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94a00ad0234e9243152a714a2b1f4143140fe0d5ac82ac89d44843029ceb27c493b2064281bff3ccf3f9d5e251c2d3827f096c3d63095bb1c3fe2a2708bf7c01
|
7
|
+
data.tar.gz: fd44d3b82d3f007a6330cde77df12c3219ef7b913755530118c160ddbca3fe2687e4cfc0819c6337d40c12c89dbc6da1eb4c9a83736ffad4b7c1bf57b67be350
|
data/README.md
CHANGED
@@ -23,11 +23,10 @@ require 'codecal'
|
|
23
23
|
# Parameters:
|
24
24
|
# account_id : Integer(<=9) --user account_id in acx
|
25
25
|
# currency : String --currency name
|
26
|
-
# Return:
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
# currency not found
|
26
|
+
# Return: Hash
|
27
|
+
# success : boolean -- generate customer code success
|
28
|
+
# customer code : String -- 16 numbers string when success == true
|
29
|
+
# error : String -- error message of parameters when success == false
|
31
30
|
Codecal.bank_customer_code_generate(account_id, currency)
|
32
31
|
|
33
32
|
# Validate customer code
|
@@ -35,6 +34,5 @@ Codecal.bank_customer_code_generate(account_id, currency)
|
|
35
34
|
# customer_code : String
|
36
35
|
# Return:
|
37
36
|
# boolean
|
38
|
-
# Return String
|
39
37
|
Codecal.validate_bank_customer_code(String)
|
40
38
|
|
data/lib/codecal/version.rb
CHANGED
data/lib/codecal.rb
CHANGED
@@ -5,12 +5,17 @@ module Codecal
|
|
5
5
|
@@generate_seed = [2,7,5,3,8,9,5,9,1,6,7,3,5]
|
6
6
|
class<<self
|
7
7
|
def bank_customer_code_generate(account_id, currency)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
errormsg = ""
|
9
|
+
errormsg += "parameter 1 type should be Integer and length not longer than 9. " unless account_id.is_a?(Integer) && account_id.to_s.size <= 9
|
10
|
+
currency.is_a?(String) ? currency.upcase! : errormsg += "parameter 2 type should be String. "
|
11
|
+
currency_code = Code.new[currency]
|
12
|
+
errormsg += "currency not found. " unless currency_code
|
13
|
+
if errormsg.size == 0
|
14
|
+
cal_array = ("%09d" % account_id + "%04d" % currency_code.to_i).split("").map! {|i| i.to_i}
|
15
|
+
{success:true,customer_code: code_calculate(cal_array, @@generate_seed) }
|
16
|
+
else
|
17
|
+
{success:false, error: errormsg}
|
18
|
+
end
|
14
19
|
end
|
15
20
|
|
16
21
|
def validate_bank_customer_code(customer_code)
|