cashbox 0.0.28 → 0.0.29

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5ee5fff97665fd2a7ac1653360cad18dd8420a9
4
- data.tar.gz: c0eccb6bb6e081c1680844ec2bceffb16939c4ee
3
+ metadata.gz: 494c2c2038e3a5a9cd16a08e9150edb1bdb21bb3
4
+ data.tar.gz: b5855dcc9b3cb371522c85d7a14f50d9a6862832
5
5
  SHA512:
6
- metadata.gz: bf4cd3b4749712c725474fe0215438adb6d62f37eb040e80ed581b0831e2139fe240e559f84abceea2b575f94f9c84b01d8e25b2c148c2d769af30dd25959fd2
7
- data.tar.gz: ad9099c7e3f06d8a9f569d17464d10c8f8269348f6a5a1d9de335ff57950fde02ff07da3304e36ceb4c789a2b091905bca76ad21a337c21287d8310279b57521
6
+ metadata.gz: 80e0b9ad17debe098926bec454b55f1c21725a4394f2d6cb60f3f02a9b1fbdafb6373cb6b8cfca58b4049fef8650c6df6c29f40b51df5293e129ef9c7a88342b
7
+ data.tar.gz: bbc2a88cbb06761a6a2028984c9a0abfccd2aacd010668b0c396fa70fe2d78bf3b62d4952b3fb9948d7ae639695eb627b8d85c430b4abaaa81d426310a1b2fbc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cashbox (0.0.28)
4
+ cashbox (0.0.29)
5
5
  activesupport
6
6
  addressable
7
7
  hashie
@@ -2,11 +2,24 @@ module Cashbox
2
2
  class CreditCard < Model
3
3
  include Concern::Objectable
4
4
 
5
+ MASTER_CARD = 'MasterCard'
6
+ VISA = 'Visa'
7
+
8
+ BIN_PREFIXES = {
9
+ '2' => MASTER_CARD,
10
+ '5' => MASTER_CARD,
11
+ '4' => VISA
12
+ }
13
+
5
14
  property :vid
6
15
  property :account
7
16
  property :account_length
8
17
  property :bin
9
18
  property :expiration_date
10
19
  property :last_digits
20
+
21
+ def network
22
+ BIN_PREFIXES[bin.to_s[0]]
23
+ end
11
24
  end
12
25
  end
@@ -4,6 +4,9 @@ module Cashbox
4
4
  include Rest::ReadWrite
5
5
  include Rest::Archive
6
6
 
7
+ CREDIT_CARD = 'CreditCard'
8
+ DIRECT_DEBIT = 'DirectDebit'
9
+
7
10
  property :id
8
11
  property :vid
9
12
  property :created, coerce: Cashbox::Type.DateTime
@@ -18,11 +21,11 @@ module Cashbox
18
21
  property :validation_status
19
22
 
20
23
  def credit_card?
21
- type == "CreditCard"
24
+ type == CREDIT_CARD
22
25
  end
23
26
 
24
27
  def direct_debit?
25
- type == "DirectDebit"
28
+ type == DIRECT_DEBIT
26
29
  end
27
30
 
28
31
  def last_digits
@@ -30,10 +33,7 @@ module Cashbox
30
33
  end
31
34
 
32
35
  def card_network
33
- return unless type == "CreditCard"
34
- bin_number = credit_card.bin.to_s
35
- return "Visa" if bin_number.start_with?("4")
36
- return "Master Card" if bin_number.start_with?("2", "5")
36
+ credit_card.network unless direct_debit?
37
37
  end
38
38
  end
39
39
  end
@@ -1,3 +1,3 @@
1
1
  module Cashbox
2
- VERSION = "0.0.28"
2
+ VERSION = "0.0.29"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cashbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.28
4
+ version: 0.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathon Storer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-18 00:00:00.000000000 Z
11
+ date: 2018-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler