jemquarie 0.0.2
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 +7 -0
- data/.gitignore +37 -0
- data/.travis.yml +39 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +77 -0
- data/LICENSE.txt +22 -0
- data/README.md +84 -0
- data/Rakefile +7 -0
- data/jemquarie.gemspec +28 -0
- data/lib/jemquarie/extract.wsdl +109 -0
- data/lib/jemquarie/importer.rb +56 -0
- data/lib/jemquarie/parser/cash_transactions.rb +164 -0
- data/lib/jemquarie/version.rb +3 -0
- data/lib/jemquarie.rb +30 -0
- data/spec/files/no_data.xml +22 -0
- data/spec/files/non_authenticated.xml +8 -0
- data/spec/files/transactions.xml +2341 -0
- data/spec/lib/importer_spec.rb +88 -0
- data/spec/lib/jemquarie_spec.rb +15 -0
- data/spec/spec_helper.rb +23 -0
- metadata +153 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f56716b5c6660c31d9315ff9c3a3e2228d8d6c07
|
4
|
+
data.tar.gz: 83348e50b1cefd7cd6fcc9f5e7b9c67b4601aa0a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6248a67d9c264b00be2e7b5dfdd17134b73ff6d5eaa31aff397913c3ae7aaf68151d23fcbc17f308f8de312c8ba9eb82543fef9ffb5476998ba8140ae88a3452
|
7
|
+
data.tar.gz: fc41e9d4327324f28526e154db4eb7f0720a215a6dc1fa046c20ee3a2173ff81308e09c067df85931dde3d901d6c99f474ef8c28035ce0011678ac1b68cdef90
|
data/.gitignore
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
35
|
+
|
36
|
+
# rspec
|
37
|
+
.rspec
|
data/.travis.yml
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
rvm:
|
4
|
+
- 1.9.3
|
5
|
+
- 2.0.0
|
6
|
+
- 2.1.0
|
7
|
+
- 2.1.1
|
8
|
+
- jruby-19mode # JRuby in 1.9 mode
|
9
|
+
- rbx-2.2.1
|
10
|
+
|
11
|
+
gemfile:
|
12
|
+
- gemfiles/rails_3.2.gemfile
|
13
|
+
- gemfiles/rails_4.0.gemfile
|
14
|
+
- gemfiles/rails_4.1.gemfile
|
15
|
+
|
16
|
+
matrix:
|
17
|
+
allow_failures:
|
18
|
+
- rvm: rbx-2.2.1
|
19
|
+
- rvm: jruby-19mode
|
20
|
+
exclude:
|
21
|
+
- rvm: 1.9.3
|
22
|
+
gemfile: gemfiles/rails_4.0.gemfile
|
23
|
+
- rvm: 1.9.3
|
24
|
+
gemfile: gemfiles/rails_4.1.gemfile
|
25
|
+
- rvm: jruby-19mode
|
26
|
+
gemfile: gemfiles/rails_3.2.gemfile
|
27
|
+
- rvm: jruby-19mode
|
28
|
+
gemfile: gemfiles/rails_4.0.gemfile
|
29
|
+
- rvm: jruby-19mode
|
30
|
+
gemfile: gemfiles/rails_4.1.gemfile
|
31
|
+
- rvm: rbx-2.2.1
|
32
|
+
gemfile: gemfiles/rails_3.2.gemfile
|
33
|
+
- rvm: rbx-2.2.1
|
34
|
+
gemfile: gemfiles/rails_4.0.gemfile
|
35
|
+
- rvm: rbx-2.2.1
|
36
|
+
gemfile: gemfiles/rails_4.1.gemfile
|
37
|
+
|
38
|
+
before_script:
|
39
|
+
- bundle
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jemquarie (0.0.1)
|
5
|
+
activesupport (>= 3.0)
|
6
|
+
savon (~> 2.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (4.1.1)
|
12
|
+
i18n (~> 0.6, >= 0.6.9)
|
13
|
+
json (~> 1.7, >= 1.7.7)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
thread_safe (~> 0.1)
|
16
|
+
tzinfo (~> 1.1)
|
17
|
+
akami (1.2.2)
|
18
|
+
gyoku (>= 0.4.0)
|
19
|
+
nokogiri
|
20
|
+
builder (3.2.2)
|
21
|
+
diff-lcs (1.2.5)
|
22
|
+
fakeweb (1.3.0)
|
23
|
+
gyoku (1.1.1)
|
24
|
+
builder (>= 2.1.2)
|
25
|
+
httpi (2.1.0)
|
26
|
+
rack
|
27
|
+
rubyntlm (~> 0.3.2)
|
28
|
+
i18n (0.6.9)
|
29
|
+
json (1.8.1)
|
30
|
+
macaddr (1.7.1)
|
31
|
+
systemu (~> 2.6.2)
|
32
|
+
mime-types (1.25.1)
|
33
|
+
mini_portile (0.6.0)
|
34
|
+
minitest (5.3.4)
|
35
|
+
nokogiri (1.6.2.1)
|
36
|
+
mini_portile (= 0.6.0)
|
37
|
+
nori (2.4.0)
|
38
|
+
rack (1.5.2)
|
39
|
+
rake (10.3.1)
|
40
|
+
rspec (2.14.1)
|
41
|
+
rspec-core (~> 2.14.0)
|
42
|
+
rspec-expectations (~> 2.14.0)
|
43
|
+
rspec-mocks (~> 2.14.0)
|
44
|
+
rspec-core (2.14.8)
|
45
|
+
rspec-expectations (2.14.5)
|
46
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
47
|
+
rspec-mocks (2.14.6)
|
48
|
+
rubyntlm (0.3.4)
|
49
|
+
savon (2.5.1)
|
50
|
+
akami (~> 1.2.0)
|
51
|
+
builder (>= 2.1.2)
|
52
|
+
gyoku (~> 1.1.0)
|
53
|
+
httpi (~> 2.1.0)
|
54
|
+
nokogiri (>= 1.4.0)
|
55
|
+
nori (~> 2.4.0)
|
56
|
+
uuid (~> 2.3.7)
|
57
|
+
wasabi (~> 3.3.0)
|
58
|
+
systemu (2.6.4)
|
59
|
+
thread_safe (0.3.3)
|
60
|
+
tzinfo (1.1.0)
|
61
|
+
thread_safe (~> 0.1)
|
62
|
+
uuid (2.3.7)
|
63
|
+
macaddr (~> 1.0)
|
64
|
+
wasabi (3.3.0)
|
65
|
+
httpi (~> 2.0)
|
66
|
+
mime-types (< 2.0.0)
|
67
|
+
nokogiri (>= 1.4.0)
|
68
|
+
|
69
|
+
PLATFORMS
|
70
|
+
ruby
|
71
|
+
|
72
|
+
DEPENDENCIES
|
73
|
+
bundler (>= 1.3)
|
74
|
+
fakeweb (>= 1.3.0)
|
75
|
+
jemquarie!
|
76
|
+
rake (>= 10.3.0)
|
77
|
+
rspec (>= 2.14.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 TODO: Write your name
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
jemquarie
|
2
|
+
=========
|
3
|
+
|
4
|
+
[](http://travis-ci.org/clod81/jemquarie)
|
5
|
+
|
6
|
+
Jemquarie provides an easy way to interact with Macquarie ESI api. For Ruby and Ruby on Rails.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'jemquarie'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install jemquarie
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
## For Ruby on Rails
|
25
|
+
|
26
|
+
Create an initializer file under config/initializers
|
27
|
+
|
28
|
+
The api key needs to be the unhashed value.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
require 'jemquarie'
|
32
|
+
Jemquarie::Jemquarie.set_api_credentials(YOUR_KEY, YOUR_APPLICATION_NAME)
|
33
|
+
```
|
34
|
+
|
35
|
+
### Import transactions
|
36
|
+
|
37
|
+
The auth code and password need to be the unhashed values.
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
Jemquarie::Importer.new(username, password).cash_transactions(1.day.ago.to_date, Date.today)
|
41
|
+
Jemquarie::Importer.new(username, password).cash_transactions(10.years.ago.to_date, Date.today, account_number)
|
42
|
+
```
|
43
|
+
|
44
|
+
### Results
|
45
|
+
|
46
|
+
## Success with data
|
47
|
+
|
48
|
+
The gem should return an array with formatted data. Here an example:
|
49
|
+
```
|
50
|
+
[
|
51
|
+
{
|
52
|
+
:foreign_identifier => "123456",
|
53
|
+
:date_time => "2013-01-01 00:00:00.000 UTC",
|
54
|
+
:amount => "-200",
|
55
|
+
:type_name => "TYPE",
|
56
|
+
:description => "NARRATIVE",
|
57
|
+
:meta_data => {
|
58
|
+
:updated_at => "2013-01-01 03:45:23.876 UTC"
|
59
|
+
}
|
60
|
+
]
|
61
|
+
```
|
62
|
+
|
63
|
+
|
64
|
+
## Success with no data
|
65
|
+
|
66
|
+
It just returns an empty Array
|
67
|
+
|
68
|
+
|
69
|
+
## Authentication failure
|
70
|
+
|
71
|
+
It returns an Hash {:error => "Invalid credentials"} .
|
72
|
+
|
73
|
+
|
74
|
+
## Authors ##
|
75
|
+
|
76
|
+
* [Claudio Contin](http://github.com/clod81)
|
77
|
+
|
78
|
+
## How to contribute
|
79
|
+
|
80
|
+
1. Fork it
|
81
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
82
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
83
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
84
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/jemquarie.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jemquarie/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jemquarie"
|
8
|
+
spec.version = Jemquarie::VERSION
|
9
|
+
spec.authors = ["Claudio Contin"]
|
10
|
+
spec.email = ["contin@gmail.com"]
|
11
|
+
spec.description = %q{Connect to Macquarie ESI web services}
|
12
|
+
spec.summary = %q{Ruby Gem for extracting cash transactions from Macquarie ESI web service}
|
13
|
+
spec.homepage = "https://github.com/clod81/jemquarie"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "savon", '~> 2.0'
|
22
|
+
spec.add_runtime_dependency "activesupport", '>= 3.0'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", '>= 1.3'
|
25
|
+
spec.add_development_dependency "rake", '>= 10.3.0'
|
26
|
+
spec.add_development_dependency "fakeweb", '>= 1.3.0'
|
27
|
+
spec.add_development_dependency "rspec", '>= 2.14.0'
|
28
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<definitions xmlns:tns="wrapwebservices"
|
3
|
+
xmlns:wsr="http://www.openuri.org/2002/10/soap/reliability/"
|
4
|
+
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
|
5
|
+
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
|
6
|
+
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
|
7
|
+
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
8
|
+
xmlns:soap12enc="http://www.w3.org/2003/05/soap-encoding"
|
9
|
+
xmlns:conv="http://www.openuri.org/2002/04/wsdl/conversation/"
|
10
|
+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
11
|
+
xmlns:s="http://www.w3.org/2001/XMLSchema"
|
12
|
+
xmlns="http://schemas.xmlsoap.org/wsdl/"
|
13
|
+
targetNamespace="wrapwebservices">
|
14
|
+
<types>
|
15
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
16
|
+
xmlns:stns="java:language_builtins.lang"
|
17
|
+
elementFormDefault="qualified"
|
18
|
+
attributeFormDefault="qualified"
|
19
|
+
targetNamespace="java:language_builtins.lang">
|
20
|
+
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/">
|
21
|
+
</xsd:import>
|
22
|
+
<xsd:complexType name="ArrayOfString">
|
23
|
+
<xsd:complexContent>
|
24
|
+
<xsd:restriction xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
25
|
+
base="soapenc:Array">
|
26
|
+
<xsd:attribute xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
27
|
+
ref="soapenc:arrayType"
|
28
|
+
wsdl:arrayType="xsd:string[]">
|
29
|
+
</xsd:attribute>
|
30
|
+
</xsd:restriction>
|
31
|
+
</xsd:complexContent>
|
32
|
+
</xsd:complexType>
|
33
|
+
</xsd:schema>
|
34
|
+
</types>
|
35
|
+
<message name="GenerateXMLExtract">
|
36
|
+
<part xmlns:partns="http://www.w3.org/2001/XMLSchema"
|
37
|
+
type="partns:string"
|
38
|
+
name="string">
|
39
|
+
</part>
|
40
|
+
<part xmlns:partns="http://www.w3.org/2001/XMLSchema"
|
41
|
+
type="partns:string"
|
42
|
+
name="string0">
|
43
|
+
</part>
|
44
|
+
<part xmlns:partns="http://www.w3.org/2001/XMLSchema"
|
45
|
+
type="partns:string"
|
46
|
+
name="string1">
|
47
|
+
</part>
|
48
|
+
<part xmlns:partns="http://www.w3.org/2001/XMLSchema"
|
49
|
+
type="partns:string"
|
50
|
+
name="string2">
|
51
|
+
</part>
|
52
|
+
<part xmlns:partns="http://www.w3.org/2001/XMLSchema"
|
53
|
+
type="partns:string"
|
54
|
+
name="string3">
|
55
|
+
</part>
|
56
|
+
<part xmlns:partns="http://www.w3.org/2001/XMLSchema"
|
57
|
+
type="partns:string"
|
58
|
+
name="string4">
|
59
|
+
</part>
|
60
|
+
<part xmlns:partns="java:language_builtins.lang"
|
61
|
+
type="partns:ArrayOfString"
|
62
|
+
name="strings">
|
63
|
+
</part>
|
64
|
+
</message>
|
65
|
+
<message name="GenerateXMLExtractResponse">
|
66
|
+
<part xmlns:partns="http://www.w3.org/2001/XMLSchema"
|
67
|
+
type="partns:string"
|
68
|
+
name="result">
|
69
|
+
</part>
|
70
|
+
</message>
|
71
|
+
<portType name="XMLExtractPort">
|
72
|
+
<operation name="GenerateXMLExtract">
|
73
|
+
<input message="tns:GenerateXMLExtract">
|
74
|
+
</input>
|
75
|
+
<output message="tns:GenerateXMLExtractResponse">
|
76
|
+
</output>
|
77
|
+
</operation>
|
78
|
+
</portType>
|
79
|
+
<binding type="tns:XMLExtractPort"
|
80
|
+
name="XMLExtractPort">
|
81
|
+
<soap:binding style="rpc"
|
82
|
+
transport="http://schemas.xmlsoap.org/soap/http">
|
83
|
+
</soap:binding>
|
84
|
+
<operation name="GenerateXMLExtract">
|
85
|
+
<soap:operation style="rpc"
|
86
|
+
soapAction="">
|
87
|
+
</soap:operation>
|
88
|
+
<input>
|
89
|
+
<soap:body namespace="wrapwebservices"
|
90
|
+
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
91
|
+
use="encoded">
|
92
|
+
</soap:body>
|
93
|
+
</input>
|
94
|
+
<output>
|
95
|
+
<soap:body namespace="wrapwebservices"
|
96
|
+
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
97
|
+
use="encoded">
|
98
|
+
</soap:body>
|
99
|
+
</output>
|
100
|
+
</operation>
|
101
|
+
</binding>
|
102
|
+
<service name="XMLExtract">
|
103
|
+
<port name="XMLExtractPort"
|
104
|
+
binding="tns:XMLExtractPort">
|
105
|
+
<soap:address location="https://www.macquarie.com.au/ESI/ESIWebService/Extract">
|
106
|
+
</soap:address>
|
107
|
+
</port>
|
108
|
+
</service>
|
109
|
+
</definitions>
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
module Jemquarie
|
5
|
+
|
6
|
+
class Importer
|
7
|
+
|
8
|
+
include Jemquarie::Parser::CashTransactions
|
9
|
+
|
10
|
+
def initialize(username, password)
|
11
|
+
@username = username
|
12
|
+
@password = password
|
13
|
+
@client = ::Savon.client do
|
14
|
+
endpoint Jemquarie::BASE_URI
|
15
|
+
wsdl File.expand_path("../extract.wsdl", __FILE__)
|
16
|
+
pretty_print_xml true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def cash_transactions(date_from = (Date.today - 1.day), date_to = Date.today, account_number = '')
|
21
|
+
if account_number.blank? && ((date_to - date_from).days > 2.days) # if no account specified, ESI api doesn't allow to ask more than 2 days of transactions
|
22
|
+
return {:error => "Cannot request more than 2 days of transactions if not account is specified"}
|
23
|
+
end
|
24
|
+
response = @client.call(:generate_xml_extract, :message => create_message(date_from, date_to, account_number))
|
25
|
+
return parse_cash_transactions_response(response) if response.success?
|
26
|
+
{:error => "An error has occured, please try again later"}
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def create_message(date_from, date_to, account_number)
|
32
|
+
{
|
33
|
+
:string => hash_key(Jemquarie.api_key), # base64 encoded of the sha1 hashed api key
|
34
|
+
:string0 => Jemquarie.app_key,
|
35
|
+
:string1 => hash_key(@username),
|
36
|
+
:string2 => hash_key(@password),
|
37
|
+
:string3 => 'your.clients Transactions',
|
38
|
+
:string4 => 'V1.4',
|
39
|
+
:strings => [
|
40
|
+
{
|
41
|
+
:item0 => account_number, # Account Number
|
42
|
+
:item1 => date_from.strftime("%Y-%m-%dT%H:%M:%S"), # START DATE
|
43
|
+
:item2 => date_to.strftime("%Y-%m-%dT%H:%M:%S"), # TO DATE
|
44
|
+
:item3 => 'Y' # Include closed accounts flag
|
45
|
+
}
|
46
|
+
]
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def hash_key(key)
|
51
|
+
Base64.strict_encode64(OpenSSL::Digest::SHA1.digest(key))
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
module Jemquarie
|
2
|
+
module Parser
|
3
|
+
module CashTransactions
|
4
|
+
|
5
|
+
def parse_cash_transactions_response(response)
|
6
|
+
body = response.body
|
7
|
+
return {:error => "Invalid credentials"} unless body[:generate_xml_extract_response] && body[:generate_xml_extract_response][:result] && body[:generate_xml_extract_response][:result].is_a?(String)
|
8
|
+
result = Hash.from_xml(Nokogiri::XML.fragment(body[:generate_xml_extract_response][:result]).to_s)
|
9
|
+
transactions = []
|
10
|
+
return transactions unless result["XMLExtract"] && result["XMLExtract"]["yourclientsTransactions"] && result["XMLExtract"]["yourclientsTransactions"]["yourclientsTransaction"]
|
11
|
+
result["XMLExtract"]["yourclientsTransactions"]["yourclientsTransaction"].each do |transaction|
|
12
|
+
transactions << parse_single_transaction(transaction)
|
13
|
+
end
|
14
|
+
transactions
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def parse_single_transaction(transaction)
|
20
|
+
{
|
21
|
+
:foreign_identifier => transaction["TransactionId"],
|
22
|
+
:date_time => Time.parse(transaction["TransactionDate"] + " UTC"),
|
23
|
+
:amount => transaction["DebitCredit"] == 'C' ? transaction["Amount"] : ('-' + transaction["Amount"]),
|
24
|
+
:type_name => translate_transaction_type(transaction["TransactionType"]),
|
25
|
+
:description => transaction["Narrative"],
|
26
|
+
:meta_data => {
|
27
|
+
:updated_at => Time.parse(transaction["DateModified"] + " UTC")
|
28
|
+
}
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def translate_transaction_type(type)
|
33
|
+
list = [
|
34
|
+
{:key => '04', :value => 'WITHDRAWAL'},
|
35
|
+
{:key => '06', :value => 'AUTHORITY TRANSFER'},
|
36
|
+
{:key => '07', :value => 'INTERNATIONAL DEBIT'},
|
37
|
+
{:key => '08', :value => 'DIRECT ENTRY DEBIT'},
|
38
|
+
{:key => '09', :value => 'CHEQUE'},
|
39
|
+
{:key => '11', :value => 'DEBIT BATCH VALUE DOCUMENT'},
|
40
|
+
{:key => '12', :value => 'INTERBANK DEBIT'},
|
41
|
+
{:key => '13', :value => 'WITHDRAWAL'},
|
42
|
+
{:key => '14', :value => 'TELEGRAPHIC TRANSFER'},
|
43
|
+
{:key => '15', :value => 'RETURNED CHEQUE'},
|
44
|
+
{:key => '16', :value => 'RETURNED CHEQUE CHARGE'},
|
45
|
+
{:key => '17', :value => 'ERROR IN DEPOSIT - ADJUSTMENT'},
|
46
|
+
{:key => '18', :value => 'INTERNATIONAL DEBIT'},
|
47
|
+
{:key => '19', :value => 'INTEREST ADJUSTMENT'},
|
48
|
+
{:key => '20', :value => 'CASH ACCOUNT DEBIT'},
|
49
|
+
{:key => '21', :value => 'FIN INST DUTY'},
|
50
|
+
{:key => '22', :value => 'FX TRANSACTION'},
|
51
|
+
{:key => '23', :value => 'SEARCH FEE'},
|
52
|
+
{:key => '24', :value => 'STATE DEBITS TAX'},
|
53
|
+
{:key => '25', :value => 'WITHHOLDING TAX'},
|
54
|
+
{:key => '26', :value => 'ATM WITHDRAWAL'},
|
55
|
+
{:key => '27', :value => 'VISA SALE'},
|
56
|
+
{:key => '29', :value => 'MISCELLANEOUS DEBIT FRC'},
|
57
|
+
{:key => '30', :value => 'SPECIAL CLEARING CHARGE'},
|
58
|
+
{:key => '39', :value => 'INTEREST CHARGED'},
|
59
|
+
{:key => '43', :value => 'BANK FEE'},
|
60
|
+
{:key => '44', :value => 'MISCELLANEOUS DEBIT'},
|
61
|
+
{:key => '45', :value => 'STAMP DUTY'},
|
62
|
+
{:key => '46', :value => 'PERIODICAL PAYMENT DEBIT'},
|
63
|
+
{:key => '47', :value => 'REVERSAL DEBIT'},
|
64
|
+
{:key => '49', :value => 'CHEQUE BOOK'},
|
65
|
+
{:key => '50', :value => 'DEPOSIT'},
|
66
|
+
{:key => '51', :value => 'GOVT SECURITY INTEREST'},
|
67
|
+
{:key => '52', :value => 'FAMILY ALLOWANCE'},
|
68
|
+
{:key => '53', :value => 'SALARY'},
|
69
|
+
{:key => '54', :value => 'PENSION'},
|
70
|
+
{:key => '55', :value => 'SERVICE ALLOTMENT'},
|
71
|
+
{:key => '56', :value => 'DIVIDEND'},
|
72
|
+
{:key => '57', :value => 'DEBENTURE NOTE INTEREST'},
|
73
|
+
{:key => '58', :value => 'GENERAL CREDIT'},
|
74
|
+
{:key => '59', :value => 'CREDIT BATCH VALUE DOCUMENT'},
|
75
|
+
{:key => '60', :value => 'DEPOSIT AGT'},
|
76
|
+
{:key => '61', :value => 'TELEGRAPHIC TRANSFER'},
|
77
|
+
{:key => '62', :value => 'ERROR IN DEPOSIT - ADJUSTMENT'},
|
78
|
+
{:key => '63', :value => 'INTEREST ADJUSTMENT'},
|
79
|
+
{:key => '64', :value => 'BILL ROLLOVER'},
|
80
|
+
{:key => '66', :value => 'FX TRANSACTION'},
|
81
|
+
{:key => '67', :value => 'INTERBANK CREDIT'},
|
82
|
+
{:key => '68', :value => 'INTERNATIONAL CREDIT'},
|
83
|
+
{:key => '69', :value => 'AUTHORITY TRANSFER'},
|
84
|
+
{:key => '70', :value => 'DEPOSIT'},
|
85
|
+
{:key => '71', :value => 'INTERBANK USE NOT AVAILABLE'},
|
86
|
+
{:key => '72', :value => 'REV FINANCIAL INSTITUTION DUTY'},
|
87
|
+
{:key => '73', :value => 'INTEREST PAID'},
|
88
|
+
{:key => '74', :value => 'REV FEDERAL DEBITS TAX'},
|
89
|
+
{:key => '76', :value => 'SWEEP ACCOUNT INTEREST'},
|
90
|
+
{:key => '77', :value => 'NEGATIVE DISTRIBUTION'},
|
91
|
+
{:key => '78', :value => 'DISHONOURED ITEM'},
|
92
|
+
{:key => '82', :value => 'REV WITHHOLDING TAX'},
|
93
|
+
{:key => '86', :value => 'BANK CHEQUE-REVERSAL'},
|
94
|
+
{:key => '87', :value => 'REVERSAL CHEQUE'},
|
95
|
+
{:key => '88', :value => 'REVERSAL CEMTEX'},
|
96
|
+
{:key => '89', :value => 'REV INTEREST CHARGED'},
|
97
|
+
{:key => '90', :value => 'REVERSAL CREDIT'},
|
98
|
+
{:key => '91', :value => 'REVERSAL OF CHARGE'},
|
99
|
+
{:key => '92', :value => 'PERIODICAL CREDIT'},
|
100
|
+
{:key => '93', :value => 'DEPOSIT'},
|
101
|
+
{:key => '94', :value => 'REVERSAL RTGS REDEMP'},
|
102
|
+
{:key => '95', :value => 'DEPOSIT'},
|
103
|
+
{:key => '96', :value => 'MISCELLANEOUS CREDIT FRC'},
|
104
|
+
{:key => '99', :value => 'MISCELLANEOUS CREDIT'},
|
105
|
+
{:key => 'AF', :value => 'APPLICATION FEE'},
|
106
|
+
{:key => 'BB', :value => 'BPAY DEPOSIT'},
|
107
|
+
{:key => 'BC', :value => 'BANK CHEQUE'},
|
108
|
+
{:key => 'BD', :value => 'BANK CHEQUE FEE'},
|
109
|
+
{:key => 'BP', :value => 'B-PAY WITHDRAWAL'},
|
110
|
+
{:key => 'BT', :value => 'DEPOSIT BANK TRANSFER'},
|
111
|
+
{:key => 'CA', :value => 'DEPOSIT - CASH'},
|
112
|
+
{:key => 'CC', :value => 'CHEQUE ISSUE FEE'},
|
113
|
+
{:key => 'CD', :value => 'DEPOSIT - CHEQUE'},
|
114
|
+
{:key => 'CQ', :value => 'FEE FOR CHQ TRANSACTIONS'},
|
115
|
+
{:key => 'CW', :value => '## EXCESS CHQ WITHDRAWALS'},
|
116
|
+
{:key => 'DC', :value => 'WITHDRAWAL-CHEQUE'},
|
117
|
+
{:key => 'DD', :value => 'WITHDRAWAL-BANK TRF'},
|
118
|
+
{:key => 'DF', :value => 'TRANSFER FROM'},
|
119
|
+
{:key => 'DI', :value => 'RETURNED DIRECT DEBIT FEE'},
|
120
|
+
{:key => 'DM', :value => 'ADDITIONAL STATEMENT FEE'},
|
121
|
+
{:key => 'DN', :value => 'EXCESS CHEQUE DEPOSITS'},
|
122
|
+
{:key => 'DS', :value => 'DISHONOUR - SAVING PLAN DEPOSIT'},
|
123
|
+
{:key => 'DT', :value => 'TRANSFER TO'},
|
124
|
+
{:key => 'EF', :value => 'ESTABLISHMENT FEE'},
|
125
|
+
{:key => 'FD', :value => 'FIXED PAYMENT-BANK TFR'},
|
126
|
+
{:key => 'FM', :value => 'MINIMUM BALANCE CHARGE'},
|
127
|
+
{:key => 'FT', :value => 'TRANSACTION CHARGES'},
|
128
|
+
{:key => 'IC', :value => 'CR INCOME ADJUSTMENT'},
|
129
|
+
{:key => 'ID', :value => 'DR INCOME ADJUSTMENT'},
|
130
|
+
{:key => 'JA', :value => 'INTERNAL APPLICATION'},
|
131
|
+
{:key => 'JR', :value => 'INTERNAL REDEMPTION'},
|
132
|
+
{:key => 'MC', :value => 'WITHDRAWAL - MANUAL CHEQUE'},
|
133
|
+
{:key => 'MF', :value => 'MISCELLANEOUS FEES'},
|
134
|
+
{:key => 'MM', :value => 'MANAGEMENT FEE'},
|
135
|
+
{:key => 'ND', :value => 'NET INCOME BANK TRANSFER'},
|
136
|
+
{:key => 'NF', :value => 'NET TAXES AND FEES'},
|
137
|
+
{:key => 'NR', :value => 'NET INCOME REINVEST'},
|
138
|
+
{:key => 'OB', :value => 'OPENING BALANCE'},
|
139
|
+
{:key => 'OC', :value => 'OVERSEAS BANK DRAFT FEE'},
|
140
|
+
{:key => 'OS', :value => 'EXCESS CHEQUE DEPOSITS DEBIT'},
|
141
|
+
{:key => 'OT', :value => 'OVERSEAS TELEGRAPH TRANSFER FE'},
|
142
|
+
{:key => 'RD', :value => 'RTGS APPLICATIONS'},
|
143
|
+
{:key => 'RT', :value => "RES INVEST W'HOLDING TAX"},
|
144
|
+
{:key => 'RW', :value => 'RTGS REDEMPTION'},
|
145
|
+
{:key => 'SC', :value => 'SWITCH CREDIT TRANS'},
|
146
|
+
{:key => 'SD', :value => 'SWITCH DEBIT TRANS'},
|
147
|
+
{:key => 'SF', :value => 'SAVINGS PLAN FEES'},
|
148
|
+
{:key => 'SP', :value => 'SAVINGS PLAN DEPOSIT'},
|
149
|
+
{:key => 'ST', :value => 'STOP PAYMENT FEE'},
|
150
|
+
{:key => 'TC', :value => 'WITHDRAWAL - CHEQUE'},
|
151
|
+
{:key => 'TD', :value => 'WITHDRAWAL - BANK TRF'},
|
152
|
+
{:key => 'WF', :value => 'WITHDRAWAL FEE'},
|
153
|
+
{:key => 'XC', :value => 'SWITCH OF INVESTMENT FUNDS'},
|
154
|
+
{:key => 'XD', :value => 'SWITCH OF INVESTMENT FUNDS'}
|
155
|
+
]
|
156
|
+
item = list.detect{|t| t[:key] == type}
|
157
|
+
return unless item
|
158
|
+
item[:value]
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|