fat_zebra 3.0.2 → 3.0.3

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: b9a4b0c24c9b0a769d463452e4c1826477908e7c
4
- data.tar.gz: e023bcc5106aad407e116d72db57c81c3c9b0c0f
3
+ metadata.gz: 57875bf7e3c1fb775a6fd1dd26ccd44f5d145abf
4
+ data.tar.gz: fe734d0bb133c3fe08aaab48921e4d95f808019b
5
5
  SHA512:
6
- metadata.gz: 85db673360acbb895e0e5560eedc8bf5a6683417173769266232e0dc8a61a97a1d5a56ab4ae4065a8c696e679ed7798923dd021077f16c8b4e6f5a20e7e28910
7
- data.tar.gz: 04a5cc56c681b18ebd1ab9c26ff573c5903d1a3aa79c1eafe12852a3d8f8314139ffbe10ed2052c100db2eb66689a841bb94ce46c894d0be307ee86aea71aa33
6
+ metadata.gz: e20f23ef8ea97426baefa11501cd720222793b13417e03ec29e6b16ae55f3c2989e5114fdc38e23a733f018beae019170d69a9ea1e29e8a8c874fa1b30a7dc3c
7
+ data.tar.gz: 363f87999dadd14104e2594572f8bd906cdb07275519ba510db42060d5a07e2e4aa92b09d2079ee943fddacde2b56878d80960399a7b51277feb9c9e943a3055
@@ -17,9 +17,9 @@ module FatZebra
17
17
  include FatZebra::APIOperation::Save
18
18
  include FatZebra::APIOperation::Delete
19
19
 
20
- validates :filename, required: true, class_type: String, on: :create
21
- validates :file, required: true, class_type: File, on: :create
22
- validates :multipart, required: true, class_type: TrueClass, on: :create
20
+ validates :filename, required: true, type: :batch_filename, on: :create
21
+ validates :file, required: true, type: :file_type, on: :create
22
+ validates :multipart, required: true, type: :boolean, on: :create
23
23
 
24
24
  class << self
25
25
 
@@ -17,7 +17,7 @@ module FatZebra
17
17
  include FatZebra::APIOperation::Delete
18
18
 
19
19
  validates :description, required: true, on: :create
20
- validates :amount, required: true, class_type: Integer, on: :create
20
+ validates :amount, required: true, type: :positive_numeric, on: :create
21
21
  validates :bsb, required: true, on: :create
22
22
  validates :account_name, required: true, on: :create
23
23
  validates :account_number, required: true, on: :create
@@ -17,7 +17,7 @@ module FatZebra
17
17
  include FatZebra::APIOperation::Delete
18
18
 
19
19
  validates :description, required: true, on: :create
20
- validates :amount, required: true, class_type: Integer, on: :create
20
+ validates :amount, required: true, type: :positive_numeric, on: :create
21
21
  validates :bsb, required: true, on: :create
22
22
  validates :account_name, required: true, on: :create
23
23
  validates :account_number, required: true, on: :create
@@ -22,7 +22,7 @@ module FatZebra
22
22
  validates :card_number, required: { unless: %i[card_token wallet] }, on: :create
23
23
  validates :card_token, required: { unless: %i[card_number wallet] }, on: :create
24
24
  validates :card_expiry, required: { unless: %i[card_token wallet] }, on: :create
25
- validates :amount, required: true, class_type: Integer, on: :create
25
+ validates :amount, required: true, type: :positive_integer, on: :create
26
26
  validates :reference, required: true, on: :create
27
27
  validates :customer_ip, required: true, on: :create
28
28
 
@@ -39,8 +39,24 @@ module FatZebra
39
39
  errors << "'#{field}' is required" if params[field].nil? || params[field] == ''
40
40
  end
41
41
 
42
- def validate_class_type(field, options, params)
43
- errors << "'#{field}' is not a '#{options}'" unless params[field].is_a?(options)
42
+ def validate_type(field, options, params)
43
+ regexp =
44
+ case options
45
+ when :positive_numeric
46
+ /\A\d*\.?\d+\z/
47
+ when :positive_integer
48
+ /\A\d*\z/
49
+ when :batch_filename
50
+ /\ABATCH-(?<version>v\d)-(?<type>[A-Z]*)-((?<merchant_username>[A-Z0-9]*\-?[A-Z0-9]*)-)?(?<process_date>\d{8})-(?<reference>[a-zA-Z0-9\-_]*).csv\z/i
51
+ when :file_type
52
+ /\A\#\<File\:.*\z/
53
+ when :boolean
54
+ /\Atrue|false\z/
55
+ else
56
+ raise RequestValidationError, "Unknown type #{options} for #{field}"
57
+ end
58
+
59
+ errors << "'#{field}' is not a '#{options}'" unless params[field].to_s =~ regexp
44
60
  end
45
61
 
46
62
  end
@@ -1,3 +1,3 @@
1
1
  module FatZebra
2
- VERSION = '3.0.2'.freeze
2
+ VERSION = '3.0.3'.freeze
3
3
  end
