finapps 0.22.4.pre → 1.0.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.
- checksums.yaml +4 -4
 - data/.gitignore +7 -25
 - data/.rspec +5 -0
 - data/finapps.gemspec +8 -8
 - data/lib/finapps/middleware/api_token.rb +6 -6
 - data/lib/finapps/rest/alert.rb +12 -5
 - data/lib/finapps/rest/alert_definition.rb +11 -3
 - data/lib/finapps/rest/alert_preferences.rb +10 -2
 - data/lib/finapps/rest/alert_settings.rb +11 -3
 - data/lib/finapps/rest/budget_calculation.rb +11 -4
 - data/lib/finapps/rest/budget_models.rb +11 -3
 - data/lib/finapps/rest/budgets.rb +10 -4
 - data/lib/finapps/rest/cashflows.rb +5 -3
 - data/lib/finapps/rest/categories.rb +6 -2
 - data/lib/finapps/rest/client.rb +102 -48
 - data/lib/finapps/rest/connection.rb +20 -45
 - data/lib/finapps/rest/defaults.rb +1 -2
 - data/lib/finapps/rest/institutions.rb +11 -3
 - data/lib/finapps/rest/relevance/rulesets.rb +10 -10
 - data/lib/finapps/rest/transactions.rb +16 -4
 - data/lib/finapps/rest/user_institutions.rb +35 -10
 - data/lib/finapps/rest/users.rb +20 -24
 - data/lib/finapps/utils/logging.rb +7 -7
 - data/lib/finapps/version.rb +1 -1
 - data/spec/middleware/api_token_spec.rb +32 -0
 - data/spec/rest/client_spec.rb +91 -59
 - data/spec/rest/connection_spec.rb +40 -0
 - data/spec/spec_helper.rb +12 -60
 - data/spec/utils/logging_spec.rb +4 -8
 - metadata +70 -54
 - data/bin/finapps +0 -9
 - data/lib/finapps/cli/alert_preferences.rb +0 -65
 - data/lib/finapps/cli/budgets.rb +0 -37
 - data/lib/finapps/cli/cashflows.rb +0 -37
 - data/lib/finapps/cli/common.rb +0 -43
 - data/lib/finapps/cli/institutions.rb +0 -59
 - data/lib/finapps/cli/users.rb +0 -87
 
| 
         @@ -7,37 +7,49 @@ module FinApps 
     | 
|
| 
       7 
7 
     | 
    
         
             
                  # @transaction_id [String]
         
     | 
| 
       8 
8 
     | 
    
         
             
                  # # @return [Hash, Array<String>]
         
     | 
| 
       9 
9 
     | 
    
         
             
                  def show(transaction_id)
         
     | 
| 
      
 10 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Started"
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       10 
12 
     | 
    
         
             
                    end_point = Defaults::END_POINTS[:transactions_show]
         
     | 
| 
       11 
13 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => end_point: #{end_point}"
         
     | 
| 
       12 
14 
     | 
    
         | 
| 
       13 
15 
     | 
    
         
             
                    path = end_point.sub ':transaction_id', ERB::Util.url_encode(transaction_id)
         
     | 
| 
       14 
16 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => path: #{path}"
         
     | 
| 
       15 
17 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
                    transaction, error_messages = 
     | 
| 
      
 18 
     | 
    
         
            +
                    transaction, error_messages =  @client.send_request(path, :get)
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Completed"
         
     | 
| 
       17 
21 
     | 
    
         
             
                    return transaction, error_messages
         
     | 
| 
       18 
22 
     | 
    
         
             
                  end
         
     | 
| 
       19 
23 
     | 
    
         | 
| 
       20 
24 
     | 
    
         
             
                  # @param [Hash] params
         
     | 
| 
       21 
25 
     | 
    
         
             
                  # @return [Array<Hash>, Array<String>]
         
     | 
| 
       22 
26 
     | 
    
         
             
                  def search(params={})
         
     | 
| 
      
 27 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Started"
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
       23 
29 
     | 
    
         
             
                    path = Defaults::END_POINTS[:transactions_list]
         
     | 
| 
       24 
30 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => path: #{path}"
         
     | 
| 
       25 
31 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
                    transactions, error_messages = @client. 
     | 
| 
      
 32 
     | 
    
         
            +
                    transactions, error_messages = @client.send_request(path, :post, params.compact)
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Completed"
         
     | 
| 
       27 
35 
     | 
    
         
             
                    return transactions, error_messages
         
     | 
| 
       28 
36 
     | 
    
         
             
                  end
         
     | 
| 
       29 
37 
     | 
    
         | 
| 
       30 
38 
     | 
    
         
             
                  # @param [Hash] params
         
     | 
| 
       31 
39 
     | 
    
         
             
                  # @return [Array<Hash>, Array<String>]
         
     | 
| 
       32 
40 
     | 
    
         
             
                  def update(params={})
         
     | 
| 
      
 41 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Started"
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
       33 
43 
     | 
    
         
             
                    path = Defaults::END_POINTS[:transactions_update]
         
     | 
| 
       34 
44 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => path: #{path}"
         
     | 
| 
       35 
45 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
                    _, error_messages = @client. 
     | 
| 
      
 46 
     | 
    
         
            +
                    _, error_messages = @client.send_request(path, :put, params.compact)
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Completed"
         
     | 
| 
       37 
49 
     | 
    
         
             
                    error_messages
         
     | 
| 
       38 
50 
     | 
    
         
             
                  end
         
     | 
| 
       39 
51 
     | 
    
         | 
| 
       40 
52 
     | 
    
         
             
                end
         
     | 
| 
       41 
53 
     | 
    
         | 
| 
       42 
54 
     | 
    
         
             
              end
         
     | 
| 
       43 
     | 
    
         
            -
            end
         
     | 
| 
      
 55 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -7,15 +7,19 @@ module FinApps 
     | 
|
| 
       7 
7 
     | 
    
         
             
                  include FinApps::REST::Defaults
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                  def list
         
     | 
| 
      
 10 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Started"
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       10 
12 
     | 
    
         
             
                    path = Defaults::END_POINTS[:user_institutions_list]
         
     | 
| 
       11 
13 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => path: #{path}"
         
     | 
| 
       12 
14 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                    user_institutions, error_messages = @client. 
     | 
| 
      
 15 
     | 
    
         
            +
                    user_institutions, error_messages = @client.send_request(path, :get)
         
     | 
| 
       14 
16 
     | 
    
         | 
| 
      
 17 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Completed"
         
     | 
| 
       15 
18 
     | 
    
         
             
                    return user_institutions, error_messages
         
     | 
| 
       16 
19 
     | 
    
         
             
                  end
         
     | 
| 
       17 
20 
     | 
    
         | 
| 
       18 
21 
     | 
    
         
             
                  def add(site_id, parameters)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Started"
         
     | 
| 
       19 
23 
     | 
    
         | 
| 
       20 
24 
     | 
    
         
             
                    raise MissingArgumentsError.new 'Missing argument: site_id.' if site_id.blank?
         
     | 
| 
       21 
25 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => site_id: #{site_id}"
         
     | 
| 
         @@ -29,12 +33,14 @@ module FinApps 
     | 
|
| 
       29 
33 
     | 
    
         
             
                    path = end_point.sub ':site_id', ERB::Util.url_encode(site_id)
         
     | 
| 
       30 
34 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => path: #{path}"
         
     | 
| 
       31 
35 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
                    user_institution, error_messages = @client. 
     | 
| 
      
 36 
     | 
    
         
            +
                    user_institution, error_messages = @client.send_request(path, :post, :parameters => parameters)
         
     | 
| 
       33 
37 
     | 
    
         | 
| 
      
 38 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Completed"
         
     | 
| 
       34 
39 
     | 
    
         
             
                    return user_institution, error_messages
         
     | 
| 
       35 
40 
     | 
    
         
             
                  end
         
     | 
| 
       36 
41 
     | 
    
         | 
| 
       37 
42 
     | 
    
         
             
                  def show(user_institution_id)
         
     | 
| 
      
 43 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Started"
         
     | 
| 
       38 
44 
     | 
    
         | 
| 
       39 
45 
     | 
    
         
             
                    raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
         
     | 
| 
       40 
46 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => user_institution_id: #{user_institution_id}"
         
     | 
| 
         @@ -45,12 +51,15 @@ module FinApps 
     | 
|
| 
       45 
51 
     | 
    
         
             
                    path = end_point.sub ':user_institution_id', ERB::Util.url_encode(user_institution_id)
         
     | 
| 
       46 
52 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => path: #{path}"
         
     | 
| 
       47 
53 
     | 
    
         | 
| 
       48 
     | 
    
         
            -
                    user_institution, error_messages = @client. 
     | 
| 
      
 54 
     | 
    
         
            +
                    user_institution, error_messages = @client.send_request(path, :get)
         
     | 
| 
       49 
55 
     | 
    
         | 
| 
      
 56 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Completed"
         
     | 
| 
       50 
57 
     | 
    
         
             
                    return user_institution, error_messages
         
     | 
| 
       51 
58 
     | 
    
         
             
                  end
         
     | 
| 
       52 
59 
     | 
    
         | 
| 
       53 
60 
     | 
    
         
             
                  def form(user_institution_id)
         
     | 
| 
      
 61 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Started"
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
       54 
63 
     | 
    
         
             
                    raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
         
     | 
| 
       55 
64 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => user_institution_id: #{user_institution_id}"
         
     | 
| 
       56 
65 
     | 
    
         | 
| 
         @@ -60,12 +69,15 @@ module FinApps 
     | 
|
| 
       60 
69 
     | 
    
         
             
                    path = end_point.sub ':user_institution_id', ERB::Util.url_encode(user_institution_id)
         
     | 
| 
       61 
70 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => path: #{path}"
         
     | 
| 
       62 
71 
     | 
    
         | 
| 
       63 
     | 
    
         
            -
                    user_institution, error_messages = @client. 
     | 
| 
      
 72 
     | 
    
         
            +
                    user_institution, error_messages = @client.send_request(path, :get)
         
     | 
| 
       64 
73 
     | 
    
         | 
| 
      
 74 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Completed"
         
     | 
| 
       65 
75 
     | 
    
         
             
                    return user_institution, error_messages
         
     | 
| 
       66 
76 
     | 
    
         
             
                  end
         
     | 
| 
       67 
77 
     | 
    
         | 
| 
       68 
78 
     | 
    
         
             
                  def status(user_institution_id)
         
     | 
