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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6df72edfd99e5aae4c757a243a55e61f2a5ae24f
4
- data.tar.gz: 33cb3d394bb1d6d27b514c4092b25139947c583d
3
+ metadata.gz: 5455c8859db022c360849abcefa90d96a59bf093
4
+ data.tar.gz: 245f49ddaa195a53bd274e3a983e7f59ae3a09c6
5
5
  SHA512:
6
- metadata.gz: 1de146a6d24fe5cd27d0b6ac0f32bb91ee72d0019537f3cb58541f5a7fc3ffccb5c9523ae6fb94369412949d003e1b7ddb677e8733b81967814ecb2da791ebd7
7
- data.tar.gz: fa5fff1e23abc5352602ffaa4e1d8a2792d5bf03ecb2fc2cf321292942c3b5b110b85198d2d3a58b053b6a4df83f5f75b9a90037b6e9b7f109a25d0854f5c4ea
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
- # String(16) -- 16 numbers string
28
- # Raise:
29
- # pamameters type error
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
 
@@ -1,3 +1,3 @@
1
1
  module Codecal
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
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
- raise "parameter 1 type should be Integer and length not longer than 9" unless account_id.is_a?(Integer) && account_id.to_s.size <= 9
9
- raise "parameter 2 type should be String" unless currency.is_a?(String)
10
- currency_code = Code.new[currency.upcase]
11
- raise "currency not found" unless currency_code
12
- cal_array = ("%09d" % account_id + "%04d" % currency_code.to_i).split("").map! {|i| i.to_i}
13
- return code_calculate(cal_array, @@generate_seed)
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codecal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roger Fang