@@ -0,0 +1,54 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.sandbox.fatzebra.com.au/v1.0/direct_credits
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"description":"Confirmation","amount":42.42,"bsb":"123-123","account_name":"Test","account_number":"012345678","test":true}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Ruby
16
+ Authorization:
17
+ - Basic VEVTVDpURVNU
18
+ Content-Type:
19
+ - application/json
20
+ response:
21
+ status:
22
+ code: 201
23
+ message: Created
24
+ headers:
25
+ Date:
26
+ - Thu, 05 Oct 2017 04:32:57 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ Status:
34
+ - 201 Created
35
+ Cache-Control:
36
+ - no-store
37
+ X-Request-Version:
38
+ - 1.20.4
39
+ Pragma:
40
+ - no-cache
41
+ X-Request-Id:
42
+ - 304387854316f4399af6ecf6f8bb7eb3
43
+ X-Runtime:
44
+ - '0.037728'
45
+ X-Rack-Cache:
46
+ - invalidate, pass
47
+ X-Backend:
48
+ - sbox-priv-gateway-a
49
+ body:
50
+ encoding: UTF-8
51
+ string: '{"successful":true,"response":{"id":"071-DC-XVIW0KJG","amount":42.42,"bsb":"123-123","account_number":"012345678","account_name":"Test","description":"Confirmation","reference":"071-DC-XVIW0KJG","date":"2017-10-05","process_date":null,"status":"New","result":null,"metadata":{}},"errors":[],"test":true}'
52
+ http_version:
53
+ recorded_at: Thu, 05 Oct 2017 04:32:57 GMT
54
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,54 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.sandbox.fatzebra.com.au/v1.0/direct_debits
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"description":"Confirmation","amount":42.42,"bsb":"123-123","account_name":"Test","account_number":"012345678","test":true}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Ruby
16
+ Authorization:
17
+ - Basic VEVTVDpURVNU
18
+ Content-Type:
19
+ - application/json
20
+ response:
21
+ status:
22
+ code: 201
23
+ message: Created
24
+ headers:
25
+ Date:
26
+ - Thu, 05 Oct 2017 04:28:44 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ Status:
34
+ - 201 Created
35
+ Cache-Control:
36
+ - no-store
37
+ X-Request-Version:
38
+ - 1.20.4
39
+ Pragma:
40
+ - no-cache
41
+ X-Request-Id:
42
+ - 2b5ea6816467df484d4649cc7a56932e
43
+ X-Runtime:
44
+ - '0.035993'
45
+ X-Rack-Cache:
46
+ - invalidate, pass
47
+ X-Backend:
48
+ - sbox-priv-gateway-a
49
+ body:
50
+ encoding: UTF-8
51
+ string: '{"successful":true,"response":{"id":"071-DD-551C0W7W","amount":42.42,"bsb":"123-123","account_number":"012345678","account_name":"Test","description":"Confirmation","reference":"071-DD-551C0W7W","date":"2017-10-05","process_date":null,"status":"New","result":null,"metadata":{}},"errors":[],"test":true}'
52
+ http_version:
53
+ recorded_at: Thu, 05 Oct 2017 04:28:44 GMT
54
+ recorded_with: VCR 3.0.3
@@ -19,9 +19,17 @@ describe FatZebra::DirectCredit do
19
19
  it { expect(direct_credit.id).to_not be_empty }
20
20
 
21
21
  context 'validations' do
22
- let(:valid_direct_credit_payload) {{}}
22
+ context 'valid' do
23
+ before { valid_direct_credit_payload[:amount] = 42.42 }
23
24
 
24
- it { expect{ direct_credit }.to raise_error(FatZebra::RequestValidationError) }
25
+ it { is_expected.to be_accepted }
26
+ end
27
+
28
+ context 'failed' do
29
+ let(:valid_direct_credit_payload) {{}}
30
+
31
+ it { expect{ direct_credit }.to raise_error(FatZebra::RequestValidationError) }
32
+ end
25
33
  end
26
34
  end
27
35
 
@@ -19,9 +19,17 @@ describe FatZebra::DirectDebit do
19
19
  it { expect(direct_debit.id).to_not be_empty }
20
20
 
21
21
  context 'validations' do
22
- let(:valid_direct_debit_payload) {{}}
22
+ context 'valid' do
23
+ before { valid_direct_debit_payload[:amount] = 42.42 }
23
24
 
24
- it { expect{ direct_debit }.to raise_error(FatZebra::RequestValidationError) }
25
+ it { is_expected.to be_accepted }
26
+ end
27
+
28
+ context 'failed' do
29
+ let(:valid_direct_debit_payload) {{}}
30
+
31
+ it { expect{ direct_debit }.to raise_error(FatZebra::RequestValidationError) }
32
+ end
25
33
  end
26
34
  end
27
35
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fat_zebra
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Savage
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-18 00:00:00.000000000 Z
11
+ date: 2017-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -209,6 +209,7 @@ files:
209
209
  - spec/cassettes/FatZebra_DirectCredit/_create/1_1_4.yml
210
210
  - spec/cassettes/FatZebra_DirectCredit/_create/1_1_5.yml
211
211
  - spec/cassettes/FatZebra_DirectCredit/_create/validations/1_1_5_1.yml
212
+ - spec/cassettes/FatZebra_DirectCredit/_create/validations/valid/1_1_5_1_1.yml
212
213
  - spec/cassettes/FatZebra_DirectCredit/_delete/1_4_1.yml
213
214
  - spec/cassettes/FatZebra_DirectCredit/_delete/1_4_2.yml
214
215
  - spec/cassettes/FatZebra_DirectCredit/_find/1_2_1.yml
@@ -222,6 +223,7 @@ files:
222
223
  - spec/cassettes/FatZebra_DirectDebit/_create/1_1_4.yml
223
224
  - spec/cassettes/FatZebra_DirectDebit/_create/1_1_5.yml
224
225
  - spec/cassettes/FatZebra_DirectDebit/_create/validations/1_1_5_1.yml
226
+ - spec/cassettes/FatZebra_DirectDebit/_create/validations/valid/1_1_5_1_1.yml
225
227
  - spec/cassettes/FatZebra_DirectDebit/_delete/1_4_1.yml
226
228
  - spec/cassettes/FatZebra_DirectDebit/_delete/1_4_2.yml
227
229
  - spec/cassettes/FatZebra_DirectDebit/_find/1_2_1.yml