| 
      
 79 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Started"
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
       69 
81 
     | 
    
         
             
                    raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
         
     | 
| 
       70 
82 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => user_institution_id: #{user_institution_id}"
         
     | 
| 
       71 
83 
     | 
    
         | 
| 
         @@ -75,12 +87,15 @@ module FinApps 
     | 
|
| 
       75 
87 
     | 
    
         
             
                    path = end_point.sub ':user_institution_id', ERB::Util.url_encode(user_institution_id)
         
     | 
| 
       76 
88 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => path: #{path}"
         
     | 
| 
       77 
89 
     | 
    
         | 
| 
       78 
     | 
    
         
            -
                    user_institution, error_messages = @client. 
     | 
| 
      
 90 
     | 
    
         
            +
                    user_institution, error_messages = @client.send_request(path, :get)
         
     | 
| 
       79 
91 
     | 
    
         | 
| 
      
 92 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Completed"
         
     | 
| 
       80 
93 
     | 
    
         
             
                    return user_institution, error_messages
         
     | 
| 
       81 
94 
     | 
    
         
             
                  end
         
     | 
| 
       82 
95 
     | 
    
         | 
| 
       83 
96 
     | 
    
         
             
                  def mfa(user_institution_id, parameters)
         
     | 
| 
      
 97 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Started"
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
       84 
99 
     | 
    
         
             
                    raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
         
     | 
| 
       85 
100 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => user_institution_id: #{user_institution_id}"
         
     | 
| 
       86 
101 
     | 
    
         | 
| 
         @@ -93,12 +108,15 @@ module FinApps 
     | 
|
| 
       93 
108 
     | 
    
         
             
                    path = end_point.sub ':user_institution_id', ERB::Util.url_encode(user_institution_id)
         
     | 
| 
       94 
109 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => path: #{path}"
         
     | 
| 
       95 
110 
     | 
    
         | 
| 
       96 
     | 
    
         
            -
                    user_institution, error_messages = @client. 
     | 
| 
      
 111 
     | 
    
         
            +
                    user_institution, error_messages = @client.send_request(path, :put, :parameters => parameters)
         
     | 
| 
       97 
112 
     | 
    
         | 
| 
      
 113 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Completed"
         
     | 
| 
       98 
114 
     | 
    
         
             
                    return user_institution, error_messages
         
     | 
| 
       99 
115 
     | 
    
         
             
                  end
         
     | 
| 
       100 
116 
     | 
    
         | 
| 
       101 
117 
     | 
    
         
             
                  def update(user_institution_id, parameters)
         
     | 
| 
      
 118 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Started"
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
       102 
120 
     | 
    
         
             
                    raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
         
     | 
| 
       103 
121 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => user_institution_id: #{user_institution_id}"
         
     | 
| 
       104 
122 
     | 
    
         | 
| 
         @@ -111,22 +129,28 @@ module FinApps 
     | 
|
| 
       111 
129 
     | 
    
         
             
                    path = end_point.sub ':user_institution_id', ERB::Util.url_encode(user_institution_id)
         
     | 
| 
       112 
130 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => path: #{path}"
         
     | 
| 
       113 
131 
     | 
    
         | 
| 
       114 
     | 
    
         
            -
                    user_institution, error_messages = @client. 
     | 
| 
      
 132 
     | 
    
         
            +
                    user_institution, error_messages = @client.send_request(path, :put, :parameters => parameters)
         
     | 
| 
       115 
133 
     | 
    
         | 
| 
      
 134 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Completed"
         
     | 
| 
       116 
135 
     | 
    
         
             
                    return user_institution, error_messages
         
     | 
| 
       117 
136 
     | 
    
         
             
                  end
         
     | 
| 
       118 
137 
     | 
    
         | 
| 
       119 
138 
     | 
    
         
             
                  def refresh
         
     | 
| 
      
 139 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Started"
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
       120 
141 
     | 
    
         
             
                    path = Defaults::END_POINTS[:user_institutions_refresh]
         
     | 
| 
       121 
142 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => path: #{path}"
         
     | 
| 
       122 
143 
     | 
    
         | 
| 
       123 
     | 
    
         
            -
                    user_institutions, error_messages = @client. 
     | 
| 
      
 144 
     | 
    
         
            +
                    user_institutions, error_messages = @client.send_request(path, :get)
         
     | 
| 
       124 
145 
     | 
    
         | 
| 
      
 146 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Completed"
         
     | 
| 
       125 
147 
     | 
    
         
             
                    return user_institutions, error_messages
         
     | 
| 
       126 
148 
     | 
    
         
             
                  end
         
     | 
| 
       127 
149 
     | 
    
         | 
| 
       128 
150 
     | 
    
         
             
                  # @return [Hash, Array<String>]
         
     | 
| 
       129 
151 
     | 
    
         
             
                  def delete(user_institution_id)
         
     | 
| 
      
 152 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Started"
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
       130 
154 
     | 
    
         
             
                    raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
         
     | 
| 
       131 
155 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => user_institution_id: #{user_institution_id.inspect}"
         
     | 
| 
       132 
156 
     | 
    
         | 
| 
         @@ -136,12 +160,13 @@ module FinApps 
     | 
|
| 
       136 
160 
     | 
    
         
             
                    path = end_point.sub ':user_institution_id', ERB::Util.url_encode(user_institution_id)
         
     | 
