ach_client 0.7.0 → 1.0.0

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
- SHA1:
3
- metadata.gz: a4f5db8a27b5ba348d4a2b98c3219350528ba763
4
- data.tar.gz: e067d4721f6225444a0c9d740cabe5b7bc4c2c8f
2
+ SHA256:
3
+ metadata.gz: 1592b86e14d743c487591e1a205a85ac072cf23a43e27a8dc8e6a7d8dd860acc
4
+ data.tar.gz: e4ad0a3ae01d345b4dbd8e224fd4d336737d297d82669af08a58d1b858c04dfc
5
5
  SHA512:
6
- metadata.gz: 3936c72ff9eff2330f3b06d8ead56d03d5c858cbe7ab783d9840f9c4da79751bb7c8c94658551e22da0cfa7a53d2cee7449505c2ea7da52d022f5f046a8b288f
7
- data.tar.gz: b207d8ac87d006dcb3c3aebc81107db555583ee88eab300e0c2277a7c8531d613a76316c22ee3d157202ec73f1a9b5155dfb9ee2cbf127f7b335b2b929566074
6
+ metadata.gz: 9a6cbf086b1b6424fcdd034a4131403c00d5e04bf74a01a86176b6c9ff0d24cc8e40020005b3bb06c194b9dd890999c08d82d2c79cd271e510d73cfe9975f910
7
+ data.tar.gz: 7130cdd271cecff3efd4297284ccca59d36985eca2868b1df9c3dc2ce1eed6d986b1b633127e025b8bea175387be9a25d5b4eaa1f925be27f847e5c6ff90bf96
@@ -1 +1 @@
1
- 2.4.2
1
+ 2.5.0
@@ -1 +1 @@
1
- ruby 2.4.2
1
+ ruby 2.5.0
@@ -0,0 +1 @@
1
+ ruby 2.5.0
data/README.md CHANGED
@@ -163,7 +163,9 @@ To check statuses:
163
163
  ```
164
164
 
165
165
  Both of these methods return a `Hash` with the `external_ach_id` for ach_transaction as the keys and
166
- instances of AchClient::AchResponse as values.
166
+ a list of instances of AchClient::AchResponse as values. A polling response may contain
167
+ more than one response record for each `external_ach_id` if that ACH has changed
168
+ statuses more than once within the polling range.
167
169
 
168
170
  ### Responses
169
171
 
@@ -0,0 +1,17 @@
1
+ module AchClient
2
+ class Helpers
3
+ class Utils
4
+ # Given a list of hashes where the hashes values are lists, merge the
5
+ # list of hashes by appending the two lists when there is a key
6
+ # collision
7
+ # @param hashlist [Array(Hash{String => Array})]
8
+ def self.hashlist_merge(hashlist)
9
+ hashlist.reduce do |map, record|
10
+ map.merge(record) do |_key, left_value, right_value|
11
+ left_value + right_value
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -4,15 +4,15 @@ module AchClient
4
4
  # Interface for polling provider for ACH status responses
5
5
  class AchStatusChecker
6
6
  # Wrapper for a provider's "most recent bucket"
7
- # @return [Hash{String => AchClient::AchResponse}] Hash with provider's
8
- # external ACH id as the key, AchResponse objects as values
7
+ # @return [Hash{String => [AchClient::AchResponse]}] Hash with provider's
8
+ # external ACH id as the key, list of AchResponse objects as values
9
9
  def self.most_recent
10
10
  raise AbstractMethodError
11
11
  end
12
12
 
13
13
  # Wrapper for a providers range response endpoint
14
- # @return [Hash{String => AchClient::AchResponse}] Hash with provider's
15
- # external ACH id as the key, AchResponse objects as values
14
+ # @return [Hash{String => [AchClient::AchResponse]}] Hash with provider's
15
+ # external ACH id as the key, list of AchResponse objects as values
16
16
  def self.in_range(*)
17
17
  raise AbstractMethodError
18
18
  end
@@ -6,8 +6,9 @@ module AchClient
6
6
  ##
7
7
  # Gets the status of ach transactions since the last time we ran this
8
8
  # method
9
- # @return [Hash{String => AchClient::AchResponse}] Hash with
10
- # individual_id_number values as keys, AchResponse objects as values
9
+ # @return [Hash{String => [AchClient::AchResponse]}] Hash with
10
+ # individual_id_number values as keys, list of AchResponse objects
11
+ # as values
11
12
  def self.most_recent
12
13
  process_files(most_recent_files)
13
14
  end
@@ -16,8 +17,9 @@ module AchClient
16
17
  # Gets the status of ach transactions between the given dates
17
18
  # @param start_date [String] lower bound of date ranged status query
18
19
  # @param end_date [String] upper bound of date ranged status query
19
- # @return [Hash{String => AchClient::AchResponse}] Hash with
20
- # individual_id_number values as keys, AchResponse objects as values
20
+ # @return [Hash{String => [AchClient::AchResponse]}] Hash with
21
+ # individual_id_number values as keys, list of AchResponse objects as
22
+ # values
21
23
  def self.in_range(start_date:, end_date:)
22
24
  in_range = {}
23
25
  self.parent.with_sftp_connection do |connection|
@@ -33,14 +35,16 @@ module AchClient
33
35
  end
34
36
 
35
37
  private_class_method def self.process_files(files)
36
- (files || []).reduce({}) do |acc, entry|
37
- ACH::ACHFile.new(entry.last).batches.map do |batch|
38
- batch.entries.map do |ach|
39
- # return trace ==> response
40
- { ach.individual_id_number => process_ach(batch, ach) }
41
- end.reduce({}, &:merge)
42
- end.reduce({}, &:merge).merge(acc)
43
- end
38
+ Helpers::Utils.hashlist_merge(
39
+ (files || []).reduce([]) do |acc, entry|
40
+ ACH::ACHFile.new(entry.last).batches.map do |batch|
41
+ batch.entries.map do |ach|
42
+ # return trace ==> response
43
+ { ach.individual_id_number => [process_ach(batch, ach)] }
44
+ end
45
+ end.reduce([], &:+) + acc
46
+ end
47
+ )
44
48
  end
45
49
 
46
50
  private_class_method def self.process_ach(batch, ach)
@@ -49,21 +49,25 @@ module AchClient
49
49
  if response[:total_num_records] == '0'
50
50
  []
51
51
  else
52
- response[:ach_return_records][:ach_return_record].select do |record|
53
- # Exclude records with no front end trace
54
- # They are probably 9BNK response codes, not actual transactions
55
- # 9BNK is when AchWorks gives us an aggregate record, containing
56
- # the total debit/credit to your actual bank account.
57
- # We don't care about those here.
58
- record[:front_end_trace].present?
59
- end.map do |record|
60
- {
61
- # Strips the first characther because it is always the added Z
62
- record[:front_end_trace][1..-1] =>
63
- AchClient::AchWorks::ResponseRecordProcessor
64
- .process_response_record(record)
65
- }
66
- end.reduce(&:merge)
52
+ Helpers::Utils.hashlist_merge(
53
+ response[:ach_return_records][:ach_return_record].select do |record|
54
+ # Exclude records with no front end trace
55
+ # They are probably 9BNK response codes, not actual transactions
56
+ # 9BNK is when AchWorks gives us an aggregate record, containing
57
+ # the total debit/credit to your actual bank account.
58
+ # We don't care about those here.
59
+ record[:front_end_trace].present?
60
+ end.map do |record|
61
+ {
62
+ # Strips the first characther because it is always the added Z
63
+ record[:front_end_trace][1..-1] =>
64
+ [
65
+ AchClient::AchWorks::ResponseRecordProcessor
66
+ .process_response_record(record)
67
+ ]
68
+ }
69
+ end
70
+ )
67
71
  end
68
72
  end
69
73
 
@@ -35,26 +35,30 @@ module AchClient
35
35
  end
36
36
 
37
37
  # Wrapper for the range response endpoint
38
- # @return [Hash{String => AchClient::AchResponse}] Hash with confirmation
39
- # number as the key, AchResponse objects as values
38
+ # @return [Hash{String => [AchClient::AchResponse]}] Hash with
39
+ # confirmation number as the key, lists of AchResponse objects as values
40
40
  def self.in_range(start_date:, end_date:)
41
- AchClient::ICheckGateway.wrap_request(
42
- method: :pull_transaction_report,
43
- message: AchClient::ICheckGateway::CompanyInfo.build.to_hash.merge({
44
- startDate: start_date,
45
- endDate: end_date
46
- })
47
- ).split("\n").select do |record|
48
- check_for_errors(record)
49
- # Ignore credit card swipes if there are any
50
- record.start_with?('ICHECK')
51
- end.map do |record|
52
- {
53
- record.split('|')[3] =>
54
- AchClient::ICheckGateway::ResponseRecordProcessor
55
- .process_response_record(record)
56
- }
57
- end.reduce(&:merge)
41
+ Helpers::Utils.hashlist_merge(
42
+ AchClient::ICheckGateway.wrap_request(
43
+ method: :pull_transaction_report,
44
+ message: AchClient::ICheckGateway::CompanyInfo.build.to_hash.merge({
45
+ startDate: start_date,
46
+ endDate: end_date
47
+ })
48
+ ).split("\n").select do |record|
49
+ check_for_errors(record)
50
+ # Ignore credit card swipes if there are any
51
+ record.start_with?('ICHECK')
52
+ end.map do |record|
53
+ {
54
+ record.split('|')[3] =>
55
+ [
56
+ AchClient::ICheckGateway::ResponseRecordProcessor
57
+ .process_response_record(record)
58
+ ]
59
+ }
60
+ end
61
+ )
58
62
  end
59
63
  end
60
64
  end
@@ -1,4 +1,4 @@
1
1
  module AchClient
2
2
  # Increment this when changes are published
3
- VERSION = '0.7.0'
3
+ VERSION = '1.0.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ach_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Cotter
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-07 00:00:00.000000000 Z
11
+ date: 2018-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ach
@@ -274,6 +274,7 @@ files:
274
274
  - ".rubocop.yml"
275
275
  - ".ruby-version"
276
276
  - ".tool-versions"
277
+ - ".tool-versions-e"
277
278
  - ".travis.yml"
278
279
  - Gemfile
279
280
  - README.md
@@ -286,6 +287,7 @@ files:
286
287
  - lib/ach_client/abstract/abstract_method_error.rb
287
288
  - lib/ach_client/abstract/invalid_ach_transaction_error.rb
288
289
  - lib/ach_client/helpers/dollars_to_cents.rb
290
+ - lib/ach_client/helpers/utils.rb
289
291
  - lib/ach_client/logging/log_provider_job.rb
290
292
  - lib/ach_client/logging/log_providers/log_provider.rb
291
293
  - lib/ach_client/logging/log_providers/null_log_provider.rb
@@ -355,7 +357,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
355
357
  version: '0'
356
358
  requirements: []
357
359
  rubyforge_project:
358
- rubygems_version: 2.6.14
360
+ rubygems_version: 2.7.3
359
361
  signing_key:
360
362
  specification_version: 4
361
363
  summary: Adapter to interact with various ACH service providers