qonto_ofx 1.0.1

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 (99) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +1 -0
  4. data/.rubocop_todo.yml +68 -0
  5. data/Gemfile +6 -0
  6. data/Gemfile.lock +60 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +34 -0
  9. data/Rakefile +11 -0
  10. data/bin/qonto_ofx +24 -0
  11. data/bin/setup +8 -0
  12. data/lib/api_gateway.rb +47 -0
  13. data/lib/base_validator.rb +17 -0
  14. data/lib/converter.rb +158 -0
  15. data/lib/ofx_validator.rb +17 -0
  16. data/lib/organization_validator.rb +17 -0
  17. data/lib/qonto_ofx/version.rb +3 -0
  18. data/lib/transactions_listing_validator.rb +17 -0
  19. data/qonto_ofx.gemspec +32 -0
  20. data/qonto_organization_schema.json +63 -0
  21. data/qonto_transactions_schema.json +175 -0
  22. data/schema/.DS_Store +0 -0
  23. data/schema/OFX2_Protocol.xsd +783 -0
  24. data/schema/OFX3_Protocol_dotNET.xsd +691 -0
  25. data/schema/OFX_Banking.xsd +119 -0
  26. data/schema/OFX_Banking_Message_Wrappers.xsd +399 -0
  27. data/schema/OFX_Banking_Messages.xsd +431 -0
  28. data/schema/OFX_BillPay.xsd +223 -0
  29. data/schema/OFX_BillPay_Message_Wrappers.xsd +343 -0
  30. data/schema/OFX_BillPay_Messages.xsd +412 -0
  31. data/schema/OFX_BillerDelivery.xsd +263 -0
  32. data/schema/OFX_BillerDelivery_Message_Wrappers.xsd +295 -0
  33. data/schema/OFX_BillerDelivery_Messages.xsd +259 -0
  34. data/schema/OFX_BillerDirectory.xsd +132 -0
  35. data/schema/OFX_BillerDirectory_Message_Wrappers.xsd +56 -0
  36. data/schema/OFX_BillerDirectory_Messages.xsd +86 -0
  37. data/schema/OFX_Common.xsd +2329 -0
  38. data/schema/OFX_CreditCard.xsd +45 -0
  39. data/schema/OFX_CreditCard_Message_Wrappers.xsd +88 -0
  40. data/schema/OFX_CreditCard_Messages.xsd +102 -0
  41. data/schema/OFX_Email.xsd +25 -0
  42. data/schema/OFX_Email_Message_Wrappers.xsd +129 -0
  43. data/schema/OFX_Email_Messages.xsd +72 -0
  44. data/schema/OFX_Image_Message_Wrappers.xsd +31 -0
  45. data/schema/OFX_Image_Messages.xsd +35 -0
  46. data/schema/OFX_InterTransfer.xsd +24 -0
  47. data/schema/OFX_InterTransfer_Message_Wrappers.xsd +195 -0
  48. data/schema/OFX_InterTransfer_Messages.xsd +256 -0
  49. data/schema/OFX_Investment.xsd +1358 -0
  50. data/schema/OFX_Investment_Message_Wrappers.xsd +162 -0
  51. data/schema/OFX_Investment_Messages.xsd +149 -0
  52. data/schema/OFX_Loan_Message_Wrappers.xsd +1 -0
  53. data/schema/OFX_Loan_Messages.xsd +124 -0
  54. data/schema/OFX_Loans.xsd +200 -0
  55. data/schema/OFX_Messages.xsd +18 -0
  56. data/schema/OFX_Profile.xsd +959 -0
  57. data/schema/OFX_Profile_Message_Wrappers.xsd +55 -0
  58. data/schema/OFX_Profile_Messages.xsd +96 -0
  59. data/schema/OFX_SecuritiesList.xsd +357 -0
  60. data/schema/OFX_SecuritiesList_Message_Wrappers.xsd +55 -0
  61. data/schema/OFX_SecuritiesList_Messages.xsd +55 -0
  62. data/schema/OFX_Signon.xsd +243 -0
  63. data/schema/OFX_Signon_Message_Wrappers.xsd +120 -0
  64. data/schema/OFX_Signon_Messages.xsd +211 -0
  65. data/schema/OFX_Signup.xsd +114 -0
  66. data/schema/OFX_Signup_Message_Wrappers.xsd +222 -0
  67. data/schema/OFX_Signup_Messages.xsd +153 -0
  68. data/schema/OFX_Tax1098.xsd +123 -0
  69. data/schema/OFX_Tax1098_Message_Wrappers.xsd +52 -0
  70. data/schema/OFX_Tax1098_Messages.xsd +65 -0
  71. data/schema/OFX_Tax1099.xsd +371 -0
  72. data/schema/OFX_Tax1099_Message_Wrappers.xsd +52 -0
  73. data/schema/OFX_Tax1099_Messages.xsd +50 -0
  74. data/schema/OFX_TaxW2.xsd +204 -0
  75. data/schema/OFX_TaxW2_Message_Wrappers.xsd +52 -0
  76. data/schema/OFX_TaxW2_Messages.xsd +58 -0
  77. data/schema/OFX_TypeDefinitions.xsd +98 -0
  78. data/schema/OFX_WireTransfer.xsd +88 -0
  79. data/schema/OFX_WireTransfer_Message_Wrappers.xsd +101 -0
  80. data/schema/OFX_WireTransfer_Messages.xsd +116 -0
  81. data/test/sample/ofx/invalid.xml +34 -0
  82. data/test/sample/ofx/malformed.xml +38 -0
  83. data/test/sample/ofx/test_result.xml +101 -0
  84. data/test/sample/ofx/valid.xml +38 -0
  85. data/test/sample/organization/invalid_format.txt +1 -0
  86. data/test/sample/organization/malformed.txt +1 -0
  87. data/test/sample/organization/valid_one_account.txt +1 -0
  88. data/test/sample/organization/valid_two_accounts.txt +1 -0
  89. data/test/sample/transactions/corp-1234-bank-account-1-FR0000000000000000000000001.txt +60 -0
  90. data/test/sample/transactions/corp-1234-bank-account-2-FR0000000000000000000000002-p1.txt +28 -0
  91. data/test/sample/transactions/corp-1234-bank-account-2-FR0000000000000000000000002-p2.txt +28 -0
  92. data/test/sample/transactions/invalid_format.txt +1 -0
  93. data/test/sample/transactions/malformed.txt +1 -0
  94. data/test/sample/transactions/valid.txt +1 -0
  95. data/test/test_converter.rb +51 -0
  96. data/test/test_ofx_validator.rb +25 -0
  97. data/test/test_organization_validator.rb +28 -0
  98. data/test/test_transactions_listing_validator.rb +23 -0
  99. metadata +314 -0