| 
       137 
161 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => path: #{path}"
         
     | 
| 
       138 
162 
     | 
    
         | 
| 
       139 
     | 
    
         
            -
                    _, error_messages = @client. 
     | 
| 
      
 163 
     | 
    
         
            +
                    _, error_messages = @client.send_request(path, :delete)
         
     | 
| 
       140 
164 
     | 
    
         | 
| 
      
 165 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Completed"
         
     | 
| 
       141 
166 
     | 
    
         
             
                    error_messages
         
     | 
| 
       142 
167 
     | 
    
         
             
                  end
         
     | 
| 
       143 
168 
     | 
    
         | 
| 
       144 
169 
     | 
    
         
             
                end
         
     | 
| 
       145 
170 
     | 
    
         | 
| 
       146 
171 
     | 
    
         
             
              end
         
     | 
| 
       147 
     | 
    
         
            -
            end
         
     | 
| 
      
 172 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/finapps/rest/users.rb
    CHANGED
    
    | 
         @@ -10,37 +10,44 @@ module FinApps 
     | 
|
| 
       10 
10 
     | 
    
         
             
                  # @param [Hash] params
         
     | 
| 
       11 
11 
     | 
    
         
             
                  # @return [FinApps::REST::User, Array<String>]
         
     | 
| 
       12 
12 
     | 
    
         
             
                  def create(params = {})
         
     | 
| 
      
 13 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Started"
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
       13 
15 
     | 
    
         
             
                    raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
         
     | 
| 
       14 
16 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => params: #{skip_sensitive_data params}"
         
     | 
| 
       15 
17 
     | 
    
         | 
| 
       16 
18 
     | 
    
         
             
                    end_point = Defaults::END_POINTS[:users_create]
         
     | 
| 
       17 
19 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => end_point: #{end_point}"
         
     | 
| 
       18 
20 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
                    user, error_messages = @client. 
     | 
| 
      
 21 
     | 
    
         
            +
                    user, error_messages = @client.send_request(end_point, :post, params) { |r| User.new(r.body) }
         
     | 
| 
      
 22 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Completed"
         
     | 
| 
       20 
23 
     | 
    
         | 
| 
       21 
24 
     | 
    
         
             
                    return user, error_messages
         
     | 
| 
       22 
25 
     | 
    
         
             
                  end
         
     | 
| 
       23 
26 
     | 
    
         | 
| 
       24 
27 
     | 
    
         
             
                  def update(params = {})
         
     | 
| 
       25 
     | 
    
         
            -
                     
     | 
| 
      
 28 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Started"
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
       26 
30 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => params: #{skip_sensitive_data params}"
         
     | 
| 
       27 
31 
     | 
    
         | 
| 
       28 
32 
     | 
    
         
             
                    path = Defaults::END_POINTS[:users_update]
         
     | 
| 
       29 
33 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => path: #{path}"
         
     | 
| 
       30 
34 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
                    _, error_messages = @client. 
     | 
| 
      
 35 
     | 
    
         
            +
                    _, error_messages = @client.send_request(path, :put, params.compact)
         
     | 
| 
       32 
36 
     | 
    
         | 
| 
      
 37 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Completed"
         
     | 
| 
       33 
38 
     | 
    
         
             
                    error_messages
         
     | 
| 
       34 
39 
     | 
    
         
             
                  end
         
     | 
| 
       35 
40 
     | 
    
         | 
| 
       36 
41 
     | 
    
         
             
                  def update_password(params = {})
         
     | 
| 
       37 
     | 
    
         
            -
                     
     | 
| 
      
 42 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Started"
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
       38 
44 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => params: #{skip_sensitive_data params}"
         
     | 
| 
       39 
45 
     | 
    
         | 
| 
       40 
46 
     | 
    
         
             
                    path = Defaults::END_POINTS[:users_update_password]
         
     | 
| 
       41 
47 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => path: #{path}"
         
     | 
| 
       42 
48 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
                    user, error_messages = @client. 
     | 
| 
      
 49 
     | 
    
         
            +
                    user, error_messages = @client.send_request(path, :put, params.compact) { |r| User.new(r.body) }
         
     | 
| 
      
 50 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Completed"
         
     | 
| 
       44 
51 
     | 
    
         | 
| 
       45 
52 
     | 
    
         
             
                    return user, error_messages
         
     | 
| 
       46 
53 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -48,30 +55,16 @@ module FinApps 
     | 
|
| 
       48 
55 
     | 
    
         
             
                  # @param [Hash] params
         
     | 
| 
       49 
56 
     | 
    
         
             
                  # @return [FinApps::REST::User, Array<String>]
         
     | 
| 
       50 
57 
     | 
    
         
             
                  def login(params = {})
         
     | 
| 
      
 58 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Started"
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
       51 
60 
     | 
    
         
             
                    raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
         
     | 
| 
       52 
61 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => params: #{skip_sensitive_data params}"
         
     | 
| 
       53 
62 
     | 
    
         | 
| 
       54 
63 
     | 
    
         
             
                    end_point = Defaults::END_POINTS[:users_login]
         
     | 
| 
       55 
64 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => end_point: #{end_point}"
         
     | 
| 
       56 
65 
     | 
    
         | 
| 
       57 
     | 
    
         
            -
                    user, error_messages = @client. 
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
                    return user, error_messages
         
     | 
