bambora-batch_upload 0.1.0 → 0.1.1
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 +4 -4
- data/.rvmrc +60 -0
- data/Gemfile.lock +1 -1
- data/README.md +13 -1
- data/lib/bambora/batch_upload.rb +7 -6
- data/lib/bambora/batch_upload/create_batch_file.rb +3 -2
- data/lib/bambora/batch_upload/version.rb +1 -1
- data/lib/extensions/date.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5df6239fae3d7858fa64bbb6036702411fe78272
|
4
|
+
data.tar.gz: 9a65c41b2139546a702425319b1d655a7e13e5b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0de1d46a82f52e230e0a025413c05fc18336a010ce2901e6a08989148ab312b14f62438f6f7524f1d26c52d158f2c77dc58e42a307d052c5ac6cd688e496bbe7
|
7
|
+
data.tar.gz: b4e450f72aedaabd5d3493f7e3b0f8d9200aec5665bb5650bb2929593fdcca601fef947f4b053bfda9237a700d9819895a4a4ab5a523d2ad93116c41a4d610b0
|
data/.rvmrc
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 2.3.3@bambora" > .rvmrc
|
9
|
+
environment_id="ruby-2.3.3@bambora-batch_upload"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.29.2 (master)" # 1.10.1 seems like a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | __rvm_awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
for __hook in "${rvm_path:-$HOME/.rvm}/hooks/after_use"*
|
27
|
+
do
|
28
|
+
if [[ -f "${__hook}" && -x "${__hook}" && -s "${__hook}" ]]
|
29
|
+
then \. "${__hook}" || true
|
30
|
+
fi
|
31
|
+
done
|
32
|
+
unset __hook
|
33
|
+
if (( ${rvm_use_flag:=1} >= 1 )) # display automatically
|
34
|
+
then
|
35
|
+
if [[ $- == *i* ]] # check for interactive shells
|
36
|
+
then printf "%b" "Using: $(tput setaf 2 2>/dev/null)$GEM_HOME$(tput sgr0 2>/dev/null)\n" # show the user the ruby and gemset they are using in green
|
37
|
+
else printf "%b" "Using: $GEM_HOME\n" # don't use colors in non-interactive shells
|
38
|
+
fi
|
39
|
+
fi
|
40
|
+
else
|
41
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
42
|
+
rvm --create use "$environment_id" || {
|
43
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
44
|
+
return 1
|
45
|
+
}
|
46
|
+
fi
|
47
|
+
|
48
|
+
# If you use bundler, this might be useful to you:
|
49
|
+
# if [[ -s Gemfile ]] && {
|
50
|
+
# ! builtin command -v bundle >/dev/null ||
|
51
|
+
# builtin command -v bundle | GREP_OPTIONS="" \command \grep $rvm_path/bin/bundle >/dev/null
|
52
|
+
# }
|
53
|
+
# then
|
54
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
55
|
+
# gem install bundler
|
56
|
+
# fi
|
57
|
+
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
58
|
+
# then
|
59
|
+
# bundle install | GREP_OPTIONS="" \command \grep -vE '^Using|Your bundle is complete'
|
60
|
+
# fi
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -40,8 +40,20 @@ To create a batch file and then upload:
|
|
40
40
|
```ruby
|
41
41
|
#payment type has to be D (debit) or C (credit)
|
42
42
|
#amount must be specified in pennies
|
43
|
+
#if reference is not specified, it will be set to 0
|
44
|
+
#recipient and dynamic descriptor are optional
|
43
45
|
Bambora::BatchUpload.create_file do |reader|
|
44
|
-
reader.push_into_file(payment_type: "D", amount: 100, reference:
|
46
|
+
reader.push_into_file(payment_type: "D", amount: 100, reference: 34,
|
47
|
+
customer_code: "C6777B381C16434B82d40A8d23a19a68",
|
48
|
+
dynamic_descriptor: "Wesam Corp")
|
49
|
+
reader.push_into_file(payment_type: "D",
|
50
|
+
institution_number: "123",
|
51
|
+
transit_number: "12345",
|
52
|
+
account_number: "123458",
|
53
|
+
amount: 200,
|
54
|
+
reference: 667,
|
55
|
+
recipient: "Haddad"
|
56
|
+
)
|
45
57
|
##more lines
|
46
58
|
#reader.push_into_file(...)
|
47
59
|
end
|
data/lib/bambora/batch_upload.rb
CHANGED
@@ -56,13 +56,14 @@ module Bambora
|
|
56
56
|
def push_into_file(params)
|
57
57
|
validate_args params
|
58
58
|
array << OpenStruct.new(txn_type: params[:payment_type],
|
59
|
-
transit: params[:transit_number].to_s,
|
60
59
|
institution: params[:institution_number].to_s,
|
60
|
+
transit: params[:transit_number].to_s,
|
61
61
|
account: params[:account_number].to_s,
|
62
62
|
amount: params[:amount],
|
63
|
-
ref: params[:reference].to_s,
|
63
|
+
ref: (params[:reference] || 0 ).to_s,
|
64
64
|
recipient: params[:recipient].to_s,
|
65
|
-
customer_code: params[:customer_code].to_s
|
65
|
+
customer_code: params[:customer_code].to_s,
|
66
|
+
descriptor: params[:dynamic_descriptor].to_s
|
66
67
|
)
|
67
68
|
end
|
68
69
|
private
|
@@ -73,9 +74,9 @@ module Bambora
|
|
73
74
|
unless params[:payment_type] == "D" || params[:payment_type] == "C"
|
74
75
|
raise ArgumentError, "Must provide payment type: C (credit) or D (debit)"
|
75
76
|
end
|
76
|
-
if params[:customer_code].nil? && (params[:transit_number] ||
|
77
|
-
params[:institution_number] ||
|
78
|
-
params[:account_number])
|
77
|
+
if params[:customer_code].nil? && (params[:transit_number].nil? ||
|
78
|
+
params[:institution_number].nil? ||
|
79
|
+
params[:account_number].nil?)
|
79
80
|
raise ArgumentError, "Must either provide customer code or transit, institution, and account #s"
|
80
81
|
end
|
81
82
|
end
|
@@ -39,13 +39,14 @@ module Bambora::BatchUpload
|
|
39
39
|
txn_array.each do |txn|
|
40
40
|
string << "E,"
|
41
41
|
string << "#{txn.txn_type}," #C for Credit, D for Debit
|
42
|
-
string << "#{txn.transit},"
|
43
42
|
string << "#{txn.institution},"
|
43
|
+
string << "#{txn.transit},"
|
44
44
|
string << "#{txn.account},"
|
45
45
|
string << "#{txn.amount},"
|
46
46
|
string << "#{txn.ref},"
|
47
47
|
string << "#{txn.recipient},"
|
48
|
-
string << "#{txn.customer_code}"
|
48
|
+
string << "#{txn.customer_code},"
|
49
|
+
string << "#{txn.descriptor}"
|
49
50
|
string << "\r\n"
|
50
51
|
end
|
51
52
|
string
|
data/lib/extensions/date.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bambora-batch_upload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alwesam
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curb
|
@@ -89,6 +89,7 @@ extra_rdoc_files: []
|
|
89
89
|
files:
|
90
90
|
- ".gitignore"
|
91
91
|
- ".rspec"
|
92
|
+
- ".rvmrc"
|
92
93
|
- ".travis.yml"
|
93
94
|
- CODE_OF_CONDUCT.md
|
94
95
|
- Gemfile
|