svbclient 3.2.2 → 3.2.3

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/svbclient.rb +122 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1aca09ed58e59e32a13bd7e8c324e8f2544f4f84
4
- data.tar.gz: 124d011d799c750cce04aeae833c3c036de3683e
3
+ metadata.gz: 5e2293f322ab232c27811ac01f771940fd47643c
4
+ data.tar.gz: e10b4783b0546ae476c07db5709a35d87646b762
5
5
  SHA512:
6
- metadata.gz: 262973ab50e187760b491b2f5c5cfe2e6088e7bb145e24e88adfcbbadfca3cc321a1271b462a770da539fd1a2e855c08b93dd89595dd53124a1ea63750445e25
7
- data.tar.gz: 5a73b8bad451c297c456847d1f6c83ccdbcaec56b347b1d6ec7ffcd695bbe85e11d208e82de528637a55f0c8f2469e0362d267eeae7b9577663b8782cee55e9d
6
+ metadata.gz: 29aaed3d9e418e1fa21d9b7395b8595c0af576483cc344d32e8fd684d9e03ba23ecea6dd53a633167eef378dfbdfc2f7e1865cb1d616fd99379ed2141c8b1742
7
+ data.tar.gz: a4fcfa2ae7de155ff35e6dba8448a57b7b343715ab011fd8f86ee12ffd98a2ac54419b3c4fe9491c8f9a6e748777019b6527e568954ef9469e59fb85e68da3a6
data/lib/svbclient.rb CHANGED
@@ -76,6 +76,31 @@ class SVBClient
76
76
  end
77
77
  end
78
78
 
79
+ class SVBClient::Account
80
+ def self.all(client)
81
+ list = JSON.parse(client.get("/v1/accounts"))["data"]
82
+ list.map do |account|
83
+ SVBClient::Account.new(client, account["id"])
84
+ end
85
+ end
86
+
87
+ def initialize(client, id)
88
+ @client = client
89
+ @id = id
90
+ end
91
+
92
+ def data
93
+ JSON.parse(@client.get("/v1/accounts/#{@id}").body)["data"]
94
+ end
95
+
96
+ def transactions(start_date: nil, end_date: nil)
97
+ filters = []
98
+ filters << 'filter%5Bstart_date%5D=' + start_date unless start_date.nil?
99
+ filters << 'filter%5Bend_date%5D=' + end_date unless end_date.nil?
100
+ JSON.parse(@client.get("/v1/accounts/#{@id}/transactions", filters.join('&')).body)["data"]
101
+ end
102
+ end
103
+
79
104
  class SVBClient::ACH
80
105
  def initialize(client, id)
81
106
  @client = client
@@ -87,7 +112,7 @@ class SVBClient::ACH
87
112
  end
88
113
 
89
114
  def update_status(status)
90
- @client.patch("/v1/ach/#{id}", { status: status })
115
+ @client.patch("/v1/ach/#{@id}", { status: status })
91
116
  end
92
117
  end
93
118
 
@@ -107,11 +132,15 @@ class SVBClient::ACHHandler
107
132
  SVBClient::ACH.new(@client, id)
108
133
  end
109
134
 
135
+ def all
136
+ find
137
+ end
138
+
110
139
  def find(status: nil, effective_date: nil)
111
- query = ''
112
- query += "filter%5Bstatus%5D=#{status}" unless status.nil?
113
- query += "filter%5Beffective_date%5D=#{effective_date}" unless effective_date.nil?
114
- response = @client.get("/v1/ach", query)
140
+ query = []
141
+ query << "filter%5Bstatus%5D=#{status}" unless status.nil?
142
+ query << "filter%5Beffective_date%5D=#{effective_date}" unless effective_date.nil?
143
+ response = @client.get("/v1/ach", query.join('&'))
115
144
  list = JSON.parse(response.body)["data"]
116
145
  list.map do |ach|
117
146
  SVBClient::ACH.new(@client, ach["id"])
@@ -119,6 +148,94 @@ class SVBClient::ACHHandler
119
148
  end
120
149
  end
121
150
 
151
+ class SVBClient::BookTransfer
152
+ def initialize(client, id)
153
+ @client = client
154
+ @id = id
155
+ end
156
+
157
+ def data
158
+ JSON.parse(@client.get("/v1/book/#{@id}").body)["data"]
159
+ end
160
+
161
+ def update_status(status)
162
+ @client.patch("/v1/book/#{@id}", { status: status })
163
+ end
164
+ end
165
+
166
+ class SVBClient::BookTransferHandler
167
+ def initialize(client)
168
+ raise 'provide an API client' if client.nil?
169
+ @client = client
170
+ end
171
+
172
+ def create(transfer_data)
173
+ response = @client.post('/v1/book', transfer_data)
174
+ SVBClient::BookTransfer.new(@client, JSON.parse(response.body)["data"]["id"])
175
+ end
176
+
177
+ def get(id)
178
+ @client.get("/v1/book/#{id}")
179
+ SVBClient::BookTransfer.new(@client, id)
180
+ end
181
+
182
+ def all
183
+ response = @client.get("/v1/book")
184
+ list = JSON.parse(response.body)["data"]
185
+ list.map do |transfer|
186
+ SVBClient::BookTransfer.new(@client, transfer["id"])
187
+ end
188
+ end
189
+ end
190
+
191
+ class SVBClient::Wire
192
+ def initialize(client, id)
193
+ @client = client
194
+ @id = id
195
+ end
196
+
197
+ def data
198
+ JSON.parse(@client.get("/v1/wire/#{@id}").body)["data"]
199
+ end
200
+
201
+ def update_status(status)
202
+ @client.patch("/v1/wire/#{@id}", { status: status })
203
+ end
204
+ end
205
+
206
+ class SVBClient::WireHandler
207
+ def initialize(client)
208
+ raise 'provide an API client' if client.nil?
209
+ @client = client
210
+ end
211
+
212
+ def create(wire_data)
213
+ response = @client.post('/v1/wire', wire_data)
214
+ SVBClient::Wire.new(@client, JSON.parse(response.body)["data"]["id"])
215
+ end
216
+
217
+ def get(id)
218
+ @client.get("/v1/wire/#{id}")
219
+ SVBClient::Wire.new(@client, id)
220
+ end
221
+
222
+ def all
223
+ find
224
+ end
225
+
226
+ def find(status: nil, effective_date_start: nil, effective_date_end: nil)
227
+ query = []
228
+ query << "filter%5Bstatus%5D=#{status}" unless status.nil?
229
+ query << "filter%5Beffective_date_start%5D=#{effective_date_start}" unless effective_date_start.nil?
230
+ query << "filter%5Beffective_date_end%5D=#{effective_date_end}" unless effective_date_end.nil?
231
+ response = @client.get("/v1/wire", query.join('&'))
232
+ list = JSON.parse(response.body)["data"]
233
+ list.map do |wire|
234
+ SVBClient::Wire.new(@client, wire["id"])
235
+ end
236
+ end
237
+ end
238
+
122
239
  class SVBClient::Onboarding
123
240
  def initialize(client)
124
241
  raise 'provide an API client' if client.nil?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svbclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 3.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Silicon Valley Bank