| 
       60 
     | 
    
         
            -
                  end
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
                  # @param [String] public_id
         
     | 
| 
       63 
     | 
    
         
            -
                  # @return [FinApps::REST::User, Array<String>]
         
     | 
| 
       64 
     | 
    
         
            -
                  def show(public_id)
         
     | 
| 
       65 
     | 
    
         
            -
                    raise MissingArgumentsError.new 'Missing argument: public_id.' if public_id.blank?
         
     | 
| 
       66 
     | 
    
         
            -
                    logger.debug "##{__method__.to_s} => public_id: #{public_id}"
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                    end_point = Defaults::END_POINTS[:users_show]
         
     | 
| 
       69 
     | 
    
         
            -
                    logger.debug "##{__method__.to_s} => end_point: #{end_point}"
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
                    path = end_point.sub ':public_id', ERB::Util.url_encode(public_id)
         
     | 
| 
       72 
     | 
    
         
            -
                    logger.debug "##{__method__.to_s} => path: #{path}"
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
                    user, error_messages = @client.send(path, :get) { |r| User.new(r.body) }
         
     | 
| 
      
 66 
     | 
    
         
            +
                    user, error_messages = @client.send_request(end_point, :post, params) { |r| User.new(r.body) }
         
     | 
| 
      
 67 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Completed"
         
     | 
| 
       75 
68 
     | 
    
         | 
| 
       76 
69 
     | 
    
         
             
                    return user, error_messages
         
     | 
| 
       77 
70 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -79,6 +72,8 @@ module FinApps 
     | 
|
| 
       79 
72 
     | 
    
         
             
                  # @param [String] public_id
         
     | 
| 
       80 
73 
     | 
    
         
             
                  # @return [Array<String>]
         
     | 
| 
       81 
74 
     | 
    
         
             
                  def delete(public_id)
         
     | 
| 
      
 75 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Started"
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
       82 
77 
     | 
    
         
             
                    raise MissingArgumentsError.new 'Missing argument: public_id.' if public_id.blank?
         
     | 
| 
       83 
78 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => public_id: #{public_id}"
         
     | 
| 
       84 
79 
     | 
    
         | 
| 
         @@ -88,7 +83,8 @@ module FinApps 
     | 
|
| 
       88 
83 
     | 
    
         
             
                    path = end_point.sub ':public_id', ERB::Util.url_encode(public_id)
         
     | 
| 
       89 
84 
     | 
    
         
             
                    logger.debug "##{__method__.to_s} => path: #{path}"
         
     | 
| 
       90 
85 
     | 
    
         | 
| 
       91 
     | 
    
         
            -
                    _, error_messages = @client. 
     | 
| 
      
 86 
     | 
    
         
            +
                    _, error_messages = @client.send_request(path, :delete)
         
     | 
| 
      
 87 
     | 
    
         
            +
                    logger.debug "##{__method__.to_s} => Completed"
         
     | 
| 
       92 
88 
     | 
    
         | 
| 
       93 
89 
     | 
    
         
             
                    error_messages
         
     | 
| 
       94 
90 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -2,14 +2,14 @@ module FinApps 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module Logging
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
                SEVERITY_LABEL = %w(DEBUG INFO WARN ERROR FATAL UNKNOWN)
         
     | 