@@ -0,0 +1,116 @@
1
+ <?xml version="1.0" encoding="utf-8" standalone="no"?>
2
+
3
+ <!--
4
+
5
+ Open Financial Exchange Specification (c)1996-2003 ("Specification") by all of its publishers:
6
+ CheckFree Corp., Intuit Inc., and Microsoft Corporation. All rights reserved.
7
+
8
+ Revision History:
9
+
10
+ Version Date Editor Email Addr Short Description
11
+
12
+ p18 2002-02-11 altenburgd@businesslogic.com Initial revision
13
+ p20 2002-03-10 altenburgd@businesslogic.com Created abstract type 'AbstractWireResponse' and made 'WireResponse' and
14
+ WireCancellationResponse' to extend it
15
+ Created abstract type 'AbstractWireRequest' and made 'WireRequest' and
16
+ 'WireCancellationRequest' to extend it
17
+ p21 2002-03-17 altenburgd@businesslogic.com Changed elementFormDefault to "unqualified"
18
+ Changed namespace to "http://ofx.net/types/2003/04"
19
+ -->
20
+
21
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
22
+ elementFormDefault="unqualified"
23
+ xmlns:ofx="http://ofx.net/types/2003/04"
24
+ targetNamespace="http://ofx.net/types/2003/04">
25
+
26
+
27
+ <xsd:include schemaLocation = "OFX_WireTransfer.xsd" />
28
+
29
+ <xsd:complexType name="AbstractWireResponse" abstract="true"/>
30
+
31
+ <xsd:complexType name="WireCancellationResponse">
32
+ <xsd:annotation>
33
+ <xsd:documentation>
34
+ The OFX element "WIRECANRS" is of type "WireCancellationResponse"
35
+ </xsd:documentation>
36
+ </xsd:annotation>
37
+ <xsd:complexContent>
38
+ <xsd:extension base="ofx:AbstractWireResponse">
39
+ <xsd:sequence>
40
+ <xsd:element name="SRVRTID" type="ofx:ServerIdType" />
41
+ </xsd:sequence>
42
+ </xsd:extension>
43
+ </xsd:complexContent>
44
+ </xsd:complexType>
45
+
46
+ <xsd:complexType name="AbstractWireRequest" abstract="true"/>
47
+
48
+ <xsd:complexType name="WireRequest">
49
+ <xsd:annotation>
50
+ <xsd:documentation>
51
+ The OFX element "WIRERQ" is of type "WireRequest"
52
+ </xsd:documentation>
53
+ </xsd:annotation>
54
+
55
+ <xsd:complexContent>
56
+ <xsd:extension base="ofx:AbstractWireRequest">
57
+ <xsd:sequence>
58
+ <xsd:element name="BANKACCTFROM" type="ofx:BankAccount" />
59
+ <xsd:element name="WIREBENEFICIARY" type="ofx:WireBeneficiary" />
60
+ <xsd:element name="WIREDESTBANK" type="ofx:WireDestinationBank" minOccurs="0" maxOccurs="1" />
61
+ <xsd:element name="TRNAMT" type="ofx:AmountType" />
62
+ <xsd:element name="DTDUE" type="ofx:DateTimeType" minOccurs="0" maxOccurs="1" />
63
+ <xsd:element name="PAYINSTRUCT" type="ofx:MessageType" minOccurs="0" maxOccurs="1" />
64
+ </xsd:sequence>
65
+ </xsd:extension>
66
+ </xsd:complexContent>
67
+ </xsd:complexType>
68
+
69
+ <xsd:complexType name="WireCancellationRequest">
70
+ <xsd:annotation>
71
+ <xsd:documentation>
72
+ The OFX element "WIRECANRQ" is of type "WireCancellationRequest"
73
+ </xsd:documentation>
74
+ </xsd:annotation>
75
+
76
+ <xsd:complexContent>
77
+ <xsd:extension base="ofx:AbstractWireRequest">
78
+ <xsd:sequence>
79
+ <xsd:element name="SRVRTID" type="ofx:ServerIdType" />
80
+ </xsd:sequence>
81
+ </xsd:extension>
82
+ </xsd:complexContent>
83
+ </xsd:complexType>
84
+
85
+
86
+
87
+ <xsd:complexType name="WireResponse">
88
+ <xsd:annotation>
89
+ <xsd:documentation>
90
+ The OFX element "WIRERS" is of type "WireResponse"
91
+ </xsd:documentation>
92
+ </xsd:annotation>
93
+
94
+ <xsd:complexContent>
95
+ <xsd:extension base="ofx:AbstractWireResponse">
96
+ <xsd:sequence>
97
+ <xsd:element name="CURDEF" type="ofx:CurrencyEnum" />
98
+ <xsd:element name="SRVRTID" type="ofx:ServerIdType" />
99
+ <xsd:element name="BANKACCTFROM" type="ofx:BankAccount" />
100
+ <xsd:element name="WIREBENEFICIARY" type="ofx:WireBeneficiary" />
101
+ <xsd:element name="WIREDESTBANK" type="ofx:WireDestinationBank" minOccurs="0" maxOccurs="1" />
102
+ <xsd:element name="TRNAMT" type="ofx:AmountType" />
103
+ <xsd:element name="DTDUE" type="ofx:DateTimeType" minOccurs="0" maxOccurs="1" />
104
+ <xsd:element name="PAYINSTRUCT" type="ofx:MessageType" minOccurs="0" maxOccurs="1" />
105
+ <xsd:choice minOccurs="0" maxOccurs="1">
106
+ <xsd:element name="DTXFERPRJ" type="ofx:DateTimeType" />
107
+ <xsd:element name="DTPOSTED" type="ofx:DateTimeType" />
108
+ </xsd:choice>
109
+ <xsd:element name="FEE" type="ofx:AmountType" minOccurs="0" maxOccurs="1" />
110
+ <xsd:element name="CONFMSG" type="ofx:MessageType" minOccurs="0" maxOccurs="1" />
111
+ </xsd:sequence>
112
+ </xsd:extension>
113
+ </xsd:complexContent>
114
+ </xsd:complexType>
115
+
116
+ </xsd:schema>
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0"?>
2
+ <ofx:OFX xmlns:ofx="http://ofx.net/types/2003/04">
3
+ <SIGNONMSGSRSV1>
4
+ <SONRS>
5
+ <DTSERVER>20180710094504</DTSERVER>
6
+ <LANGUAGE>FRE</LANGUAGE>
7
+ </SONRS>
8
+ </SIGNONMSGSRSV1>
9
+ <BANKMSGSRSV1>
10
+ <STMTTRNRS>
11
+ <TRNUID>1</TRNUID>
12
+ <STATUS>
13
+ <CODE>0</CODE>
14
+ <SEVERITY>INFO</SEVERITY>
15
+ </STATUS>
16
+ <STMTRS>
17
+ <CURDEF>EUR</CURDEF>
18
+ <BANKACCTFROM>
19
+ <BANKID>0000</BANKID>
20
+ <ACCTID>798000010000036472315</ACCTID>
21
+ <ACCTTYPE>CHECKING</ACCTTYPE>
22
+ </BANKACCTFROM>
23
+ <BANKTRANLIST>
24
+ <DTSTART>20180710094504</DTSTART>
25
+ <DTEND>20180710094504</DTEND>
26
+ </BANKTRANLIST>
27
+ <LEDGERBAL>
28
+ <BALAMT>0.0</BALAMT>
29
+ <DTASOF>20180710094504</DTASOF>
30
+ </LEDGERBAL>
31
+ </STMTRS>
32
+ </STMTTRNRS>
33
+ </BANKMSGSRSV1>
34
+ </ofx:OFX>
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0"?>
2
+ <ofx:OFX xmlns:ofx="http://ofx.net/types/2003/04">
3
+ <SIGNONMSGSRSV1>
4
+ <SONRS>
5
+ <STATUS>
6
+ <CODE>0</CODE>
7
+ <SEVERITY>INFO</SEVERITY>
8
+ </STATUS>
9
+ <DTSERVER>20180710094504</DTSERVER>
10
+ <LANGUAGE>FRE</LANGUAGE>
11
+ </SONRS>
12
+ </SIGNONMSGSRSV1>
13
+ <BANKMSGSRSV1>
14
+ <STMTTRNRS>
15
+ <TRNUID>1</TRNUID>
16
+ <STATUS>
17
+ <CODE>0</CODE>
18
+ <SEVERITY>INFO
19
+ </STATUS>
20
+ <STMTRS>
21
+ <CURDEF>EUR</CURDEF>
22
+ <BANKACCTFROM>
23
+ <BANKID>0000</BANKID>
24
+ <ACCTID>798000010000036472315</ACCTID>
25
+ <ACCTTYPE>CHECKING</ACCTTYPE>
26
+ </BANKACCTFROM>
27
+ <BANKTRANLIST>
28
+ <DTSTART>20180710094504</DTSTART>
29
+ <DTEND>20180710094504</DTEND>
30
+ </BANKTRANLIST>
31
+ <LEDGERBAL>
32
+ <BALAMT>0.0</BALAMT>
33
+ <DTASOF>20180710094504</DTASOF>
34
+ </LEDGERBAL>
35
+ </STMTRS>
36
+ </STMTTRNRS>
37
+ </BANKMSGSRSV1>
38
+ </ofx:OFX>
@@ -0,0 +1,101 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <ofx:OFX xmlns:ofx="http://ofx.net/types/2003/04">
3
+ <SIGNONMSGSRSV1>
4
+ <SONRS>
5
+ <STATUS>
6
+ <CODE>0</CODE>
7
+ <SEVERITY>INFO</SEVERITY>
8
+ </STATUS>
9
+ <DTSERVER>20180710000000</DTSERVER>
10
+ <LANGUAGE>FRE</LANGUAGE>
11
+ </SONRS>
12
+ </SIGNONMSGSRSV1>
13
+ <BANKMSGSRSV1>
14
+ <STMTTRNRS>
15
+ <TRNUID>1</TRNUID>
16
+ <STATUS>
17
+ <CODE>0</CODE>
18
+ <SEVERITY>INFO</SEVERITY>
19
+ </STATUS>
20
+ <STMTRS>
21
+ <CURDEF>EUR</CURDEF>
22
+ <BANKACCTFROM>
23
+ <BANKID>0000</BANKID>
24
+ <ACCTID>000000000000000000001</ACCTID>
25
+ <ACCTTYPE>CHECKING</ACCTTYPE>
26
+ </BANKACCTFROM>
27
+ <BANKTRANLIST>
28
+ <DTSTART>20180706070608</DTSTART>
29
+ <DTEND>20180707070608</DTEND>
30
+ <STMTTRN>
31
+ <TRNTYPE>POS</TRNTYPE>
32
+ <DTPOSTED>20180706070608</DTPOSTED>
33
+ <TRNAMT>-12.4</TRNAMT>
34
+ <FITID>corp-1234-transaction-1</FITID>
35
+ <NAME>test transaction #1 - amount wit</NAME>
36
+ <MEMO>test transaction #1</MEMO>
37
+ </STMTTRN>
38
+ <STMTTRN>
39
+ <TRNTYPE>POS</TRNTYPE>
40
+ <DTPOSTED>20180707070608</DTPOSTED>
41
+ <TRNAMT>-12.0</TRNAMT>
42
+ <FITID>corp-1234-transaction-2</FITID>
43
+ <NAME>test transaction #2 - amount wit</NAME>
44
+ <MEMO>test transaction #2</MEMO>
45
+ </STMTTRN>
46
+ <STMTTRN>
47
+ <TRNTYPE>XFER</TRNTYPE>
48
+ <DTPOSTED>20180707070608</DTPOSTED>
49
+ <TRNAMT>12.0</TRNAMT>
50
+ <FITID>corp-1234-transaction-3</FITID>
51
+ <NAME>test transaction #3 - debit</NAME>
52
+ <MEMO>test transaction #3</MEMO>
53
+ </STMTTRN>
54
+ </BANKTRANLIST>
55
+ <LEDGERBAL>
56
+ <BALAMT>12.0</BALAMT>
57
+ <DTASOF>20180710000000</DTASOF>
58
+ </LEDGERBAL>
59
+ </STMTRS>
60
+ </STMTTRNRS>
61
+ <STMTTRNRS>
62
+ <TRNUID>1</TRNUID>
63
+ <STATUS>
64
+ <CODE>0</CODE>
65
+ <SEVERITY>INFO</SEVERITY>
66
+ </STATUS>
67
+ <STMTRS>
68
+ <CURDEF>EUR</CURDEF>
69
+ <BANKACCTFROM>
70
+ <BANKID>0000</BANKID>
71
+ <ACCTID>000000000000000000002</ACCTID>
72
+ <ACCTTYPE>CHECKING</ACCTTYPE>
73
+ </BANKACCTFROM>
74
+ <BANKTRANLIST>
75
+ <DTSTART>20180706070608</DTSTART>
76
+ <DTEND>20180706070608</DTEND>
77
+ <STMTTRN>
78
+ <TRNTYPE>POS</TRNTYPE>
79
+ <DTPOSTED>20180706070608</DTPOSTED>
80
+ <TRNAMT>-12.4</TRNAMT>
81
+ <FITID>corp-1234-transaction-1</FITID>
82
+ <NAME>test transaction #1</NAME>
83
+ <MEMO>test transaction #1</MEMO>
84
+ </STMTTRN>
85
+ <STMTTRN>
86
+ <TRNTYPE>POS</TRNTYPE>
87
+ <DTPOSTED>20180706070608</DTPOSTED>
88
+ <TRNAMT>-12.4</TRNAMT>
89
+ <FITID>corp-1234-transaction-2</FITID>
90
+ <NAME>test transaction #2</NAME>
91
+ <MEMO>test transaction #2</MEMO>
92
+ </STMTTRN>
93
+ </BANKTRANLIST>
94
+ <LEDGERBAL>
95
+ <BALAMT>13.0</BALAMT>
96
+ <DTASOF>20180710000000</DTASOF>
97
+ </LEDGERBAL>
98
+ </STMTRS>
99
+ </STMTTRNRS>
100
+ </BANKMSGSRSV1>
101
+ </ofx:OFX>
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0"?>
2
+ <ofx:OFX xmlns:ofx="http://ofx.net/types/2003/04">
3
+ <SIGNONMSGSRSV1>
4
+ <SONRS>
5
+ <STATUS>
6
+ <CODE>0</CODE>
7
+ <SEVERITY>INFO</SEVERITY>
8
+ </STATUS>
9
+ <DTSERVER>20180710094504</DTSERVER>
10
+ <LANGUAGE>FRE</LANGUAGE>
11
+ </SONRS>
12
+ </SIGNONMSGSRSV1>
13
+ <BANKMSGSRSV1>
14
+ <STMTTRNRS>
15
+ <TRNUID>1</TRNUID>
16
+ <STATUS>
17
+ <CODE>0</CODE>
18
+ <SEVERITY>INFO</SEVERITY>
19
+ </STATUS>
20
+ <STMTRS>
21
+ <CURDEF>EUR</CURDEF>
22
+ <BANKACCTFROM>
23
+ <BANKID>0000</BANKID>
24
+ <ACCTID>798000010000036472315</ACCTID>
25
+ <ACCTTYPE>CHECKING</ACCTTYPE>
26
+ </BANKACCTFROM>
27
+ <BANKTRANLIST>
28
+ <DTSTART>20180710094504</DTSTART>
29
+ <DTEND>20180710094504</DTEND>
30
+ </BANKTRANLIST>
31
+ <LEDGERBAL>
32
+ <BALAMT>0.0</BALAMT>
33
+ <DTASOF>20180710094504</DTASOF>
34
+ </LEDGERBAL>
35
+ </STMTRS>
36
+ </STMTTRNRS>
37
+ </BANKMSGSRSV1>
38
+ </ofx:OFX>
@@ -0,0 +1 @@
1
+ {"organization":{"slug":"corp-1234","bank_accounts":[{"slug":"corp-1234-bank-account-1","iban":"BAD_FORMAT","bic":"XXXXXXXXXXX","currency":"EUR","balance":12.0,"balance_cents":120,"authorized_balance":12.5,"authorized_balance_cents":125}]}}
@@ -0,0 +1 @@
1
+ {"organization":{"slug":"corp-1234","ba
@@ -0,0 +1 @@
1
+ {"organization":{"slug":"corp-1234","bank_accounts":[{"slug":"corp-1234-bank-account-1","iban":"FR0000000000000000000000001","bic":"XXXXXXXXXXX","currency":"EUR","balance":12,"balance_cents":120,"authorized_balance":12,"authorized_balance_cents":120}]}}
@@ -0,0 +1 @@
1
+ {"organization":{"slug":"corp-1234","bank_accounts":[{"slug":"corp-1234-bank-account-1","iban":"FR0000000000000000000000001","bic":"XXXXXXXXXXX","currency":"EUR","balance":12.0,"balance_cents":120,"authorized_balance":12.5,"authorized_balance_cents":125},{"slug":"corp-1234-bank-account-2","iban":"FR0000000000000000000000002","bic":"XXXXXXXXXXX","currency":"EUR","balance":13.0,"balance_cents":130,"authorized_balance":13.4,"authorized_balance_cents":134}]}}
@@ -0,0 +1,60 @@
1
+ {
2
+ "transactions":[
3
+ {
4
+ "transaction_id":"corp-1234-transaction-1",
5
+ "amount":12.4,
6
+ "amount_cents":124,
7
+ "local_amount":12.3,
8
+ "local_amount_cents":123,
9
+ "side":"debit",
10
+ "operation_type":"card",
11
+ "currency":"EUR",
12
+ "local_currency":"USD",
13
+ "label":"test transaction #1 - amount with cents",
14
+ "settled_at":"2018-07-06T07:06:08.000Z",
15
+ "emitted_at":"2018-07-06T07:06:08.000Z",
16
+ "status":"completed",
17
+ "note":"test transaction #1"
18
+ },
19
+ {
20
+ "transaction_id":"corp-1234-transaction-2",
21
+ "amount":12.0,
22
+ "amount_cents":120,
23
+ "local_amount":12.0,
24
+ "local_amount_cents":120,
25
+ "side":"debit",
26
+ "operation_type":"card",
27
+ "currency":"EUR",
28
+ "local_currency":"USD",
29
+ "label":"test transaction #2 - amount without cents",
30
+ "settled_at":"2018-07-07T07:06:08.000Z",
31
+ "emitted_at":"2018-07-07T07:06:08.000Z",
32
+ "status":"completed",
33
+ "note":"test transaction #2"
34
+ },
35
+ {
36
+ "transaction_id":"corp-1234-transaction-3",
37
+ "amount":12.0,
38
+ "amount_cents":120,
39
+ "local_amount":12.0,
40
+ "local_amount_cents":120,
41
+ "side":"credit",
42
+ "operation_type":"income",
43
+ "currency":"EUR",
44
+ "local_currency":"USD",
45
+ "label":"test transaction #3 - debit",
46
+ "settled_at":"2018-07-07T07:06:08.000Z",
47
+ "emitted_at":"2018-07-07T07:06:08.000Z",
48
+ "status":"completed",
49
+ "note":"test transaction #3"
50
+ }
51
+ ],
52
+ "meta":{
53
+ "current_page":1,
54
+ "next_page":null,
55
+ "prev_page":null,
56
+ "total_pages":3,
57
+ "total_count":3,
58
+ "per_page":100
59
+ }
60
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "transactions":[
3
+ {
4
+ "transaction_id":"corp-1234-transaction-1",
5
+ "amount":12.4,
6
+ "amount_cents":124,
7
+ "local_amount":12.3,
8
+ "local_amount_cents":123,
9
+ "side":"debit",
10
+ "operation_type":"card",
11
+ "currency":"EUR",
12
+ "local_currency":"USD",
13
+ "label":"test transaction #1",
14
+ "settled_at":"2018-07-06T07:06:08.000Z",
15
+ "emitted_at":"2018-07-06T07:06:08.000Z",
16
+ "status":"completed",
17
+ "note":"test transaction #1"
18
+ }
19
+ ],
20
+ "meta":{
21
+ "current_page":1,
22
+ "next_page":"https://thirdparty.qonto.eu/v2/transactions?slug=corp-1234-bank-account-2&iban=FR0000000000000000000000002&page=2",
23
+ "prev_page":null,
24
+ "total_pages":2,
25
+ "total_count":2,
26
+ "per_page":1
27
+ }
28
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "transactions":[
3
+ {
4
+ "transaction_id":"corp-1234-transaction-2",
5
+ "amount":12.4,
6
+ "amount_cents":124,
7
+ "local_amount":12.3,
8
+ "local_amount_cents":123,
9
+ "side":"debit",
10
+ "operation_type":"card",
11
+ "currency":"EUR",
12
+ "local_currency":"USD",
13
+ "label":"test transaction #2",
14
+ "settled_at":"2018-07-06T07:06:08.000Z",
15
+ "emitted_at":"2018-07-06T07:06:08.000Z",
16
+ "status":"completed",
17
+ "note":"test transaction #2"
18
+ }
19
+ ],
20
+ "meta":{
21
+ "current_page":2,
22
+ "next_page":null,
23
+ "prev_page":"https://thirdparty.qonto.eu/v2/transactions?slug=corp-1234-bank-account-2&iban=FR0000000000000000000000002",
24
+ "total_pages":2,
25
+ "total_count":2,
26
+ "per_page":1
27
+ }
28
+ }
@@ -0,0 +1 @@
1
+ {"transactions":[{"transaction_id":"$$$$$$corp-1234-1-transaction-1","amount":0.86,"amount_cents":86,"local_amount":1.0,"local_amount_cents":100,"side":"debit","operation_type":"card","currency":"EUR","local_currency":"USD","label":"Amazon web services","settled_at":null,"emitted_at":"2018-07-06T07:06:08.000Z","status":"declined","note":"Ajout de ma carte sur AWS (transaction de $1 de test)"}],"meta":{"current_page":1,"next_page":null,"prev_page":null,"total_pages":1,"total_count":1,"per_page":100}}
@@ -0,0 +1 @@
1
+ {"transactions":[{"transaction_id":"corp-1234-1-transaction-1","amount":0.86,"amount_cents
@@ -0,0 +1 @@
1
+ {"transactions":[{"transaction_id":"corp-1234-1-transaction-1","amount":0.86,"amount_cents":86,"local_amount":1.0,"local_amount_cents":100,"side":"debit","operation_type":"card","currency":"EUR","local_currency":"USD","label":"Amazon web services","settled_at":null,"emitted_at":"2018-07-06T07:06:08.000Z","status":"declined","note":"Ajout de ma carte sur AWS (transaction de $1 de test)"}],"meta":{"current_page":1,"next_page":null,"prev_page":null,"total_pages":1,"total_count":1,"per_page":100}}
@@ -0,0 +1,51 @@
1
+ require 'minitest/autorun'
2
+ require 'mocha/minitest'
3
+ require 'converter'
4
+ require 'api_gateway'
5
+ require 'diffy'
6
+
7
+ class QontoOfxTest < Minitest::Test
8
+ def setup
9
+ QontoOfx::ApiGateway.any_instance
10
+ .stubs(:fetch_organization)
11
+ .returns(JSON.parse(
12
+ File.readlines('./test/sample/organization/valid_two_accounts.txt').join
13
+ ))
14
+
15
+ stub_transactions(
16
+ 'https://thirdparty.qonto.eu/v2/transactions?slug=corp-1234-bank-account-1&iban=FR0000000000000000000000001',
17
+ './test/sample/transactions/corp-1234-bank-account-1-FR0000000000000000000000001.txt'
18
+ )
19
+ stub_transactions(
20
+ 'https://thirdparty.qonto.eu/v2/transactions?slug=corp-1234-bank-account-2&iban=FR0000000000000000000000002',
21
+ './test/sample/transactions/corp-1234-bank-account-2-FR0000000000000000000000002-p1.txt'
22
+ )
23
+ stub_transactions(
24
+ 'https://thirdparty.qonto.eu/v2/transactions?slug=corp-1234-bank-account-2&iban=FR0000000000000000000000002&page=2',
25
+ './test/sample/transactions/corp-1234-bank-account-2-FR0000000000000000000000002-p2.txt'
26
+ )
27
+ @converter = QontoOfx::Converter.new('SLUG', 'TOKEN')
28
+ Time.stubs(:now).returns(Time.new(2018, 07, 10))
29
+ end
30
+
31
+ def stub_transactions(url, file)
32
+ QontoOfx::ApiGateway.any_instance
33
+ .stubs(:fetch_transactions)
34
+ .with(url)
35
+ .returns(JSON.parse(
36
+ File.readlines(file).join
37
+ ))
38
+ end
39
+
40
+ def test_convert
41
+ result = @converter.convert
42
+
43
+ diff = Diffy::Diff.new(
44
+ File.readlines('test/sample/ofx/test_result.xml').join,
45
+ result
46
+ ).to_s(:color).chomp
47
+ puts diff unless diff.empty?
48
+
49
+ assert diff.empty?
50
+ end
51
+ end
@@ -0,0 +1,25 @@
1
+ require 'minitest/autorun'
2
+ require 'mocha/minitest'
3
+ require 'ofx_validator'
4
+ require 'nokogiri'
5
+
6
+ class OfxValidatorTest < Minitest::Test
7
+ def setup
8
+ @validator = QontoOfx::OfxValidator.new
9
+ end
10
+
11
+ def test_valid
12
+ input = File.readlines('./test/sample/ofx/valid.xml').join
13
+ assert @validator.valid? input
14
+ end
15
+
16
+ def test_invalid
17
+ input = File.readlines('./test/sample/ofx/invalid.xml').join
18
+ refute @validator.valid? input
19
+ end
20
+
21
+ def test_malformed
22
+ input = File.readlines('./test/sample/ofx/malformed.xml').join
23
+ refute @validator.valid? input
24
+ end
25
+ end
@@ -0,0 +1,28 @@
1
+ require 'minitest/autorun'
2
+ require 'mocha/minitest'
3
+
4
+ class OrganizationValidatorTest < Minitest::Test
5
+ def setup
6
+ @validator = QontoOfx::OrganizationValidator.new
7
+ end
8
+
9
+ def test_valid_one_account_json
10
+ input = File.readlines('./test/sample/organization/valid_one_account.txt').join
11
+ assert @validator.valid? input
12
+ end
13
+
14
+ def test_valid_two_account_json
15
+ input = File.readlines('./test/sample/organization/valid_two_accounts.txt').join
16
+ assert @validator.valid? input
17
+ end
18
+
19
+ def test_invalid_format
20
+ input = File.readlines('./test/sample/organization/invalid_format.txt').join
21
+ refute @validator.valid? input
22
+ end
23
+
24
+ def test_malformed_json
25
+ input = File.readlines('./test/sample/organization/malformed.txt').join
26
+ refute @validator.valid? input
27
+ end
28
+ end
@@ -0,0 +1,23 @@
1
+ require 'minitest/autorun'
2
+ require 'mocha/minitest'
3
+
4
+ class TransactionsListingValidatorTest < Minitest::Test
5
+ def setup
6
+ @validator = QontoOfx::TransactionsListingValidator.new
7
+ end
8
+
9
+ def test_valid_json
10
+ input = File.readlines('./test/sample/transactions/valid.txt').join
11
+ assert @validator.valid? input
12
+ end
13
+
14
+ def test_invalid_format
15
+ input = File.readlines('./test/sample/transactions/invalid_format.txt').join
16
+ refute @validator.valid? input
17
+ end
18
+
19
+ def test_malformed_json
20
+ input = File.readlines('./test/sample/transactions/malformed.txt').join
21
+ refute @validator.valid? input
22
+ end
23
+ end