figo 1.2.5 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/config.yml +4 -0
  4. data/console_demo.rb +1 -1
  5. data/figo.gemspec +3 -3
  6. data/lib/account/api_call.rb +55 -0
  7. data/lib/account/model.rb +122 -0
  8. data/lib/account_balance/api_call.rb +18 -0
  9. data/lib/account_balance/model.rb +31 -0
  10. data/lib/authentification/api_call.rb +88 -0
  11. data/lib/bank/api_call.rb +49 -0
  12. data/lib/bank/model.rb +23 -0
  13. data/lib/base.rb +56 -0
  14. data/lib/cacert.pem +0 -0
  15. data/lib/figo.rb +54 -380
  16. data/lib/helpers/error.rb +20 -0
  17. data/lib/helpers/https.rb +52 -0
  18. data/lib/notification/api_call.rb +40 -0
  19. data/lib/notification/model.rb +27 -0
  20. data/lib/payment/api_call.rb +71 -0
  21. data/lib/payment/model.rb +75 -0
  22. data/lib/process/api_call.rb +17 -0
  23. data/lib/process/model.rb +34 -0
  24. data/lib/security/api_call.rb +59 -0
  25. data/lib/security/model.rb +83 -0
  26. data/lib/standing_order/api_call.rb +24 -0
  27. data/lib/standing_order/model.rb +75 -0
  28. data/lib/synchronization_status/api_call.rb +27 -0
  29. data/lib/synchronization_status/model.rb +23 -0
  30. data/lib/task/api_call.rb +37 -0
  31. data/lib/task/model.rb +43 -0
  32. data/lib/transaction/api_call.rb +57 -0
  33. data/lib/transaction/model.rb +75 -0
  34. data/lib/user/api_call.rb +46 -0
  35. data/lib/user/model.rb +55 -0
  36. data/test/config.yml +7 -0
  37. data/test/test_account_sync_and_setup.rb +67 -0
  38. data/test/test_accounts.rb +106 -0
  39. data/test/test_authentififcation.rb +68 -0
  40. data/test/test_business_processes.rb +43 -0
  41. data/test/test_figo.rb +5 -86
  42. data/test/test_notifications.rb +83 -0
  43. data/test/test_payments.rb +106 -0
  44. data/test/test_securities.rb +70 -0
  45. data/test/test_standing_orders.rb +49 -0
  46. data/test/test_transactions.rb +87 -0
  47. data/test/test_user_management.rb +91 -0
  48. metadata +64 -14
  49. data/lib/models.rb +0 -466