| 
       5 
     | 
    
         
            -
                PROTECTED_KEYS = %w(login password password_confirm  
     | 
| 
      
 5 
     | 
    
         
            +
                PROTECTED_KEYS = %w(login login1 password password1 password_confirm token)
         
     | 
| 
       6 
6 
     | 
    
         
             
                FORMAT = "\033[%sm[%s#%d] %5s -- %s: %s\033[0m\n"
         
     | 
| 
       7 
7 
     | 
    
         
             
                FORMAT_TAG = "\033[%sm[%s#%d] %5s -- %s: %s %s\033[0m\n"
         
     | 
| 
       8 
8 
     | 
    
         
             
                SEVERITY_COLOR_MAP = {:debug => '0', :info => '32', :warn => '33', :error => '31', :fatal => '31', :unknown => '0;37'}
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
                class << self;
         
     | 
| 
       12 
     | 
    
         
            -
                  attr_accessor :tag;
         
     | 
| 
      
 12 
     | 
    
         
            +
                  attr_accessor :tag, :level;
         
     | 
| 
       13 
13 
     | 
    
         
             
                end
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                def logger=(logger)
         
     | 
| 
         @@ -23,21 +23,21 @@ module FinApps 
     | 
|
| 
       23 
23 
     | 
    
         
             
                    require 'logger' unless defined?(::Logger)
         
     | 
| 
       24 
24 
     | 
    
         
             
                    ::Logger.new(STDOUT).tap do |log|
         
     | 
| 
       25 
25 
     | 
    
         
             
                      log.progname = "#{self.class.to_s}"
         
     | 
| 
      
 26 
     | 
    
         
            +
                      log.level = Logging.level if Logging.level.present?
         
     | 
| 
       26 
27 
     | 
    
         
             
                      log.formatter = proc do |severity, time, progname, msg|
         
     | 
| 
       27 
28 
     | 
    
         
             
                        Logging.tag.present? ?
         
     | 
| 
       28 
29 
     | 
    
         
             
                            FORMAT_TAG % [severity_to_color(severity), format_datetime(time), $$, severity, progname, Logging.tag.to_s, msg2str(msg)] :
         
     | 
| 
       29 
30 
     | 
    
         
             
                            FORMAT % [severity_to_color(severity), format_datetime(time), $$, severity, progname, msg2str(msg)]
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
       30 
32 
     | 
    
         
             
                      end
         
     | 
| 
       31 
33 
     | 
    
         
             
                    end
         
     | 
| 
       32 
34 
     | 
    
         
             
                  end
         
     | 
| 
       33 
35 
     | 
    
         | 
| 
       34 
36 
     | 
    
         
             
                end
         
     | 
| 
       35 
37 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
                def  
     | 
| 
       37 
     | 
    
         
            -
                   
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                    logger.level = logger_level
         
     | 
| 
       40 
     | 
    
         
            -
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
                def logger_config(config)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  Logging.tag= config[:logger_tag] if config[:logger_tag].present?
         
     | 
| 
      
 40 
     | 
    
         
            +
                  Logging.level = config[:log_level] if config[:log_level].present?
         
     | 
| 
       41 
41 
     | 
    
         
             
                end
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
       43 
43 
     | 
    
         
             
                # noinspection SpellCheckingInspection
         
     | 
    
        data/lib/finapps/version.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            RSpec.describe FinApps::Middleware::ApiToken do
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              describe '#call' do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                fake_app = Proc.new { |env| env }
         
     | 
| 
      
 6 
     | 
    
         
            +
                valid_credentials = {:company_identifier => 'id', :company_token => 'token'}
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                context 'when company_identifier is NOT provided' do
         
     | 
| 
      
 9 
     | 
    
         
            +
                  let(:api_token) { FinApps::Middleware::ApiToken.new fake_app, valid_credentials.select { |x| x!= :company_identifier } }
         
     | 
| 
      
 10 
     | 
    
         
            +
                  it { expect { api_token.call({}) }.to raise_error(FinApps::REST::MissingArgumentsError) }
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                context 'when company_token is NOT provided' do
         
     | 
| 
      
 14 
     | 
    
         
            +
                  let(:api_token) { FinApps::Middleware::ApiToken.new fake_app, valid_credentials.select { |x| x!= :company_token } }
         
     | 
| 
      
 15 
     | 
    
         
            +
                  it { expect { api_token.call({}) }.to raise_error(FinApps::REST::MissingArgumentsError) }
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                context 'when company credentials were provided' do
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  let(:api_token) { FinApps::Middleware::ApiToken.new fake_app, valid_credentials }
         
     | 
| 
      
 21 
     | 
    
         
            +
                  let(:expected_header_value) { "#{valid_credentials[:company_identifier]}=#{valid_credentials[:company_token]}" }
         
     | 
| 
      
 22 
     | 
    
         
            +
                  subject(:call) { api_token.call({:request_headers => {}}) }
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  it { expect { call }.not_to raise_error }
         
     | 
| 
      
 25 
     | 
    
         
            +
                  it 'should generate the X-FinApps-Token header' do
         
     | 
| 
      
 26 
     | 
    
         
            +
                    expect(call[:request_headers]['X-FinApps-Token']).to eq(expected_header_value)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
    
        data/spec/rest/client_spec.rb
    CHANGED
    
    | 
         @@ -1,91 +1,123 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
            require 'finapps'
         
     | 
| 
      
 1 
     | 
    
         
            +
            RSpec.describe FinApps::REST::Client do
         
     | 
| 
       3 
2 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
              describe '#new' do
         
     | 
| 
       5 
4 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
                context 'when company_identifier is NOT provided' do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  it { expect { FinApps::REST::Client.new nil, :company_token }.to raise_error(FinApps::REST::MissingArgumentsError) }
         
     | 
| 
      
 7 
     | 
    
         
            +
                end
         
     | 
| 
       7 
8 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                 
     | 
| 
       9 
     | 
    
         
            -
                   
     | 
| 
      
 9 
     | 
    
         
            +
                context 'when company_token is NOT provided' do
         
     | 
| 
      
 10 
     | 
    
         
            +
                  it { expect { FinApps::REST::Client.new :company_identifier, nil }.to raise_error(FinApps::REST::MissingArgumentsError) }
         
     | 
| 
       10 
11 
     | 
    
         
             
                end
         
     | 
| 
       11 
12 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
                 
     | 
| 
       13 
     | 
    
         
            -
                  expect 
     | 
| 
      
 13 
     | 
    
         
            +
                context 'when company_identifier is not string or symbol' do
         
     | 
| 
      
 14 
     | 
    
         
            +
                  it { expect { FinApps::REST::Client.new 1, :company_token }.to raise_error(FinApps::REST::InvalidArgumentsError) }
         
     | 
| 
       14 
15 
     | 
    
         
             
                end
         
     | 
| 
       15 
16 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
                 
     | 
| 
       17 
     | 
    
         
            -
                  expect 
     | 
| 
      
 17 
     | 
    
         
            +
                context 'when company_token is not string or symbol' do
         
     | 
| 
      
 18 
     | 
    
         
            +
                  it { expect { FinApps::REST::Client.new :company_identifier, 1 }.to raise_error(FinApps::REST::InvalidArgumentsError) }
         
     | 
| 
       18 
19 
     | 
    
         
             
                end
         
     | 
| 
       19 
20 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
                 
     | 
| 
       21 
     | 
    
         
            -
                   
     | 
| 
       22 
     | 
    
         
            -
                   :budgets, :budget_calculation, :budget_models, :cashflows,
         
     | 
| 
       23 
     | 
    
         
            -
                   :categories, :institutions, :transactions,
         
     | 
| 
       24 
     | 
    
         
            -
                   :user_institutions, :users,
         
     | 
| 
       25 
     | 
    
         
            -
                   :rule_sets].each do |method|
         
     | 
| 
       26 
     | 
    
         
            -
                    expect(@client).to respond_to(method)
         
     | 
| 
       27 
     | 
    
         
            -
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
                context 'when options are not provided' do
         
     | 
| 
      
 22 
     | 
    
         
            +
                  it { expect { FinApps::REST::Client.new :company_identifier, :company_token }.not_to raise_error }
         
     | 
| 
       28 
23 
     | 
    
         
             
                end
         
     | 
| 
       29 
24 
     | 
    
         | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                  context 'when company credentials are NOT provided' do
         
     | 
| 
       32 
     | 
    
         
            -
                    it 'should raise a MissingArgumentsError exception' do
         
     | 
| 
       33 
     | 
    
         
            -
                      expect { FinApps::REST::Client.new nil, nil }.to raise_error(FinApps::REST::MissingArgumentsError)
         
     | 
| 
       34 
     | 
    
         
            -
                    end
         
     | 
| 
       35 
     | 
    
         
            -
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
       36 
26 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                    it 'should raise an InvalidArgumentsError exception' do
         
     | 
| 
       39 
     | 
    
         
            -
                      expect { FinApps::REST::Client.new 1, 2 }.to raise_error(FinApps::REST::InvalidArgumentsError)
         
     | 
| 
       40 
     | 
    
         
            -
                    end
         
     | 
| 
       41 
     | 
    
         
            -
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
              context 'after initialized' do
         
     | 
| 
       42 
28 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
      
 29 
     | 
    
         
            +
                let(:client) { FinApps::REST::Client.new(:company_identifier, :company_token) }
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                [:send_request, :connection, :users, :institutions, :user_institutions, :transactions,
         
     | 
| 
      
 32 
     | 
    
         
            +
                 :categories, :budget_models, :budget_calculation, :budgets, :cashflows, :alert,
         
     | 
| 
      
 33 
     | 
    
         
            +
                 :alert_definition, :alert_preferences, :alert_settings, :rule_sets, :user_credentials!].each do |method|
         
     | 
| 
      
 34 
     | 
    
         
            +
                  it "responds to #{method}" do
         
     | 
| 
      
 35 
     | 
    
         
            +
                    expect(client).to respond_to(method)
         
     | 
| 
       47 
36 
     | 
    
         
             
                  end
         
     | 
| 
       48 
37 
     | 
    
         
             
                end
         
     | 
| 
       49 
38 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
                describe ' 
     | 
| 
       51 
     | 
    
         
            -
                  it  
     | 
| 
       52 
     | 
    
         
            -
                    expect(@client.users).to be_an_instance_of(FinApps::REST::Users)
         
     | 
| 
       53 
     | 
    
         
            -
                  end
         
     | 
| 
      
 39 
     | 
    
         
            +
                describe '#users' do
         
     | 
| 
      
 40 
     | 
    
         
            +
                  it { expect(client.users).to be_an_instance_of(FinApps::REST::Users) }
         
     | 
| 
       54 
41 
     | 
    
         
             
                end
         
     | 
| 
       55 
42 
     | 
    
         | 
| 
       56 
     | 
    
         
            -
                describe ' 
     | 
| 
       57 
     | 
    
         
            -
                  it  
     | 
| 
       58 
     | 
    
         
            -
                    expect(@client.users).to be_an_instance_of(FinApps::REST::Users)
         
     | 
| 
       59 
     | 
    
         
            -
                  end
         
     | 
| 
      
 43 
     | 
    
         
            +
                describe '#institutions' do
         
     | 
| 
      
 44 
     | 
    
         
            +
                  it { expect(client.institutions).to be_an_instance_of(FinApps::REST::Institutions) }
         
     | 
| 
       60 
45 
     | 
    
         
             
                end
         
     | 
| 
       61 
46 
     | 
    
         | 
| 
       62 
     | 
    
         
            -
                describe ' 
     | 
| 
       63 
     | 
    
         
            -
                  it  
     | 
| 
       64 
     | 
    
         
            -
                    expect(@client.institutions).to be_an_instance_of(FinApps::REST::Institutions)
         
     | 
| 
       65 
     | 
    
         
            -
                  end
         
     | 
| 
      
 47 
     | 
    
         
            +
                describe '#user_institutions' do
         
     | 
| 
      
 48 
     | 
    
         
            +
                  it { expect(client.user_institutions).to be_an_instance_of(FinApps::REST::UserInstitutions) }
         
     | 
| 
       66 
49 
     | 
    
         
             
                end
         
     | 
| 
       67 
50 
     | 
    
         | 
| 
       68 
     | 
    
         
            -
                describe ' 
     | 
| 
       69 
     | 
    
         
            -
                  it  
     | 
| 
       70 
     | 
    
         
            -
                    expect(@client.user_institutions).to be_an_instance_of(FinApps::REST::UserInstitutions)
         
     | 
| 
       71 
     | 
    
         
            -
                  end
         
     | 
| 
      
 51 
     | 
    
         
            +
                describe '#categories' do
         
     | 
| 
      
 52 
     | 
    
         
            +
                  it { expect(client.categories).to be_an_instance_of(FinApps::REST::Categories) }
         
     | 
| 
       72 
53 
     | 
    
         
             
                end
         
     | 
| 
       73 
54 
     | 
    
         | 
| 
       74 
     | 
    
         
            -
                describe ' 
     | 
| 
       75 
     | 
    
         
            -
                  it  
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
      
 55 
     | 
    
         
            +
                describe '#budget_models' do
         
     | 
| 
      
 56 
     | 
    
         
            +
                  it { expect(client.budget_models).to be_an_instance_of(FinApps::REST::BudgetModels) }
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                describe '#budget_calculation' do
         
     | 
| 
      
 60 
     | 
    
         
            +
                  it { expect(client.budget_calculation).to be_an_instance_of(FinApps::REST::BudgetCalculation) }
         
     | 
| 
      
 61 
     | 
    
         
            +
                end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                describe '#budgets' do
         
     | 
| 
      
 64 
     | 
    
         
            +
                  it { expect(client.budgets).to be_an_instance_of(FinApps::REST::Budgets) }
         
     | 
| 
      
 65 
     | 
    
         
            +
                end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                describe '#cashflows' do
         
     | 
| 
      
 68 
     | 
    
         
            +
                  it { expect(client.cashflows).to be_an_instance_of(FinApps::REST::Cashflows) }
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                describe '#alert' do
         
     | 
| 
      
 72 
     | 
    
         
            +
                  it { expect(client.alert).to be_an_instance_of(FinApps::REST::Alert) }
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                describe '#alert_definition' do
         
     | 
| 
      
 76 
     | 
    
         
            +
                  it { expect(client.alert_definition).to be_an_instance_of(FinApps::REST::AlertDefinition) }
         
     | 
| 
      
 77 
     | 
    
         
            +
                end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                describe '#alert_preferences' do
         
     | 
| 
      
 80 
     | 
    
         
            +
                  it { expect(client.alert_preferences).to be_an_instance_of(FinApps::REST::AlertPreferences) }
         
     | 
| 
      
 81 
     | 
    
         
            +
                end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                describe '#alert_settings' do
         
     | 
| 
      
 84 
     | 
    
         
            +
                  it { expect(client.alert_settings).to be_an_instance_of(FinApps::REST::AlertSettings) }
         
     | 
| 
      
 85 
     | 
    
         
            +
                end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                describe '#rule_sets' do
         
     | 
| 
      
 88 
     | 
    
         
            +
                  it { expect(client.rule_sets).to be_an_instance_of(FinApps::REST::Relevance::Rulesets) }
         
     | 
| 
       78 
89 
     | 
    
         
             
                end
         
     | 
| 
       79 
90 
     | 
    
         | 
| 
       80 
91 
     | 
    
         
             
                describe '#connection' do
         
     | 
| 
       81 
     | 
    
         
            -
                  it  
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
      
 92 
     | 
    
         
            +
                  it { expect(client.connection).to be_an_instance_of(Faraday::Connection) }
         
     | 
| 
      
 93 
     | 
    
         
            +
                end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
                [:connection, :users, :institutions, :user_institutions, :transactions,
         
     | 
| 
      
 96 
     | 
    
         
            +
                 :categories, :budget_models, :budget_calculation, :budgets, :cashflows, :alert,
         
     | 
| 
      
 97 
     | 
    
         
            +
                 :alert_definition, :alert_preferences, :alert_settings, :rule_sets].each do |method|
         
     | 
| 
      
 98 
     | 
    
         
            +
                  it "memoizes the result of #{method}" do
         
     | 
| 
      
 99 
     | 
    
         
            +
                    first, second = client.send(method), client.send(method)
         
     | 
| 
      
 100 
     | 
    
         
            +
                    expect(first.object_id).to eq(second.object_id)
         
     | 
| 
       83 
101 
     | 
    
         
             
                  end
         
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
      
 102 
     | 
    
         
            +
                end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                describe '#send_request' do
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                  context 'when path is NOT provided' do
         
     | 
| 
      
 107 
     | 
    
         
            +
                    it { expect { client.send_request(nil, :post) }.to raise_error(FinApps::REST::MissingArgumentsError) }
         
     | 
| 
       87 
108 
     | 
    
         
             
                  end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                  context 'when method is NOT provided' do
         
     | 
| 
      
 111 
     | 
    
         
            +
                    it { expect { client.send_request(:path, nil) }.to raise_error(FinApps::REST::MissingArgumentsError) }
         
     | 
| 
      
 112 
     | 
    
         
            +
                  end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                  context 'when method is NOT supported' do
         
     | 
| 
      
 115 
     | 
    
         
            +
                    it { expect { client.send_request(:path, :unsupported_method) }.to raise_error(FinApps::REST::InvalidArgumentsError) }
         
     | 
| 
      
 116 
     | 
    
         
            +
                  end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
       88 
118 
     | 
    
         
             
                end
         
     | 
| 
       89 
119 
     | 
    
         | 
| 
       90 
120 
     | 
    
         
             
              end
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
            end
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     |