figo 1.2.5 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/config.yml +4 -0
- data/console_demo.rb +1 -1
- data/figo.gemspec +3 -3
- data/lib/account/api_call.rb +55 -0
- data/lib/account/model.rb +122 -0
- data/lib/account_balance/api_call.rb +18 -0
- data/lib/account_balance/model.rb +31 -0
- data/lib/authentification/api_call.rb +88 -0
- data/lib/bank/api_call.rb +49 -0
- data/lib/bank/model.rb +23 -0
- data/lib/base.rb +56 -0
- data/lib/cacert.pem +0 -0
- data/lib/figo.rb +54 -380
- data/lib/helpers/error.rb +20 -0
- data/lib/helpers/https.rb +52 -0
- data/lib/notification/api_call.rb +40 -0
- data/lib/notification/model.rb +27 -0
- data/lib/payment/api_call.rb +71 -0
- data/lib/payment/model.rb +75 -0
- data/lib/process/api_call.rb +17 -0
- data/lib/process/model.rb +34 -0
- data/lib/security/api_call.rb +59 -0
- data/lib/security/model.rb +83 -0
- data/lib/standing_order/api_call.rb +24 -0
- data/lib/standing_order/model.rb +75 -0
- data/lib/synchronization_status/api_call.rb +27 -0
- data/lib/synchronization_status/model.rb +23 -0
- data/lib/task/api_call.rb +37 -0
- data/lib/task/model.rb +43 -0
- data/lib/transaction/api_call.rb +57 -0
- data/lib/transaction/model.rb +75 -0
- data/lib/user/api_call.rb +46 -0
- data/lib/user/model.rb +55 -0
- data/test/config.yml +7 -0
- data/test/test_account_sync_and_setup.rb +67 -0
- data/test/test_accounts.rb +106 -0
- data/test/test_authentififcation.rb +68 -0
- data/test/test_business_processes.rb +43 -0
- data/test/test_figo.rb +5 -86
- data/test/test_notifications.rb +83 -0
- data/test/test_payments.rb +106 -0
- data/test/test_securities.rb +70 -0
- data/test/test_standing_orders.rb +49 -0
- data/test/test_transactions.rb +87 -0
- data/test/test_user_management.rb +91 -0
- metadata +64 -14
- data/lib/models.rb +0 -466
data/lib/models.rb
DELETED
@@ -1,466 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2013 figo GmbH
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#
|
22
|
-
|
23
|
-
require "date"
|
24
|
-
require "flt"
|
25
|
-
|
26
|
-
|
27
|
-
module Figo
|
28
|
-
# Set decimal precision to two digits.
|
29
|
-
Flt::DecNum.context.precision = 2
|
30
|
-
|
31
|
-
# Abstract base class for model objects.
|
32
|
-
class Base
|
33
|
-
# Attributes to be dumped (called by modify and create)
|
34
|
-
@dump_attributes = []
|
35
|
-
def self.dump_attributes
|
36
|
-
@dump_attributes
|
37
|
-
end
|
38
|
-
|
39
|
-
# Instantiate model object from hash.
|
40
|
-
#
|
41
|
-
# @param session [Session] figo `Session` object
|
42
|
-
# @param hash [Hash] use keys of this hash for model object creation
|
43
|
-
def initialize(session, hash)
|
44
|
-
@session = session
|
45
|
-
|
46
|
-
hash.each do |key, value|
|
47
|
-
key = key.to_s if key.is_a? Symbol
|
48
|
-
next unless respond_to? "#{key}="
|
49
|
-
next if value.nil?
|
50
|
-
|
51
|
-
if key == "status" and value.is_a? Hash
|
52
|
-
value = SynchronizationStatus.new(session, value)
|
53
|
-
elsif key == "balance" and value.is_a? Hash
|
54
|
-
value = AccountBalance.new(session, value)
|
55
|
-
elsif key == "amount" or key == "balance" or key == "credit_line" or key == "monthly_spending_limit"
|
56
|
-
value = Flt::DecNum(value.to_s)
|
57
|
-
elsif key.end_with?("_date")
|
58
|
-
value = DateTime.iso8601(value)
|
59
|
-
elsif key.end_with?("_timestamp")
|
60
|
-
value = DateTime.iso8601(value)
|
61
|
-
end
|
62
|
-
send("#{key}=", value)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# Dump committable attributes to a hash
|
67
|
-
def dump
|
68
|
-
result = {}
|
69
|
-
self.class.dump_attributes.each do |attribute|
|
70
|
-
value = send attribute
|
71
|
-
next if value.nil?
|
72
|
-
value = value.to_f if value.is_a? Flt::DecNum
|
73
|
-
|
74
|
-
result[attribute] = value
|
75
|
-
end
|
76
|
-
return result
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# Object representing an User
|
81
|
-
class User < Base
|
82
|
-
@dump_attributes = [:name, :address, :send_newsletter, :language]
|
83
|
-
|
84
|
-
# Internal figo Connect User ID
|
85
|
-
# @return [String]
|
86
|
-
attr_accessor :User_id
|
87
|
-
|
88
|
-
# First and last name
|
89
|
-
# @return [String]
|
90
|
-
attr_accessor :name
|
91
|
-
|
92
|
-
# Email address
|
93
|
-
# @return [String]
|
94
|
-
attr_accessor :email
|
95
|
-
|
96
|
-
#Postal address for bills, etc.
|
97
|
-
# @return [Dict]
|
98
|
-
attr_accessor :address
|
99
|
-
|
100
|
-
# This flag indicates whether the email address has been verified
|
101
|
-
# @return [Boolean]
|
102
|
-
attr_accessor :verified_email
|
103
|
-
|
104
|
-
# This flag indicates whether the User has agreed to be contacted by email
|
105
|
-
# @return [Boolean]
|
106
|
-
attr_accessor :send_newsletter
|
107
|
-
|
108
|
-
# Two-letter code of preferred language
|
109
|
-
# @return [String]
|
110
|
-
attr_accessor :language
|
111
|
-
|
112
|
-
# This flag indicates whether the figo Account plan is free or premium
|
113
|
-
# @return [Boolean]
|
114
|
-
attr_accessor :premium
|
115
|
-
|
116
|
-
# Timestamp of premium figo Account expiry
|
117
|
-
# @return [DateTime]
|
118
|
-
attr_accessor :premium_expires_on
|
119
|
-
|
120
|
-
# Provider for premium subscription or Null of no subscription is active
|
121
|
-
# @return [String]
|
122
|
-
attr_accessor :premium_subscription
|
123
|
-
|
124
|
-
# Timestamp of figo Account registration
|
125
|
-
# @return [DateTime]
|
126
|
-
attr_accessor :join_date
|
127
|
-
end
|
128
|
-
|
129
|
-
# Object representing one bank account of the User
|
130
|
-
class Account < Base
|
131
|
-
@dump_attributes = [:name, :owner, :auto_sync]
|
132
|
-
|
133
|
-
# Internal figo Connect account ID
|
134
|
-
# @return [String]
|
135
|
-
attr_accessor :account_id
|
136
|
-
|
137
|
-
# Internal figo Connect bank ID
|
138
|
-
# @return [String]
|
139
|
-
attr_accessor :bank_id
|
140
|
-
|
141
|
-
# Account name
|
142
|
-
# @return [String]
|
143
|
-
attr_accessor :name
|
144
|
-
|
145
|
-
# Account owner
|
146
|
-
# @return [String]
|
147
|
-
attr_accessor :owner
|
148
|
-
|
149
|
-
# This flag indicates whether the account will be automatically synchronized
|
150
|
-
# @return [Boolean]
|
151
|
-
attr_accessor :auto_sync
|
152
|
-
|
153
|
-
# Account number
|
154
|
-
# @return [String]
|
155
|
-
attr_accessor :account_number
|
156
|
-
|
157
|
-
# Bank code
|
158
|
-
# @return [String]
|
159
|
-
attr_accessor :bank_code
|
160
|
-
|
161
|
-
# Bank name
|
162
|
-
# @return [String]
|
163
|
-
attr_accessor :bank_name
|
164
|
-
|
165
|
-
# Three-character currency code
|
166
|
-
# @return [String]
|
167
|
-
attr_accessor :currency
|
168
|
-
|
169
|
-
# IBAN
|
170
|
-
# @return [String]
|
171
|
-
attr_accessor :iban
|
172
|
-
|
173
|
-
# BIC
|
174
|
-
# @return [String]
|
175
|
-
attr_accessor :bic
|
176
|
-
|
177
|
-
# Account type
|
178
|
-
# @return [String]
|
179
|
-
attr_accessor :type
|
180
|
-
|
181
|
-
# Account icon URL
|
182
|
-
# @return [String]
|
183
|
-
attr_accessor :icon
|
184
|
-
|
185
|
-
# Account icon URLs for other resolutions
|
186
|
-
# @return [Hash]
|
187
|
-
attr_accessor :additional_icons
|
188
|
-
|
189
|
-
# This flag indicates whether the balance of this account is added to the total balance of accounts
|
190
|
-
# @return [Boolean]
|
191
|
-
attr_accessor :in_total_balance
|
192
|
-
|
193
|
-
# Synchronization status object
|
194
|
-
# @return [SynchronizationStatus]
|
195
|
-
attr_accessor :status
|
196
|
-
|
197
|
-
# AccountBalance object
|
198
|
-
# @return [AccountBalance]
|
199
|
-
attr_accessor :balance
|
200
|
-
|
201
|
-
# Request list of transactions of this account
|
202
|
-
#
|
203
|
-
# @param since [String, Date] this parameter can either be a transaction ID or a date
|
204
|
-
# @param count [Integer] limit the number of returned transactions
|
205
|
-
# @param offset [Integer] which offset into the result set should be used to determin the first transaction to return (useful in combination with count)
|
206
|
-
# @param include_pending [Boolean] this flag indicates whether pending transactions should be included
|
207
|
-
# in the response; pending transactions are always included as a complete set, regardless of
|
208
|
-
# the `since` parameter
|
209
|
-
# @return [Array] an array of `Transaction` objects, one for each transaction of this account
|
210
|
-
def transactions(since = nil, count = 1000, offset = 0, include_pending = false)
|
211
|
-
@session.transactions @account_id, since, count, offset, include_pending
|
212
|
-
end
|
213
|
-
|
214
|
-
# Request specific transaction.
|
215
|
-
#
|
216
|
-
# @param transaction_id [String] ID of the transaction to be retrieved
|
217
|
-
# @return [Transaction] transaction object
|
218
|
-
def get_transaction(transaction_id)
|
219
|
-
@session.get_transaction @acount_id, transaction_id
|
220
|
-
end
|
221
|
-
|
222
|
-
# Retrieve list of payments on this account
|
223
|
-
#
|
224
|
-
# @return [Payment] an array of `Payment` objects, one for each payment
|
225
|
-
def payments
|
226
|
-
@session.payments @account_id
|
227
|
-
end
|
228
|
-
|
229
|
-
# Retrieve specific payment on this account
|
230
|
-
#
|
231
|
-
# @param payment_id [String] ID of the notification to be retrieved
|
232
|
-
# @return [Payment] `Payment` object for the respective payment
|
233
|
-
def get_payment(payment_id)
|
234
|
-
@session.get_payment @account_id, payment_id
|
235
|
-
end
|
236
|
-
|
237
|
-
# Retrieve bank of this account
|
238
|
-
#
|
239
|
-
# @return [Bank] `Bank` object for the respective bank
|
240
|
-
def bank
|
241
|
-
@session.get_bank @bank_id
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
# Object representing the balance of a certain bank account of the User
|
246
|
-
class AccountBalance < Base
|
247
|
-
@dump_attributes = [:credit_line, :monthly_spending_limit]
|
248
|
-
|
249
|
-
# Account balance or `nil` if the balance is not yet known
|
250
|
-
# @return [DecNum]
|
251
|
-
attr_accessor :balance
|
252
|
-
|
253
|
-
# Bank server timestamp of balance or `nil` if the balance is not yet known
|
254
|
-
# @return [Date]
|
255
|
-
attr_accessor :balance_date
|
256
|
-
|
257
|
-
# Credit line.
|
258
|
-
# @return [DecNum]
|
259
|
-
attr_accessor :credit_line
|
260
|
-
|
261
|
-
# User-defined spending limit
|
262
|
-
# @return [DecNum]
|
263
|
-
attr_accessor :monthly_spending_limit
|
264
|
-
|
265
|
-
# Synchronization status object
|
266
|
-
# @return [SynchronizationStatus]
|
267
|
-
attr_accessor :status
|
268
|
-
end
|
269
|
-
|
270
|
-
# Object representing a bank, i.e. an connection to a bank
|
271
|
-
class Bank < Base
|
272
|
-
@dump_attributes = [:sepa_creditor_id]
|
273
|
-
|
274
|
-
# Internal figo Connect bank ID
|
275
|
-
# @return [String]
|
276
|
-
attr_accessor :bank_id
|
277
|
-
|
278
|
-
# SEPA direct debit creditor ID
|
279
|
-
# @return [String]
|
280
|
-
attr_accessor :sepa_creditor_id
|
281
|
-
|
282
|
-
# This flag indicates whether the user has chosen to save the PIN on the figo Connect server
|
283
|
-
# @return [Boolean]
|
284
|
-
attr_accessor :save_pin
|
285
|
-
end
|
286
|
-
|
287
|
-
# Object representing one bank transaction on a certain bank account of the User
|
288
|
-
class Transaction < Base
|
289
|
-
@dump_attributes = []
|
290
|
-
|
291
|
-
# Internal figo Connect transaction ID
|
292
|
-
# @return [String]
|
293
|
-
attr_accessor :transaction_id
|
294
|
-
|
295
|
-
# Internal figo Connect account ID
|
296
|
-
# @return [String]
|
297
|
-
attr_accessor :account_id
|
298
|
-
|
299
|
-
# Name of originator or recipient
|
300
|
-
# @return [String]
|
301
|
-
attr_accessor :name
|
302
|
-
|
303
|
-
# Account number of originator or recipient
|
304
|
-
# @return [String]
|
305
|
-
attr_accessor :account_number
|
306
|
-
|
307
|
-
# Bank code of originator or recipient
|
308
|
-
# @return [String]
|
309
|
-
attr_accessor :bank_code
|
310
|
-
|
311
|
-
# Bank name of originator or recipient
|
312
|
-
# @return [String]
|
313
|
-
attr_accessor :bank_name
|
314
|
-
|
315
|
-
# Transaction amount
|
316
|
-
# @return [DecNum]
|
317
|
-
attr_accessor :amount
|
318
|
-
|
319
|
-
# Three-character currency code
|
320
|
-
# @return [String]
|
321
|
-
attr_accessor :currency
|
322
|
-
|
323
|
-
# Booking date
|
324
|
-
# @return [Date]
|
325
|
-
attr_accessor :booking_date
|
326
|
-
|
327
|
-
# Value date
|
328
|
-
# @return [Date]
|
329
|
-
attr_accessor :value_date
|
330
|
-
|
331
|
-
# Purpose text
|
332
|
-
# @return [String]
|
333
|
-
attr_accessor :purpose
|
334
|
-
|
335
|
-
# Transaction type
|
336
|
-
# @return [String]
|
337
|
-
attr_accessor :type
|
338
|
-
|
339
|
-
# Booking text
|
340
|
-
# @return [String]
|
341
|
-
attr_accessor :booking_text
|
342
|
-
|
343
|
-
# This flag indicates whether the transaction is booked or pending
|
344
|
-
# @return [Boolean]
|
345
|
-
attr_accessor :booked
|
346
|
-
|
347
|
-
# Internal creation timestamp on the figo Connect server
|
348
|
-
# @return [DateTime]
|
349
|
-
attr_accessor :creation_timestamp
|
350
|
-
|
351
|
-
# Internal modification timestamp on the figo Connect server
|
352
|
-
# @return [DateTime]
|
353
|
-
attr_accessor :modification_timestamp
|
354
|
-
end
|
355
|
-
|
356
|
-
# Object representing the bank server synchronization status
|
357
|
-
class SynchronizationStatus < Base
|
358
|
-
@dump_attributes = []
|
359
|
-
|
360
|
-
# Internal figo Connect status code
|
361
|
-
# @return [Integer]
|
362
|
-
attr_accessor :code
|
363
|
-
|
364
|
-
# Human-readable error message
|
365
|
-
# @return [String]
|
366
|
-
attr_accessor :message
|
367
|
-
|
368
|
-
# Timestamp of last synchronization
|
369
|
-
# @return [DateTime]
|
370
|
-
attr_accessor :sync_timestamp
|
371
|
-
|
372
|
-
# Timestamp of last successful synchronization
|
373
|
-
# @return [DateTime]
|
374
|
-
attr_accessor :success_timestamp
|
375
|
-
end
|
376
|
-
|
377
|
-
# Object representing a configured notification, e.g. a webhook or email hook
|
378
|
-
class Notification < Base
|
379
|
-
@dump_attributes = [:observe_key, :notify_uri, :state]
|
380
|
-
|
381
|
-
# Internal figo Connect notification ID from the notification registration response
|
382
|
-
# @return [String]
|
383
|
-
attr_accessor :notification_id
|
384
|
-
|
385
|
-
# One of the notification keys specified in the figo Connect API specification
|
386
|
-
# @return [String]
|
387
|
-
attr_accessor :observe_key
|
388
|
-
|
389
|
-
# Notification messages will be sent to this URL
|
390
|
-
# @return [String]
|
391
|
-
attr_accessor :notify_uri
|
392
|
-
|
393
|
-
# State similiar to sync and logon process. It will passed as POST payload for webhooks
|
394
|
-
# @return [String]
|
395
|
-
attr_accessor :state
|
396
|
-
end
|
397
|
-
|
398
|
-
# Object representing a Payment
|
399
|
-
class Payment < Base
|
400
|
-
@dump_attributes = [:type, :name, :account_number, :bank_code, :amount, :currency, :purpose]
|
401
|
-
|
402
|
-
# Internal figo Connect payment ID
|
403
|
-
# @return [String]
|
404
|
-
attr_accessor :payment_id
|
405
|
-
|
406
|
-
# Internal figo Connect account ID
|
407
|
-
# @return [String]
|
408
|
-
attr_accessor :account_id
|
409
|
-
|
410
|
-
# Payment type
|
411
|
-
# @return [String]
|
412
|
-
attr_accessor :type
|
413
|
-
|
414
|
-
# Name of creditor or debtor
|
415
|
-
# @return [String]
|
416
|
-
attr_accessor :name
|
417
|
-
|
418
|
-
# Account number of creditor or debtor
|
419
|
-
# @return [String]
|
420
|
-
attr_accessor :account_number
|
421
|
-
|
422
|
-
# Bank code of creditor or debtor
|
423
|
-
# @return [String]
|
424
|
-
attr_accessor :bank_code
|
425
|
-
|
426
|
-
# Bank name of creditor or debtor
|
427
|
-
# @return [String]
|
428
|
-
attr_accessor :bank_name
|
429
|
-
|
430
|
-
# Icon of creditor or debtor bank
|
431
|
-
# @return [String]
|
432
|
-
attr_accessor :bank_icon
|
433
|
-
|
434
|
-
# Icon of the creditor or debtor bank in other resolutions
|
435
|
-
# @return [Hash]
|
436
|
-
attr_accessor :bank_additional_icons
|
437
|
-
|
438
|
-
# Order amount
|
439
|
-
# @return [DecNum]
|
440
|
-
attr_accessor :amount
|
441
|
-
|
442
|
-
# Three-character currency code
|
443
|
-
# @return [String]
|
444
|
-
attr_accessor :currency
|
445
|
-
|
446
|
-
# Purpose text
|
447
|
-
# @return [String]
|
448
|
-
attr_accessor :purpose
|
449
|
-
|
450
|
-
# Timestamp of submission to the bank server
|
451
|
-
# @return [DateTime]
|
452
|
-
attr_accessor :submission_timestamp
|
453
|
-
|
454
|
-
# Internal creation timestamp on the figo Connect server
|
455
|
-
# @return [DateTime]
|
456
|
-
attr_accessor :creation_timestamp
|
457
|
-
|
458
|
-
# Internal modification timestamp on the figo Connect server
|
459
|
-
# @return [DateTime]
|
460
|
-
attr_accessor :modification_timestamp
|
461
|
-
|
462
|
-
# ID of the transaction corresponding to this payment. This field is only set if the payment has been matched to a transaction
|
463
|
-
# @return [String]
|
464
|
-
attr_accessor :transaction_id
|
465
|
-
end
|
466
|
-
end
|