@@ -0,0 +1,7 @@
1
+ ACCESS_TOKEN: "ASHWLIkouP2O6_bgA2wWReRhletgWKHYjLqDaqb0LFfamim9RjexTo22ujRIP_cjLiRiSyQXyt2kM1eXU2XLFZQ0Hro15HikJQT_eNeT_9XQ"
2
+ CLIENT_ID: "CaESKmC8MAhNpDe5rvmWnSkRE_7pkkVIIgMwclgzGcQY"
3
+ CLIENT_SECRET: "STdzfv0GXtEj_bwYn7AgCVszN1kKq5BdgEIKOM_fzybQ"
4
+ REFRESH_TOKEN: "RTfI2WNyK78NozupDH9ai8GPRbjjdVsXPPtmobD2p_1epZUYmidZAOoT1TkFspMQOzNlCZpIrZREHrSdYeObea3Qda7hk2Q6PO5BEVF3GBh0"
5
+ AUTHORIZATION_CODE: "OkA7jUIro6JNmOF7i5f7QmepCLLoIFug6621ADHLMjK6oimFYK1x5xy5rl0wVZNkheCv5nMkH3hZ0v24immWGaI5aGc0P0F9ue0sgnV7DqwvM"
6
+ USERNAME: "demo@figo.me"
7
+ PASSWORD: "demo1234"
@@ -0,0 +1,67 @@
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 "flt"
24
+ require "minitest/autorun"
25
+ require "minitest/reporters"
26
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
27
+ require_relative "../lib/figo"
28
+
29
+ class FigoTest < MiniTest::Unit::TestCase
30
+ def setup
31
+ @sut = Figo::Session.new(CONFIG["ACCESS_TOKEN"])
32
+ end
33
+
34
+ ## Account Setup & Synchronization
35
+ # Retrieve List of Supported Banks, Credit Cards, other Payment Services
36
+ def test_retrieve_list_of_supported_baks_cards_services
37
+ execption = assert_raises(Figo::Error) { @sut.get_supported_payment_services("DE", "whatever") }
38
+ assert "Missing, invalid or expired access token.", execption.message
39
+ # assert @sut.get_supported_payment_services("DE", "whatever")
40
+ end
41
+
42
+ # Retrieve List of Supported Credit Cards and other Payment Services
43
+ def test_retrieve_list_of_supported_cards_services
44
+ execption = assert_raises(Figo::Error) { @sut.get_supported_payment_services("DE", "services") }
45
+ assert "Missing, invalid or expired access token.", execption.message
46
+ # assert @sut.get_supported_payment_services("DE", "services")
47
+ end
48
+
49
+ # Retrieve List of all Supported Banks
50
+ def test_retreive_list_of_all_supported_banks
51
+ execption = assert_raises(Figo::Error) { @sut.get_supported_payment_services("DE", "banks") }
52
+ assert "Missing, invalid or expired access token.", execption.message
53
+ # assert @sut.get_supported_payment_services("DE", "banks")
54
+ end
55
+
56
+ # Retrieve Login Settings for a Bank or Service
57
+ def test_retreive_login_settings_for_a_bank_or_service
58
+ execption = assert_raises(Figo::Error) { @sut.find_bank("B1.1") }
59
+ assert "Missing, invalid or expired access token.", execption.message
60
+ # assert @sut.find_bank("B1.1")
61
+ end
62
+
63
+ # Setup New Bank Account
64
+ def test_setup_new_bank_account
65
+ assert @sut.get_bank("B1.1")
66
+ end
67
+ end
@@ -0,0 +1,106 @@
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 "flt"
24
+ require "minitest/autorun"
25
+ require "minitest/reporters"
26
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
27
+ require_relative "../lib/figo"
28
+
29
+ class FigoTest < MiniTest::Unit::TestCase
30
+ def setup
31
+ @sut = Figo::Session.new(CONFIG["ACCESS_TOKEN"])
32
+ end
33
+
34
+ ## Accounts
35
+ # Retrieve Bank Account
36
+ def test_retrieve_bank_account
37
+ account = @sut.get_account "A1.2"
38
+ assert_equal account.account_id, "A1.2"
39
+ end
40
+
41
+ # Retrieve all Bank Accounts
42
+ def test_retreive_all_bank_accounts
43
+ accounts = @sut.accounts
44
+ assert accounts.length > 0
45
+ end
46
+
47
+ # Retrieve Bank Account Balance and Limits
48
+ def test_retreive_bank_account_balance_and_limits
49
+ assert @sut.get_account_balance("A1.2")
50
+ end
51
+
52
+ # Modify Bank Account
53
+ def test_modify_bank_account
54
+ account = @sut.get_account "A1.2"
55
+ account.name = "new name"
56
+
57
+ execption = assert_raises(Figo::Error) { @sut.modify_account account }
58
+ assert "Missing, invalid or expired access token.", execption.message
59
+ # @sut.modify_account account
60
+
61
+ # modified_account = @sut.get_account "A1.2"
62
+ # assert_equal modified_account.name "new name"
63
+ end
64
+
65
+ # Set Bank Account Sort Order
66
+ def test_set_account_sort_order
67
+ accounts = @sut.accounts
68
+ execption = assert_raises(Figo::Error) { @sut.account_sort_order(accounts) }
69
+ assert "Missing, invalid or expired access token.", execption.message
70
+
71
+ # assert @sut.account_sort_order(accounts)
72
+ end
73
+
74
+ # Delete bank account
75
+ def test_delete_bank_account
76
+ execption = assert_raises(Figo::Error) { @sut.remove_account("A1.2") }
77
+ assert "Missing, invalid or expired access token.", execption.message
78
+
79
+ # assert_nil @sut.remove_account("A1.2")
80
+ end
81
+
82
+ # Modify Bank Account Credit Line and Limits
83
+ def test_modify_bank_account_credit_line_and_limits
84
+ old_balance = @sut.get_account_balance("A1.2")
85
+ balance = old_balance.clone
86
+
87
+ balance.balance = 1
88
+
89
+ execption = assert_raises(Figo::Error) { @sut.modify_account_balance("A1.2", balance) }
90
+ assert "Missing, invalid or expired access token.", execption.message
91
+ # new_balance = @sut.modify_account_balance("A1.2", balance)
92
+
93
+ # assert old_balance.balance != new_balance.balance
94
+ end
95
+
96
+ # Remove Stored Pin from Bank Account
97
+ def test_remove_pin_from_bank_account
98
+
99
+ new_bank_info = Figo::Bank.new(@sut, {bank_id: "B1.1", sepa_creditor_id: "DE02ZZZ0123456789", save_pin: true})
100
+
101
+ execption = assert_raises(Figo::Error) { @sut.remove_bank_pin(new_bank_info) }
102
+ assert "Missing, invalid or expired access token.", execption.message
103
+
104
+ # assert_nil @sut.remove_bank_pin(new_bank_info)
105
+ end
106
+ end
@@ -0,0 +1,68 @@
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 "flt"
24
+ require "minitest/autorun"
25
+ require "minitest/reporters"
26
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
27
+ require_relative "../lib/figo"
28
+
29
+ AUTHORIZATION = {
30
+ CLIENT_ID: "",
31
+ CLIENT_SECRET: "",
32
+ USERNAME: "",
33
+ PASSWORD: "",
34
+ AUTHORIZATION_CODE: ""
35
+ }
36
+
37
+ class FigoTest < MiniTest::Unit::TestCase
38
+
39
+ def setup
40
+ @sut = Figo::Session.new(CONFIG["ACCESS_TOKEN"])
41
+ end
42
+
43
+ # Obtain Authorization Code
44
+ # login url
45
+ # Credential Login
46
+ # Exchange Authorization Code
47
+ # Revoke Token
48
+ # Exchange Refresh Token
49
+ def test_authentification_features
50
+ connection = Figo::Connection.new(CONFIG["CLIENT_ID"], CONFIG["CLIENT_SECRET"], "")
51
+
52
+ refute_nil connection.login_url("qweqwe", "accounts=ro transactions=ro balance=ro user=ro")
53
+
54
+ execption = assert_raises(Figo::Error) { connection.credential_login(CONFIG["USERNAME"], CONFIG["PASSWORD"]) }
55
+ assert "Unsupported grant type.", execption.message
56
+ # tokens = connection.credential_login(CONFIG["USERNAME"], CONFIG["PASSWORD"])
57
+
58
+ # assert tokens.access_token
59
+ # assert tokens.token_type
60
+ # assert tokens.refresh_token
61
+
62
+ # assert connection.obtain_access_token(CONFIG["AUTHORIZATION_CODE"])
63
+
64
+ # assert connection.revoke_token(tokens.refresh_token)
65
+
66
+ # assert connection.obtain_access_token(tokens.refresh_token)
67
+ end
68
+ end
@@ -0,0 +1,43 @@
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 "flt"
24
+ require "minitest/autorun"
25
+ require "minitest/reporters"
26
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
27
+ require_relative "../lib/figo"
28
+
29
+ class FigoTest < MiniTest::Unit::TestCase
30
+ def setup
31
+ @sut = Figo::Session.new(CONFIG["ACCESS_TOKEN"])
32
+ end
33
+
34
+ ## Business Process System
35
+ def test_create_and_begin_process
36
+ process = Figo::Process.new(@sut, { email: "example@example.com", password: "password", redirect_uri: "http://127.0.0.1", state: "123", steps: [] })
37
+
38
+ execption = assert_raises(Figo::Error) { @sut.create_process(process) }
39
+ assert "Missing, invalid or expired access token.", execption.message
40
+ # assert @sut.create_process(process)
41
+ # assert_nil @sut.start_task(@sut.create_process(process))
42
+ end
43
+ end
@@ -22,45 +22,16 @@
22
22
 
