investec_open_api 2.0.0 → 2.1.0
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/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +9 -1
- data/lib/investec_open_api/client.rb +28 -9
- data/lib/investec_open_api/models/transaction.rb +9 -2
- data/lib/investec_open_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b63be4cb913b87e7b56c0a1ba3eab66a09b853991d09bec6c42eb9ba6e0a091e
|
4
|
+
data.tar.gz: e61aa2281d0ddf0dfc48e9f3782dab1999ce69b48ae137a833648ce1f5ac350d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef318fa461e96b6fd1bb3f3421f833ad8104e82efc8f457c8c364c99bf14ba0c5409e4dd4d19d77d87ae74da19d50380781259723c669be319ffe5a3670f28dd
|
7
|
+
data.tar.gz: 88f1874026696d1cfc9f2af7f6d37329d3f8a40599fb72ef66109fb3a7bffe5e1ff5f814bf782e920b76194a5da501d4fbcb7ca99580615f17c8d929c5b880fb
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -86,7 +86,15 @@ my_account = accounts.first
|
|
86
86
|
You can list your transactions by passing the account id into the `transactions` method:
|
87
87
|
|
88
88
|
```ruby
|
89
|
-
|
89
|
+
# The dates are optional
|
90
|
+
client.transactions(my_account.id, { fromDate: "2024-01-01", toDate: "2024-01-31" })
|
91
|
+
```
|
92
|
+
|
93
|
+
To list pending transactions use the following:
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
# The dates are optional
|
97
|
+
client.pending_transactions(my_account.id, { fromDate: "2024-01-01", toDate: "2024-01-31" })
|
90
98
|
```
|
91
99
|
|
92
100
|
### Get Balance for an account
|
@@ -20,18 +20,25 @@ class InvestecOpenApi::Client
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
## Get cleared transactions for an account
|
24
|
+
# @param [String] account_id The id of the account to get transactions for
|
25
|
+
# @param [Hash] options
|
26
|
+
# @option options [String] :fromDate Start date from which to get transactions
|
27
|
+
# @option options [String] :toDate End date for transactions
|
28
|
+
# @option options [String] :transactionType Type of transaction to filter by eg: CardPurchases, Deposits
|
23
29
|
def transactions(account_id, options = {})
|
24
30
|
endpoint_url = "za/pb/v1/accounts/#{account_id}/transactions"
|
31
|
+
perform_transaction_request(endpoint_url, options)
|
32
|
+
end
|
25
33
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
34
|
+
## Get pending transactions for an account
|
35
|
+
# @param [String] account_id The id of the account to get pending transactions for
|
36
|
+
# @param [Hash] options
|
37
|
+
# @option options [String] :fromDate Start date from which to get pending transactions
|
38
|
+
# @option options [String] :toDate End date for pending transactions
|
39
|
+
def pending_transactions(account_id, options = {})
|
40
|
+
endpoint_url = "za/pb/v1/accounts/#{account_id}/pending-transactions"
|
41
|
+
perform_transaction_request(endpoint_url, options)
|
35
42
|
end
|
36
43
|
|
37
44
|
def balance(account_id)
|
@@ -92,4 +99,16 @@ class InvestecOpenApi::Client
|
|
92
99
|
builder.adapter Faraday.default_adapter
|
93
100
|
end
|
94
101
|
end
|
102
|
+
|
103
|
+
def perform_transaction_request(endpoint_url, options)
|
104
|
+
unless options.empty?
|
105
|
+
query_string = URI.encode_www_form(options.camelize)
|
106
|
+
endpoint_url += "?#{query_string}"
|
107
|
+
end
|
108
|
+
|
109
|
+
response = connection.get(endpoint_url)
|
110
|
+
response.body["data"]["transactions"].map do |transaction_raw|
|
111
|
+
InvestecOpenApi::Models::Transaction.from_api(transaction_raw)
|
112
|
+
end
|
113
|
+
end
|
95
114
|
end
|
@@ -17,13 +17,20 @@ module InvestecOpenApi::Models
|
|
17
17
|
:value_date,
|
18
18
|
:action_date
|
19
19
|
|
20
|
+
## Unique identifier
|
21
|
+
# Composite key generated by Investec using the following formula:
|
22
|
+
# account_id.slice(0, 5) + posting_date.gsub(/-/, "") + posted_order.to_s.rjust(7, "0")
|
23
|
+
# This will only be populated for posted transaction on Private Bank Accounts.
|
24
|
+
# This is not a backend banking generated ID and will change if any of the properties making it up changes.
|
25
|
+
attr_reader :uuid
|
26
|
+
|
20
27
|
def initialize(params)
|
21
28
|
super
|
22
29
|
set_id
|
23
30
|
end
|
24
31
|
|
25
|
-
#
|
26
|
-
#
|
32
|
+
# Investec exposes a uuid for uniqueness so this is no longer needed (non-pending transactions).
|
33
|
+
# It is kept here for legacy purposes. It is also useful for pending transactions.
|
27
34
|
def set_id
|
28
35
|
@id = [
|
29
36
|
amount.to_i,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: investec_open_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Community Core Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|