wire_client 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wire_client/account/account.rb +14 -19
- data/lib/wire_client/base/account_transaction_helpers.rb +31 -0
- data/lib/wire_client/messages/credit_transfer.rb +6 -7
- data/lib/wire_client/messages/direct_debit.rb +4 -5
- data/lib/wire_client/messages/message.rb +13 -18
- data/lib/wire_client/providers/base/wire_batch.rb +23 -7
- data/lib/wire_client/transaction/transaction.rb +15 -3
- data/lib/wire_client/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e53215215f03709ef8df3daa7fa130af6d57ceefc4c1bcb3aaec38d679ae007
|
4
|
+
data.tar.gz: a68bab84ea944f30839b31773aba3eaccaebea3f529788b40ad77541cd0ebdae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 153180ab9e2aac835e68d27e19b5190de1ed74c250d26a91af34ecff6aedcc5cad605fb33d0e03be4f46a180a39d2281bc49749fe68a899c4e6303cfe16371a5
|
7
|
+
data.tar.gz: f73d31053413ea8188d168fd874ba66a537b8369e30d4c608170fb581cb974893b79301e71b557dd5defdb6120c1d13b1d89ab2ef4d8497ca0dd580a9ae66323
|
@@ -1,9 +1,11 @@
|
|
1
1
|
require_relative '../base/converters'
|
2
2
|
require_relative '../base/validators'
|
3
|
+
require_relative '../base/account_transaction_helpers'
|
3
4
|
|
4
5
|
module WireClient
|
5
6
|
class Account
|
6
7
|
include ActiveModel::Validations
|
8
|
+
include AccountTransactionHelpers
|
7
9
|
extend Converter
|
8
10
|
|
9
11
|
attr_accessor :name,
|
@@ -12,21 +14,25 @@ module WireClient
|
|
12
14
|
:account_number,
|
13
15
|
:wire_routing_number,
|
14
16
|
:clear_system_code,
|
17
|
+
:postal_code,
|
18
|
+
:address_line,
|
19
|
+
:city,
|
20
|
+
:country_subdivision,
|
21
|
+
:country,
|
22
|
+
:currency,
|
15
23
|
:schema_code,
|
16
24
|
:identifier,
|
17
|
-
:
|
18
|
-
:country_subdivision,
|
19
|
-
:charge_bearer,
|
20
|
-
:currency
|
25
|
+
:charge_bearer
|
21
26
|
|
22
27
|
convert :name, to: :text
|
28
|
+
validates_length_of :currency, is: 3
|
23
29
|
validates_length_of :name, within: 1..70
|
24
30
|
validates_with CurrencyValidator,
|
25
31
|
CountryValidator,
|
26
32
|
CountrySubdivisionValidator,
|
27
|
-
CreditorIdentifierValidator,
|
28
33
|
BICValidator,
|
29
34
|
IBANValidator,
|
35
|
+
CreditorIdentifierValidator,
|
30
36
|
message: "%{value} is invalid"
|
31
37
|
|
32
38
|
def initialize(attributes = {})
|
@@ -35,25 +41,14 @@ module WireClient
|
|
35
41
|
end
|
36
42
|
|
37
43
|
@currency ||= 'USD'
|
44
|
+
@postal_code ||= 'NA'
|
45
|
+
@address_line ||= 'NA'
|
46
|
+
@city ||= 'NA'
|
38
47
|
@country ||= 'US'
|
39
48
|
@country_subdivision ||= 'MA' if self.country == 'US'
|
40
49
|
@schema_code ||= 'CUST'
|
41
50
|
@clear_system_code ||= 'USABA'
|
42
51
|
custom_defaults if self.respond_to? :custom_defaults
|
43
52
|
end
|
44
|
-
|
45
|
-
def country_subdivision_abbr
|
46
|
-
if @country == 'US' && !@country_subdivision.match(/\A[A-Z]{2,2}\z/)
|
47
|
-
return US_STATES[@country_subdivision]
|
48
|
-
end
|
49
|
-
@country_subdivision
|
50
|
-
end
|
51
|
-
|
52
|
-
def country_subdivision_name
|
53
|
-
if @country == 'US' && @country_subdivision.match(/\A[A-Z]{2,2}\z/)
|
54
|
-
return US_STATES.key(@country_subdivision)
|
55
|
-
end
|
56
|
-
@country_subdivision
|
57
|
-
end
|
58
53
|
end
|
59
54
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module WireClient
|
2
|
+
module AccountTransactionHelpers
|
3
|
+
def country_subdivision_abbr
|
4
|
+
return US_STATES[@country_subdivision] if a_full_name_us_state?
|
5
|
+
@country_subdivision
|
6
|
+
end
|
7
|
+
|
8
|
+
def country_subdivision_name
|
9
|
+
return US_STATES.key(@country_subdivision) if an_abbreviated_us_state?
|
10
|
+
@country_subdivision
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def within_the_us?
|
16
|
+
@country == 'US'
|
17
|
+
end
|
18
|
+
|
19
|
+
def an_abrreviated_state_name?
|
20
|
+
@country_subdivision.match(/\A[A-Z]{2,2}\z/)
|
21
|
+
end
|
22
|
+
|
23
|
+
def an_abbreviated_us_state?
|
24
|
+
within_the_us? && an_abrreviated_state_name?
|
25
|
+
end
|
26
|
+
|
27
|
+
def a_full_name_us_state?
|
28
|
+
within_the_us? && !an_abrreviated_state_name?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -29,7 +29,9 @@ module WireClient
|
|
29
29
|
builder.PmtInf do
|
30
30
|
builder.PmtInfId(payment_information_identification(group))
|
31
31
|
builder.PmtMtd('TRF')
|
32
|
+
builder.BtchBookg(group[:batch_booking])
|
32
33
|
builder.NbOfTxs(transactions.length)
|
34
|
+
builder.CtrlSum('%.2f' % amount_total(transactions))
|
33
35
|
builder.PmtTpInf do
|
34
36
|
builder.InstrPrty(group[:service_priority])
|
35
37
|
builder.SvcLvl do
|
@@ -37,13 +39,10 @@ module WireClient
|
|
37
39
|
end
|
38
40
|
end
|
39
41
|
builder.ReqdExctnDt(group[:requested_date].iso8601)
|
40
|
-
builder.BtchBookg(group[:batch_booking])
|
41
|
-
builder.CtrlSum('%.2f' % amount_total(transactions))
|
42
42
|
builder.Dbtr do
|
43
43
|
builder.Nm(account.name)
|
44
44
|
builder.PstlAdr do
|
45
|
-
builder
|
46
|
-
builder.Ctry(account.country)
|
45
|
+
entity_address(builder, account)
|
47
46
|
end
|
48
47
|
end
|
49
48
|
builder.DbtrAcct do
|
@@ -51,7 +50,7 @@ module WireClient
|
|
51
50
|
end
|
52
51
|
builder.DbtrAgt do
|
53
52
|
builder.FinInstnId do
|
54
|
-
|
53
|
+
entity_agent_id(builder, account)
|
55
54
|
builder.PstlAdr do
|
56
55
|
builder.Ctry(account.country)
|
57
56
|
end
|
@@ -85,7 +84,7 @@ module WireClient
|
|
85
84
|
end
|
86
85
|
builder.CdtrAgt do
|
87
86
|
builder.FinInstnId do
|
88
|
-
|
87
|
+
entity_agent_id(builder, transaction)
|
89
88
|
builder.Nm(transaction.agent_name)
|
90
89
|
builder.PstlAdr do
|
91
90
|
builder.Ctry(transaction.country)
|
@@ -95,7 +94,7 @@ module WireClient
|
|
95
94
|
builder.Cdtr do
|
96
95
|
builder.Nm(transaction.name)
|
97
96
|
builder.PstlAdr do
|
98
|
-
builder
|
97
|
+
entity_address(builder, transaction)
|
99
98
|
end
|
100
99
|
end
|
101
100
|
builder.CdtrAcct do
|
@@ -56,8 +56,7 @@ module WireClient
|
|
56
56
|
builder.Cdtr do
|
57
57
|
builder.Nm(group[:account].name)
|
58
58
|
builder.PstlAdr do
|
59
|
-
builder
|
60
|
-
builder.Ctry(account.country)
|
59
|
+
entity_address(builder, account)
|
61
60
|
end
|
62
61
|
end
|
63
62
|
builder.CdtrAcct do
|
@@ -65,7 +64,7 @@ module WireClient
|
|
65
64
|
end
|
66
65
|
builder.CdtrAgt do
|
67
66
|
builder.FinInstnId do
|
68
|
-
|
67
|
+
entity_agent_id(builder, group[:account])
|
69
68
|
end
|
70
69
|
end
|
71
70
|
|
@@ -124,10 +123,10 @@ module WireClient
|
|
124
123
|
end
|
125
124
|
builder.DbtrAgt do
|
126
125
|
builder.FinInstnId do
|
127
|
-
|
126
|
+
entity_agent_id(builder, transaction)
|
128
127
|
builder.Nm(transaction.agent_name)
|
129
128
|
builder.PstlAdr do
|
130
|
-
builder
|
129
|
+
entity_address(builder, transaction)
|
131
130
|
end
|
132
131
|
end
|
133
132
|
end
|
@@ -151,15 +151,23 @@ module WireClient
|
|
151
151
|
transaction
|
152
152
|
end
|
153
153
|
|
154
|
-
def
|
155
|
-
|
156
|
-
|
154
|
+
def entity_address(builder, entity)
|
155
|
+
builder.PstCd(entity.postal_code)
|
156
|
+
builder.TwnNm(entity.city)
|
157
|
+
builder.CtrySubDvsn(entity.country_subdivision_abbr)
|
158
|
+
builder.AdrLine(entity.address_line)
|
159
|
+
builder.Ctry(entity.country)
|
160
|
+
end
|
161
|
+
|
162
|
+
def entity_agent_id(builder, entity)
|
163
|
+
if entity.bic
|
164
|
+
builder.BIC(entity.bic)
|
157
165
|
else
|
158
166
|
builder.ClrSysMmbId do
|
159
167
|
builder.ClrSysId do
|
160
|
-
builder.Cd(
|
168
|
+
builder.Cd(entity.clear_system_code)
|
161
169
|
end
|
162
|
-
builder.MmbId(
|
170
|
+
builder.MmbId(entity.wire_routing_number)
|
163
171
|
end
|
164
172
|
end
|
165
173
|
end
|
@@ -182,19 +190,6 @@ module WireClient
|
|
182
190
|
end
|
183
191
|
end
|
184
192
|
|
185
|
-
def transaction_agent_id(builder, transaction)
|
186
|
-
if transaction.bic
|
187
|
-
builder.BIC(transaction.bic)
|
188
|
-
else
|
189
|
-
builder.ClrSysMmbId do
|
190
|
-
builder.ClrSysId do
|
191
|
-
builder.Cd(transaction.clear_system_code)
|
192
|
-
end
|
193
|
-
builder.MmbId(transaction.wire_routing_number)
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
193
|
def transaction_account_id(builder, transaction)
|
199
194
|
if transaction.iban
|
200
195
|
builder.Id do
|
@@ -30,14 +30,24 @@ module WireClient
|
|
30
30
|
# @return [String] The initiating party's Identifier
|
31
31
|
class_attribute :initiator_identifier
|
32
32
|
|
33
|
-
# @return [String] The initiating party's
|
34
|
-
|
35
|
-
|
33
|
+
# @return [String] The initiating party's Postal code (default: NA)
|
34
|
+
class_attribute :initiator_postal_code
|
35
|
+
|
36
|
+
# @return [String] The initiating party's Address line (default: NA)
|
37
|
+
class_attribute :initiator_address_line
|
38
|
+
|
39
|
+
# @return [String] The initiating party's City, town or municipality
|
40
|
+
# (default: NA)
|
41
|
+
class_attribute :initiator_city
|
36
42
|
|
37
43
|
# @return [String] The initiating party's country subdivision (name or
|
38
44
|
# 2 character code; default: MA)
|
39
45
|
class_attribute :initiator_country_subdivision
|
40
46
|
|
47
|
+
# @return [String] The initiating party's country (2 character country
|
48
|
+
# code; default: US)
|
49
|
+
class_attribute :initiator_country
|
50
|
+
|
41
51
|
##
|
42
52
|
# @return [Array] A list of arguments to use in the initializer, and as
|
43
53
|
# instance attributes
|
@@ -101,8 +111,11 @@ module WireClient
|
|
101
111
|
bic: self.class.initiator_bic,
|
102
112
|
iban: self.class.initiator_iban,
|
103
113
|
identifier: self.class.initiator_identifier,
|
104
|
-
|
105
|
-
|
114
|
+
postal_code: self.class.initiator_postal_code,
|
115
|
+
address_line: self.class.initiator_address_line,
|
116
|
+
city: self.class.initiator_city,
|
117
|
+
country_subdivision: self.class.initiator_country_subdivision,
|
118
|
+
country: self.class.initiator_country
|
106
119
|
)
|
107
120
|
else
|
108
121
|
@payment_initiation = klass.new(
|
@@ -110,8 +123,11 @@ module WireClient
|
|
110
123
|
wire_routing_number: self.class.initiator_wire_routing_number,
|
111
124
|
account_number: self.class.initiator_account_number,
|
112
125
|
identifier: self.class.initiator_identifier,
|
113
|
-
|
114
|
-
|
126
|
+
postal_code: self.class.initiator_postal_code,
|
127
|
+
address_line: self.class.initiator_address_line,
|
128
|
+
city: self.class.initiator_city,
|
129
|
+
country_subdivision: self.class.initiator_country_subdivision,
|
130
|
+
country: self.class.initiator_country
|
115
131
|
)
|
116
132
|
end
|
117
133
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module WireClient
|
2
2
|
class Transaction
|
3
3
|
include ActiveModel::Validations
|
4
|
+
include AccountTransactionHelpers
|
4
5
|
extend Converter
|
5
6
|
|
6
7
|
attr_accessor :name,
|
@@ -9,8 +10,13 @@ module WireClient
|
|
9
10
|
:account_number,
|
10
11
|
:wire_routing_number,
|
11
12
|
:clear_system_code,
|
12
|
-
:
|
13
|
+
:postal_code,
|
14
|
+
:address_line,
|
15
|
+
:city,
|
16
|
+
:country_subdivision,
|
13
17
|
:country,
|
18
|
+
:currency,
|
19
|
+
:agent_name,
|
14
20
|
:amount,
|
15
21
|
:instruction,
|
16
22
|
:reference,
|
@@ -20,14 +26,13 @@ module WireClient
|
|
20
26
|
:currency,
|
21
27
|
:service_priority,
|
22
28
|
:service_level
|
29
|
+
|
23
30
|
convert :name,
|
24
31
|
:instruction,
|
25
32
|
:reference,
|
26
33
|
:remittance_information, to: :text
|
27
34
|
convert :amount, to: :decimal
|
28
35
|
|
29
|
-
validates_length_of :name, within: 1..70
|
30
|
-
validates_length_of :currency, is: 3
|
31
36
|
validates_length_of :instruction, within: 1..35, allow_nil: true
|
32
37
|
validates_length_of :reference, within: 1..35, allow_nil: true
|
33
38
|
validates_length_of :remittance_information,
|
@@ -36,8 +41,11 @@ module WireClient
|
|
36
41
|
validates_numericality_of :amount, greater_than: 0
|
37
42
|
validates_presence_of :requested_date
|
38
43
|
validates_inclusion_of :batch_booking, :in => [true, false]
|
44
|
+
validates_length_of :currency, is: 3
|
45
|
+
validates_length_of :name, within: 1..70
|
39
46
|
validates_with CurrencyValidator,
|
40
47
|
CountryValidator,
|
48
|
+
CountrySubdivisionValidator,
|
41
49
|
BICValidator,
|
42
50
|
IBANValidator,
|
43
51
|
message: "%{value} is invalid"
|
@@ -48,7 +56,11 @@ module WireClient
|
|
48
56
|
end
|
49
57
|
|
50
58
|
@currency ||= 'USD'
|
59
|
+
@postal_code ||= 'NA'
|
60
|
+
@address_line ||= 'NA'
|
61
|
+
@city ||= 'NA'
|
51
62
|
@country ||= 'US'
|
63
|
+
@country_subdivision ||= 'MA' if self.country == 'US'
|
52
64
|
@clear_system_code ||= 'USABA'
|
53
65
|
@agent_name ||= 'NOTPROVIDED'
|
54
66
|
@requested_date ||= default_requested_date
|
data/lib/wire_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wire_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ewerton Carlos Assis
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ach_client
|
@@ -327,6 +327,7 @@ files:
|
|
327
327
|
- lib/wire_client/account/account.rb
|
328
328
|
- lib/wire_client/account/creditor_account.rb
|
329
329
|
- lib/wire_client/account/debitor_account.rb
|
330
|
+
- lib/wire_client/base/account_transaction_helpers.rb
|
330
331
|
- lib/wire_client/base/constants.rb
|
331
332
|
- lib/wire_client/base/converters.rb
|
332
333
|
- lib/wire_client/base/invalid_wire_transaction_error.rb
|