23
23
  require "flt"
24
24
  require "minitest/autorun"
25
+ require "minitest/reporters"
26
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
25
27
  require_relative "../lib/figo"
26
-
28
+ require "yaml"
27
29
 
28
30
  class FigoTest < MiniTest::Unit::TestCase
31
+ CONFIG = YAML.load_file(File.join(__dir__, 'CONFIG.yml'))
29
32
 
30
33
  def setup
31
- @sut = Figo::Session.new("ASHWLIkouP2O6_bgA2wWReRhletgWKHYjLqDaqb0LFfamim9RjexTo22ujRIP_cjLiRiSyQXyt2kM1eXU2XLFZQ0Hro15HikJQT_eNeT_9XQ")
32
- end
33
-
34
- def test_accounts
35
- @sut.accounts
36
- @sut.get_account "A1.1"
37
- account = @sut.get_account "A1.2"
38
- assert_equal account.account_id, "A1.2"
39
-
40
- # account sub-resources
41
- assert @sut.get_account("A1.2").balance.balance
42
- assert @sut.get_account("A1.2").balance.balance_date
43
-
44
- transactions = @sut.get_account("A1.2").transactions
45
- assert transactions.length > 0
46
-
47
- payments = @sut.get_account("A1.2").payments
48
- assert payments.length >= 0
49
- end
50
-
51
- def test_global_transactions
52
- transactions = @sut.transactions
53
- assert transactions.length > 0
54
- end
55
-
56
- def test_global_payments
57
- payments = @sut.payments
58
- assert payments.length >= 0
59
- end
60
-
61
- def test_notifications
62
- notifications = @sut.notifications
63
- assert notifications.length >= 0
34
+ @sut = Figo::Session.new(CONFIG["ACCESS_TOKEN"])
64
35
  end
65
36
 
66
37
  def test_missing_handling
@@ -74,56 +45,4 @@ class FigoTest < MiniTest::Unit::TestCase
74
45
  def test_sync_uri
75
46
  @sut.sync_url("qwe", "qew")
76
47
  end
77
-
78
- def test_user
79
- @sut.user
80
- end
81
-
82
- def test_create_update_delete_notification
83
- added_notification = @sut.add_notification(Figo::Notification.new(@sut, {:observe_key => "/rest/transactions", :notify_uri => "http://figo.me/test", :state => "qwe"}))
84
- refute_nil added_notification.notification_id
85
- assert_equal added_notification.observe_key, "/rest/transactions"
86
- assert_equal added_notification.notify_uri, "http://figo.me/test"
87
- assert_equal added_notification.state, "qwe"
88
-
89
- added_notification.state = "asd"
90
- modified_notification = @sut.modify_notification(added_notification)
91
- assert_equal modified_notification.notification_id, added_notification.notification_id
92
- assert_equal modified_notification.observe_key, "/rest/transactions"
93
- assert_equal modified_notification.notify_uri, "http://figo.me/test"
94
- assert_equal modified_notification.state, "asd"
95
-
96
- retrieved_notification = @sut.get_notification(modified_notification.notification_id)
97
- assert_equal retrieved_notification.notification_id, added_notification.notification_id
98
- assert_equal retrieved_notification.observe_key, "/rest/transactions"
99
- assert_equal retrieved_notification.notify_uri, "http://figo.me/test"
100
- assert_equal retrieved_notification.state, "asd"
101
-
102
- @sut.remove_notification(retrieved_notification)
103
- assert_nil @sut.get_notification(added_notification.notification_id)
104
- end
105
-
106
- def test_create_update_delete_payment
107
- added_payment = @sut.add_payment(Figo::Payment.new(@sut, {:account_id => "A1.1", :type => "Transfer", :account_number => "4711951501", :bank_code => "90090042", :name => "figo", :purpose => "Thanks for all the fish.", :amount => 0.89}))
108
- refute_nil added_payment.payment_id
109
- assert_equal added_payment.account_id, "A1.1"
110
- assert_equal added_payment.bank_name, "Demobank"
111
- assert_equal added_payment.amount, 0.89
112
-
113
- added_payment.amount = 2.39
114
- modified_payment = @sut.modify_payment(added_payment)
115
- assert_equal modified_payment.payment_id, added_payment.payment_id
116
- assert_equal modified_payment.account_id, "A1.1"
117
- assert_equal modified_payment.bank_name, "Demobank"
118
- assert_equal modified_payment.amount, 2.39
119
-
120
- retrieved_payment = @sut.get_payment(modified_payment.account_id, modified_payment.payment_id)
121
- assert_equal retrieved_payment.payment_id, added_payment.payment_id
122
- assert_equal retrieved_payment.account_id, "A1.1"
123
- assert_equal retrieved_payment.bank_name, "Demobank"
124
- assert_equal retrieved_payment.amount, 2.39
125
-
126
- @sut.remove_payment(retrieved_payment)
127
- assert_nil @sut.get_payment(modified_payment.account_id, modified_payment.payment_id)
128
- end
129
48
  end
@@ -0,0 +1,83 @@
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 "flt"
24
+ require "minitest/autorun"
25
+ require "minitest/reporters"
26
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
27
+ require_relative "../lib/figo"
28
+
29
+ class FigoTest < MiniTest::Unit::TestCase
30
+ def setup
31
+ @sut = Figo::Session.new(CONFIG["ACCESS_TOKEN"])
32
+ end
33
+
34
+ ## Notifications & Web Hooks
35
+ # Retrieve all Notifications
36
+ def test_retrieve_all_notifications
37
+ notifications = @sut.notifications
38
+ assert notifications.length >= 0
39
+ end
40
+
41
+ # Create a New Notification
42
+ def test_create_new_notification
43
+ added_notification = @sut.add_notification(Figo::Notification.new(@sut, {:observe_key => "/rest/transactions", :notify_uri => "http://figo.me/test", :state => "qwe"}))
44
+
45
+ refute_nil added_notification.notification_id
46
+ assert_equal added_notification.observe_key, "/rest/transactions"
47
+ assert_equal added_notification.notify_uri, "http://figo.me/test"
48
+ assert_equal added_notification.state, "qwe"
49
+ end
50
+
51
+ # Retrieve one Specific Notification
52
+ def test_retrieve_one_specific_notification
53
+ added_notification = @sut.add_notification(Figo::Notification.new(@sut, {:observe_key => "/rest/transactions", :notify_uri => "http://figo.me/test", :state => "qwe"}))
54
+
55
+ retrieved_notification = @sut.get_notification(added_notification.notification_id)
56
+
57
+ assert_equal retrieved_notification.notification_id, added_notification.notification_id
58
+ assert_equal retrieved_notification.observe_key, "/rest/transactions"
59
+ assert_equal retrieved_notification.notify_uri, "http://figo.me/test"
60
+ assert_equal retrieved_notification.state, "qwe"
61
+ end
62
+
63
+ # Modify Single Notification
64
+ def test_modify_single_notification
65
+ added_notification = @sut.add_notification(Figo::Notification.new(@sut, {:observe_key => "/rest/transactions", :notify_uri => "http://figo.me/test", :state => "qwe"}))
66
+
67
+ added_notification.state = "asd"
68
+ modified_notification = @sut.modify_notification(added_notification)
69
+
70
+ assert_equal modified_notification.notification_id, added_notification.notification_id
71
+ assert_equal modified_notification.observe_key, "/rest/transactions"
72
+ assert_equal modified_notification.notify_uri, "http://figo.me/test"
73
+ assert_equal modified_notification.state, "asd"
74
+ end
75
+
76
+ # Delete Notification
77
+ def test_delete_notification
78
+ added_notification = @sut.add_notification(Figo::Notification.new(@sut, {:observe_key => "/rest/transactions", :notify_uri => "http://figo.me/test", :state => "qwe"}))
79
+
80
+ @sut.remove_notification(added_notification)
81
+ assert_nil @sut.get_notification(added_notification.notification_id)
82
+ end
83
+ end