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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d63aea6ee443ea35ef173be3a2de9f21c36ccf03bf9545249700a443d274360e
4
- data.tar.gz: 176d7edd574dcdc1be3a54a7cce109c861d3bdeba7b32f6c3a769e40fdffea93
3
+ metadata.gz: b63be4cb913b87e7b56c0a1ba3eab66a09b853991d09bec6c42eb9ba6e0a091e
4
+ data.tar.gz: e61aa2281d0ddf0dfc48e9f3782dab1999ce69b48ae137a833648ce1f5ac350d
5
5
  SHA512:
6
- metadata.gz: 071f395d389f11333db5b5a36048ad9f0b66ff688fbfb35bccb83296b49491279a1b83f458507dd4e83426ffa39fd96d720ef000d0753595cc849e9901749d53
7
- data.tar.gz: 54d8986eccc4461d9b59c4f16b894e0274d660be311b6862cb1734010be7a7e386e496a36a7eb0f07621ab2cbf1785374fed3328a4fecfb210c52e40ec85437c
6
+ metadata.gz: ef318fa461e96b6fd1bb3f3421f833ad8104e82efc8f457c8c364c99bf14ba0c5409e4dd4d19d77d87ae74da19d50380781259723c669be319ffe5a3670f28dd
7
+ data.tar.gz: 88f1874026696d1cfc9f2af7f6d37329d3f8a40599fb72ef66109fb3a7bffe5e1ff5f814bf782e920b76194a5da501d4fbcb7ca99580615f17c8d929c5b880fb
data/.gitignore CHANGED
@@ -11,3 +11,4 @@
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
13
  .env
14
+ investec_open_api*.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- investec_open_api (2.0.0)
4
+ investec_open_api (2.1.0)
5
5
  faraday
6
6
  money
7
7
 
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
- client.transactions(my_account.id)
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
- unless options.empty?
27
- query_string = URI.encode_www_form(options.camelize)
28
- endpoint_url += "?#{query_string}"
29
- end
30
-
31
- response = connection.get(endpoint_url)
32
- response.body["data"]["transactions"].map do |transaction_raw|
33
- InvestecOpenApi::Models::Transaction.from_api(transaction_raw)
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
- # At this point, there is no unique identifier being returned from Investec's API.
26
- # This method serves to create a stable unique identifier based on the transaction details.
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,
@@ -1,3 +1,3 @@
1
1
  module InvestecOpenApi
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
3
3
  end
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.0.0
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-09-12 00:00:00.000000000 Z
11
+ date: 2024-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday