coyodlee 0.1.0 → 0.2.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.
@@ -1,550 +0,0 @@
1
- require_relative 'utils'
2
-
3
- module Coyodlee
4
- class Client
5
- include Utils
6
-
7
- def initialize(session)
8
- @session = session
9
- end
10
-
11
- def get_accounts
12
- HttpWrapper.get(
13
- url: build_url('/accounts'),
14
- headers: {
15
- authorization: @session.auth_header,
16
- accept: :json
17
- }
18
- )
19
- end
20
-
21
- def get_account_details(account_id:, container:)
22
- params = [:container]
23
- .map { |sym| uncapitalized_camelize sym.to_s }
24
- .zip([container])
25
- .reject { |query, value| value.to_s.strip.empty? }
26
- .to_h
27
- HttpWrapper.get(
28
- url: build_url("/accounts/#{account_id}"),
29
- params: params,
30
- headers: {
31
- authorization: @session.auth_header,
32
- accept: :json
33
- }
34
- )
35
- end
36
-
37
- def update_account(account_id:, body:)
38
- HttpWrapper.put(
39
- url: build_url("/accounts/#{account_id}"),
40
- body: body,
41
- headers: {
42
- authorization: @session.auth_header,
43
- accept: :json,
44
- content_type: :json
45
- }
46
- )
47
- end
48
-
49
- def delete_account(id:)
50
- HttpWrapper.delete(
51
- url: build_url("/accounts/#{account_id}"),
52
- headers: {
53
- authorization: @session.auth_header,
54
- accept: :json
55
- }
56
- )
57
- end
58
-
59
- def add_manual_account(body:)
60
- HttpWrapper.post(
61
- url: build_url("/accounts"),
62
- body: body,
63
- headers: {
64
- authorization: @session.auth_header,
65
- accept: :json
66
- }
67
- )
68
- end
69
-
70
- def get_investment_options(_include: '', account_recon_type: '', account_id: '')
71
- params = [:_include, :account_recon_type, :account_id]
72
- .map { |sym| uncapitalized_camelize sym.to_s }
73
- .map { |sym| sub_underscore sym.to_s }
74
- .zip([_include, account_recon_type, account_id])
75
- .reject { |query, value| value.to_s.strip.empty? }
76
- .to_h
77
- HttpWrapper.get(
78
- url: build_url('/accounts/investmentPlan/investmentOptions'),
79
- params: params,
80
- headers: {
81
- authorization: @session.auth_header,
82
- accept: :json
83
- }
84
- )
85
- end
86
-
87
- def get_historical_balances(
88
- include_cf: '',
89
- account_id: '',
90
- from_date: '',
91
- to_date: '',
92
- interval: '',
93
- account_recon_type: '',
94
- skip: '',
95
- top: ''
96
- )
97
- params = [:include_cf, :account_id, :from_date, :to_date, :interval, :account_recon_type, :skip, :top]
98
- .map { |sym| uncapitalized_camelize sym.to_s }
99
- .zip([include_cf, account_id, from_date, to_date, interval, account_recon_type, skip, top])
100
- .reject { |query, value| value.to_s.strip.empty? }
101
- .to_h
102
- HttpWrapper.get(
103
- url: build_url('/accounts/historicalBalances'),
104
- params: params,
105
- headers: {
106
- authorization: @session.auth_header,
107
- accept: :json
108
- }
109
- )
110
- end
111
-
112
- def get_holdings(
113
- _include: '',
114
- account_id: '',
115
- provider_account_id: '',
116
- asset_classification__asset_classification_type: '',
117
- classification_value: '',
118
- account_recon_type: ''
119
- )
120
- params = [:_include, :account_id, :provider_account_id, :asset_classification__asset_classification_type, :classification_value, :account_recon_type]
121
- .map { |sym| uncapitalized_camelize sym.to_s }
122
- .map { |sym| sub_underscore sym.to_s }
123
- .map { |sym| sub_double_underscore sym.to_s }
124
- .zip([_include, account_id, provider_account_id, asset_classification__asset_classification_type, classification_value, account_recon_type])
125
- .reject { |query, value| value.to_s.strip.empty? }
126
- .to_h
127
- HttpWrapper.get(
128
- url: build_url('/holdings'),
129
- params: params,
130
- headers: {
131
- authorization: @session.auth_header,
132
- accept: :json
133
- }
134
- )
135
- end
136
-
137
- def get_extended_securities_info(holding_id: '')
138
- params = [:holding_id]
139
- .map { |sym| uncapitalized_camelize sym.to_s }
140
- .zip([holding_id])
141
- .reject { |query, value| value.to_s.strip.empty? }
142
- .to_h
143
- HttpWrapper.get(
144
- url: build_url('/holdings/securities'),
145
- params: params,
146
- headers: {
147
- authorization: @session.auth_header,
148
- accept: :json
149
- }
150
- )
151
- end
152
-
153
- def get_holding_type_list
154
- HttpWrapper.get(
155
- url: build_url('/holdings/holdingTypeList'),
156
- headers: {
157
- authorization: @session.auth_header,
158
- accept: :json
159
- }
160
- )
161
- end
162
-
163
- def get_asset_classification_list
164
- HttpWrapper.get(
165
- url: build_url('/holdings/assetClassificationList'),
166
- headers: {
167
- authorization: @session.auth_header,
168
- accept: :json
169
- }
170
- )
171
- end
172
-
173
- def get_provider_details(provider_id:, provider_account_id:)
174
- params = [:provider_account_id]
175
- .map { |sym| uncapitalized_camelize sym.to_s }
176
- .zip([provider_account_id])
177
- .reject { |query, value| value.to_s.strip.empty? }
178
- .to_h
179
- HttpWrapper.post(
180
- url: build_url("/providers/#{provider_id}"),
181
- params: params,
182
- headers: {
183
- authorization: @session.auth_header,
184
- accept: :json
185
- }
186
- )
187
- end
188
-
189
- def get_providers(
190
- priority: '',
191
- capability: '',
192
- additional_data_set: '',
193
- name: '',
194
- skip: '',
195
- top: '',
196
- classification: ''
197
- )
198
- params = [:priority, :capability, :additional_data_set, :name, :skip, :top, :classification]
199
- .map { |sym| uncapitalized_camelize sym.to_s }
200
- .map { |sym| sub_underscore sym.to_s }
201
- .map { |sym| sub_double_underscore sym.to_s }
202
- .zip([priority, capability, additional_data_set, name, skip, top, classification])
203
- .reject { |query, value| value.to_s.strip.empty? }
204
- .to_h
205
- HttpWrapper.get(
206
- url: build_url('/providers'),
207
- params: params,
208
- headers: {
209
- authorization: @session.auth_header,
210
- accept: :json
211
- }
212
- )
213
- end
214
-
215
- def verify_provider_account(body:)
216
- HttpWrapper.put(
217
- url: build_url('/providerAccounts/verification'),
218
- body: body,
219
- headers: {
220
- authorization: @session.auth_header,
221
- accept: :json
222
- }
223
- )
224
- end
225
-
226
- def get_verification_status(provider_account_id:)
227
- HttpWrapper.get(
228
- url: build_url("/providerAccounts/verification/#{provider_account_id}"),
229
- body: body,
230
- headers: {
231
- authorization: @session.auth_header,
232
- accept: :json
233
- }
234
- )
235
- end
236
-
237
- def update_provider_account(body:)
238
- HttpWrapper.put(
239
- url: build_url('/provideAccounts'),
240
- body: body,
241
- headers: {
242
- authorization: @session.auth_header,
243
- accept: :json
244
- }
245
- )
246
- end
247
-
248
- def delete_provider_account(provider_account_id:)
249
- HttpWrapper.delete(
250
- url: build_url("/providerAccounts/#{provider_account_id}"),
251
- headers: {
252
- authorization: @session.auth_header,
253
- accept: :json
254
- }
255
- )
256
- end
257
-
258
- def get_provider_account_details(provider_account_id:, _include: '')
259
- params = [:provider_account_id, :_include]
260
- .map { |sym| uncapitalized_camelize sym.to_s }
261
- .zip([provider_account_id, _include])
262
- .reject { |query, value| value.to_s.strip.empty? }
263
- .to_h
264
- HttpWrapper.get(
265
- url: build_url("/providerAccounts/#{provider_account_id}"),
266
- params: params,
267
- headers: {
268
- authorization: @session.auth_header,
269
- accept: :json
270
- }
271
- )
272
- end
273
-
274
- def get_provider_accounts
275
- HttpWrapper.get(
276
- url: build_url('/providerAccounts'),
277
- headers: {
278
- authorization: @session.auth_header,
279
- accept: :json
280
- }
281
- )
282
- end
283
-
284
- def add_provider_account(provider_id:, body:)
285
- params = [:provider_id]
286
- .map { |sym| uncapitalized_camelize sym.to_s }
287
- .zip([provider_id])
288
- .reject { |query, value| value.to_s.strip.empty? }
289
- .to_h
290
- HttpWrapper.post(
291
- url: build_url('/providerAccounts'),
292
- params: params,
293
- body: body,
294
- headers: {
295
- authorization: @session.auth_header,
296
- accept: :json
297
- }
298
- )
299
- end
300
-
301
- def get_transactions_count(params={})
302
- params = params
303
- .map { |sym, val| [uncapitalized_camelize(sym.to_s), val] }
304
- .reject { |_, value| value.to_s.strip.empty? }
305
- .to_h
306
- HttpWrapper.get(
307
- url: build_url('/transactions/count'),
308
- params: params,
309
- headers: {
310
- authorization: @session.auth_header,
311
- accept: :json
312
- }
313
- )
314
- end
315
-
316
- def get_transaction_categorization_rules
317
- HttpWrapper.get(
318
- url: build_url('/transactions/categories/rules'),
319
- headers: {
320
- authorization: @session.auth_header,
321
- accept: :json
322
- }
323
- )
324
- end
325
-
326
- def create_transaction_categorization_rule(body:)
327
- HttpWrapper.post(
328
- url: build_url('/transactions/categories/rules'),
329
- body: body,
330
- headers: {
331
- authorization: @session.auth_header,
332
- accept: :json
333
- }
334
- )
335
- end
336
-
337
- def update_transaction_categorization_rule(rule_id:, body:)
338
- HttpWrapper.put(
339
- url: build_url("/transactions/categories/rules/#{rule_id}"),
340
- body: body,
341
- headers: {
342
- authorization: @session.auth_header,
343
- accept: :json
344
- }
345
- )
346
- end
347
-
348
- def delete_transaction_categorization_rule(rule_id:)
349
- HttpWrapper.delete(
350
- url: build_url("/transactions/categories/rules/#{rule_id}"),
351
- headers: {
352
- authorization: @session.auth_header,
353
- accept: :json
354
- }
355
- )
356
- end
357
-
358
- def run_transaction_categorization_rule(rule_id:)
359
- params = { action: 'run'}
360
- HttpWrapper.post(
361
- url: build_url("/transactions/categories/rules/#{rule_id}"),
362
- params: params,
363
- headers: {
364
- authorization: @session.auth_header,
365
- accept: :json
366
- }
367
- )
368
- end
369
-
370
- def run_all_transaction_categorization_rules
371
- params = { action: 'run'}
372
- HttpWrapper.post(
373
- url: build_url('/transactions/categories/rules'),
374
- params: params,
375
- headers: {
376
- authorization: @session.auth_header,
377
- accept: :json
378
- }
379
- )
380
- end
381
-
382
- def delete_transaction_category(category_id:)
383
- HttpWrapper.delete(
384
- url: build_url("/transactions/categories/#{category_id}"),
385
- headers: {
386
- authorization: @session.auth_header,
387
- accept: :json
388
- }
389
- )
390
- end
391
-
392
- def update_transaction_category(category_id:, container:, category_name:, transaction_id:)
393
- params = [:container, :category_name, :transaction_id]
394
- .map { |sym, val| [uncapitalized_camelize(sym.to_s), val] }
395
- .zip([container, category_name, transaction_id])
396
- .reject { |_, value| value.to_s.strip.empty? }
397
- .to_h
398
- HttpWrapper.put(
399
- url: build_url("/transactions/categories/#{category_id}"),
400
- params: params,
401
- headers: {
402
- authorization: @session.auth_header,
403
- accept: :json
404
- }
405
- )
406
- end
407
-
408
- def get_transaction_category_list
409
- HttpWrapper.get(
410
- url: build_url('/transactions/categories'),
411
- headers: {
412
- authorization: @session.auth_header,
413
- accept: :json
414
- }
415
- )
416
- end
417
-
418
- def create_category(body:)
419
- HttpWrapper.post(
420
- url: build_url('/transactions/categories'),
421
- body: body,
422
- headers: {
423
- authorization: @session.auth_header,
424
- accept: :json
425
- }
426
- )
427
- end
428
-
429
- def update_category(body:)
430
- HttpWrapper.put(
431
- url: build_url('/transactions/categories'),
432
- body: body,
433
- headers: {
434
- authorization: @session.auth_header,
435
- accept: :json
436
- }
437
- )
438
- end
439
-
440
- def get_transactions(params={})
441
- params = params
442
- .map { |sym, val| [uncapitalized_camelize(sym.to_s), val] }
443
- .reject { |_, value| value.to_s.strip.empty? }
444
- .to_h
445
- HttpWrapper.get(
446
- url: build_url('/transactions'),
447
- params: params,
448
- headers: {
449
- authorization: @session.auth_header,
450
- accept: :json
451
- }
452
- )
453
- end
454
-
455
- def get_statements(params={})
456
- params = params
457
- .map { |sym, val| [uncapitalized_camelize(sym.to_s), val] }
458
- .reject { |_, value| value.to_s.strip.empty? }
459
- .to_h
460
- HttpWrapper.get(
461
- url: build_url('/statements'),
462
- params: params,
463
- headers: {
464
- authorization: @session.auth_header,
465
- accept: :json
466
- }
467
- )
468
- end
469
-
470
- def get_transaction_summary(group_by:, params: {})
471
- params = params
472
- .merge({ group_by: group_by })
473
- .map { |sym, val| [uncapitalized_camelize(sym.to_s), val] }
474
- .reject { |_, value| value.to_s.strip.empty? }
475
- .to_h
476
- HttpWrapper.get(
477
- url: build_url('/derived/transactionSummary'),
478
- params: params,
479
- headers: {
480
- authorization: @session.auth_header,
481
- accept: :json
482
- }
483
- )
484
- end
485
-
486
- def get_holding_summary(params={})
487
- params = params
488
- .map { |sym, val| [uncapitalized_camelize(sym.to_s), val] }
489
- .map { |sym, val| [sub_underscore(sym.to_s), val] }
490
- .reject { |_, value| value.to_s.strip.empty? }
491
- .to_h
492
- HttpWrapper.get(
493
- url: build_url('/derived/holdingSummary'),
494
- params: params,
495
- headers: {
496
- authorization: @session.auth_header,
497
- accept: :json
498
- }
499
- )
500
- end
501
-
502
- def get_networth_summary(params={})
503
- params = params
504
- .map { |sym, val| [uncapitalized_camelize(sym.to_s), val] }
505
- .map { |sym, val| [sub_underscore(sym.to_s), val] }
506
- .reject { |_, value| value.to_s.strip.empty? }
507
- .to_h
508
- HttpWrapper.get(
509
- url: build_url('/derived/networth'),
510
- params: params,
511
- headers: {
512
- authorization: @session.auth_header,
513
- accept: :json
514
- }
515
- )
516
- end
517
-
518
- def get_extract_events(event_name:, from_date:, to_date:)
519
- params = [:event_name, :from_date, :to_date]
520
- .map { |sym| uncapitalized_camelize sym.to_s }
521
- .zip([event_name, from_date, to_date])
522
- .reject { |_, value| value.to_s.strip.empty? }
523
- .to_h
524
- HttpWrapper.get(
525
- url: build_url('/dataExtracts/events'),
526
- params: params,
527
- headers: {
528
- authorization: @session.auth_header,
529
- accept: :json
530
- }
531
- )
532
- end
533
-
534
- def get_user_data(login_name:, from_date:, to_date:)
535
- params = [:login_name, :from_date, :to_date]
536
- .map { |sym| uncapitalized_camelize sym.to_s }
537
- .zip([login_name, from_date, to_date])
538
- .reject { |_, value| value.to_s.strip.empty? }
539
- .to_h
540
- HttpWrapper.get(
541
- url: build_url('/dataExtracts/userData'),
542
- params: params,
543
- headers: {
544
- authorization: @session.auth_header,
545
- accept: :json
546
- }
547
- )
548
- end
549
- end
550
- end