Class: FireflyIIIClient::RulesApi

Inherits:
Object
  • Object
show all
Defined in:
lib/firefly_iii_client/api/rules_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ RulesApi

Returns a new instance of RulesApi.



19
20
21
# File 'lib/firefly_iii_client/api/rules_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/firefly_iii_client/api/rules_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#delete_rule(id, opts = {}) ⇒ nil

Delete an rule. Delete an rule.

Parameters:

  • id (Integer)

    The ID of the rule.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


27
28
29
30
# File 'lib/firefly_iii_client/api/rules_api.rb', line 27

def delete_rule(id, opts = {})
  delete_rule_with_http_info(id, opts)
  nil
end

#delete_rule_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete an rule. Delete an rule.

Parameters:

  • id (Integer)

    The ID of the rule.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/firefly_iii_client/api/rules_api.rb', line 37

def delete_rule_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RulesApi.delete_rule ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling RulesApi.delete_rule"
  end
  # resource path
  local_var_path = '/api/v1/rules/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['firefly_iii_auth']

  new_options = opts.merge(
    :operation => :"RulesApi.delete_rule",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RulesApi#delete_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#fire_rule(id, opts = {}) ⇒ nil

Fire the rule on your transactions. Fire the rule group on your transactions. Changes will be made by the rules in the group! Limit the result if you want to.

Parameters:

  • id (Integer)

    The ID of the rule.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :start (Date)

    A date formatted YYYY-MM-DD, to limit the transactions the actions will be applied to. Both the start date and the end date must be present.

  • :_end (Date)

    A date formatted YYYY-MM-DD, to limit the transactions the actions will be applied to. Both the start date and the end date must be present.

  • :accounts (String)

    Limit the testing of the rule to these asset accounts. Only asset accounts will be accepted. Other types will be silently dropped.

Returns:

  • (nil)


91
92
93
94
# File 'lib/firefly_iii_client/api/rules_api.rb', line 91

def fire_rule(id, opts = {})
  fire_rule_with_http_info(id, opts)
  nil
end

#fire_rule_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Fire the rule on your transactions. Fire the rule group on your transactions. Changes will be made by the rules in the group! Limit the result if you want to.

Parameters:

  • id (Integer)

    The ID of the rule.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :start (Date)

    A date formatted YYYY-MM-DD, to limit the transactions the actions will be applied to. Both the start date and the end date must be present.

  • :_end (Date)

    A date formatted YYYY-MM-DD, to limit the transactions the actions will be applied to. Both the start date and the end date must be present.

  • :accounts (String)

    Limit the testing of the rule to these asset accounts. Only asset accounts will be accepted. Other types will be silently dropped.

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/firefly_iii_client/api/rules_api.rb', line 104

def fire_rule_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RulesApi.fire_rule ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling RulesApi.fire_rule"
  end
  # resource path
  local_var_path = '/api/v1/rules/{id}/trigger'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start'] = opts[:'start'] if !opts[:'start'].nil?
  query_params[:'end'] = opts[:'_end'] if !opts[:'_end'].nil?
  query_params[:'accounts'] = opts[:'accounts'] if !opts[:'accounts'].nil?

  # header parameters
  header_params = opts[:header_params] || {}

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['firefly_iii_auth']

  new_options = opts.merge(
    :operation => :"RulesApi.fire_rule",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RulesApi#fire_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_rule(id, opts = {}) ⇒ RuleSingle

Get a single rule. Get a single rule.

Parameters:

  • id (Integer)

    The ID of the object.X

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



158
159
160
161
# File 'lib/firefly_iii_client/api/rules_api.rb', line 158

def get_rule(id, opts = {})
  data, _status_code, _headers = get_rule_with_http_info(id, opts)
  data
end

#get_rule_with_http_info(id, opts = {}) ⇒ Array<(RuleSingle, Integer, Hash)>

Get a single rule. Get a single rule.

Parameters:

  • id (Integer)

    The ID of the object.X

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(RuleSingle, Integer, Hash)>)

    RuleSingle data, response status code and response headers



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/firefly_iii_client/api/rules_api.rb', line 168

def get_rule_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RulesApi.get_rule ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling RulesApi.get_rule"
  end
  # resource path
  local_var_path = '/api/v1/rules/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'RuleSingle'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['firefly_iii_auth']

  new_options = opts.merge(
    :operation => :"RulesApi.get_rule",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RulesApi#get_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_rule(opts = {}) ⇒ RuleArray

List all rules. List all rules.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Page number. The default pagination is 50.

Returns:



221
222
223
224
# File 'lib/firefly_iii_client/api/rules_api.rb', line 221

def list_rule(opts = {})
  data, _status_code, _headers = list_rule_with_http_info(opts)
  data
end

#list_rule_with_http_info(opts = {}) ⇒ Array<(RuleArray, Integer, Hash)>

List all rules. List all rules.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Page number. The default pagination is 50.

Returns:

  • (Array<(RuleArray, Integer, Hash)>)

    RuleArray data, response status code and response headers



231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/firefly_iii_client/api/rules_api.rb', line 231

def list_rule_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RulesApi.list_rule ...'
  end
  # resource path
  local_var_path = '/api/v1/rules'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'RuleArray'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['firefly_iii_auth']

  new_options = opts.merge(
    :operation => :"RulesApi.list_rule",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RulesApi#list_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#store_rule(rule, opts = {}) ⇒ RuleSingle

Store a new rule Creates a new rule. The data required can be submitted as a JSON body or as a list of parameters.

Parameters:

  • rule (Rule)

    JSON array or key&#x3D;value pairs with the necessary rule information. See the model for the exact specifications.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



281
282
283
284
# File 'lib/firefly_iii_client/api/rules_api.rb', line 281

def store_rule(rule, opts = {})
  data, _status_code, _headers = store_rule_with_http_info(rule, opts)
  data
end

#store_rule_with_http_info(rule, opts = {}) ⇒ Array<(RuleSingle, Integer, Hash)>

Store a new rule Creates a new rule. The data required can be submitted as a JSON body or as a list of parameters.

Parameters:

  • rule (Rule)

    JSON array or key&#x3D;value pairs with the necessary rule information. See the model for the exact specifications.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(RuleSingle, Integer, Hash)>)

    RuleSingle data, response status code and response headers



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/firefly_iii_client/api/rules_api.rb', line 291

def store_rule_with_http_info(rule, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RulesApi.store_rule ...'
  end
  # verify the required parameter 'rule' is set
  if @api_client.config.client_side_validation && rule.nil?
    fail ArgumentError, "Missing the required parameter 'rule' when calling RulesApi.store_rule"
  end
  # resource path
  local_var_path = '/api/v1/rules'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/x-www-form-urlencoded'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(rule)

  # return_type
  return_type = opts[:debug_return_type] || 'RuleSingle'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['firefly_iii_auth']

  new_options = opts.merge(
    :operation => :"RulesApi.store_rule",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RulesApi#store_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#test_rule(id, opts = {}) ⇒ TransactionArray

Test which transactions would be hit by the rule. No changes will be made. Test which transactions would be hit by the rule. No changes will be made. Limit the result if you want to.

Parameters:

  • id (Integer)

    The ID of the rule.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Page number. The default pagination is 50 items.

  • :start (Date)

    A date formatted YYYY-MM-DD, to limit the transactions the test will be applied to. Both the start date and the end date must be present.

  • :_end (Date)

    A date formatted YYYY-MM-DD, to limit the transactions the test will be applied to. Both the start date and the end date must be present.

  • :search_limit (Integer)

    Maximum number of transactions Firefly III will try. Don&#39;t set this too high, or it will take Firefly III very long to run the test. I suggest a max of 200.

  • :triggered_limit (Integer)

    Maximum number of transactions the rule can actually trigger on, before Firefly III stops. I would suggest setting this to 10 or 15. Don&#39;t go above the user&#39;s page size, because browsing to page 2 or 3 of a test result would fire the test again, making any navigation efforts very slow.

  • :accounts (String)

    Limit the testing of the rule to these asset accounts. Only asset accounts will be accepted. Other types will be silently dropped.

Returns:



352
353
354
355
# File 'lib/firefly_iii_client/api/rules_api.rb', line 352

def test_rule(id, opts = {})
  data, _status_code, _headers = test_rule_with_http_info(id, opts)
  data
end

#test_rule_with_http_info(id, opts = {}) ⇒ Array<(TransactionArray, Integer, Hash)>

Test which transactions would be hit by the rule. No changes will be made. Test which transactions would be hit by the rule. No changes will be made. Limit the result if you want to.

Parameters:

  • id (Integer)

    The ID of the rule.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Page number. The default pagination is 50 items.

  • :start (Date)

    A date formatted YYYY-MM-DD, to limit the transactions the test will be applied to. Both the start date and the end date must be present.

  • :_end (Date)

    A date formatted YYYY-MM-DD, to limit the transactions the test will be applied to. Both the start date and the end date must be present.

  • :search_limit (Integer)

    Maximum number of transactions Firefly III will try. Don&#39;t set this too high, or it will take Firefly III very long to run the test. I suggest a max of 200.

  • :triggered_limit (Integer)

    Maximum number of transactions the rule can actually trigger on, before Firefly III stops. I would suggest setting this to 10 or 15. Don&#39;t go above the user&#39;s page size, because browsing to page 2 or 3 of a test result would fire the test again, making any navigation efforts very slow.

  • :accounts (String)

    Limit the testing of the rule to these asset accounts. Only asset accounts will be accepted. Other types will be silently dropped.

Returns:

  • (Array<(TransactionArray, Integer, Hash)>)

    TransactionArray data, response status code and response headers



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/firefly_iii_client/api/rules_api.rb', line 368

def test_rule_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RulesApi.test_rule ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling RulesApi.test_rule"
  end
  # resource path
  local_var_path = '/api/v1/rules/{id}/test'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'start'] = opts[:'start'] if !opts[:'start'].nil?
  query_params[:'end'] = opts[:'_end'] if !opts[:'_end'].nil?
  query_params[:'search_limit'] = opts[:'search_limit'] if !opts[:'search_limit'].nil?
  query_params[:'triggered_limit'] = opts[:'triggered_limit'] if !opts[:'triggered_limit'].nil?
  query_params[:'accounts'] = opts[:'accounts'] if !opts[:'accounts'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'TransactionArray'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['firefly_iii_auth']

  new_options = opts.merge(
    :operation => :"RulesApi.test_rule",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RulesApi#test_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_rule(id, rule, opts = {}) ⇒ RuleSingle

Update existing rule. Update existing rule.

Parameters:

  • id (Integer)

    The ID of the object.X

  • rule (Rule)

    JSON array with updated rule information. See the model for the exact specifications.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



428
429
430
431
# File 'lib/firefly_iii_client/api/rules_api.rb', line 428

def update_rule(id, rule, opts = {})
  data, _status_code, _headers = update_rule_with_http_info(id, rule, opts)
  data
end

#update_rule_with_http_info(id, rule, opts = {}) ⇒ Array<(RuleSingle, Integer, Hash)>

Update existing rule. Update existing rule.

Parameters:

  • id (Integer)

    The ID of the object.X

  • rule (Rule)

    JSON array with updated rule information. See the model for the exact specifications.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(RuleSingle, Integer, Hash)>)

    RuleSingle data, response status code and response headers



439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
# File 'lib/firefly_iii_client/api/rules_api.rb', line 439

def update_rule_with_http_info(id, rule, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RulesApi.update_rule ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling RulesApi.update_rule"
  end
  # verify the required parameter 'rule' is set
  if @api_client.config.client_side_validation && rule.nil?
    fail ArgumentError, "Missing the required parameter 'rule' when calling RulesApi.update_rule"
  end
  # resource path
  local_var_path = '/api/v1/rules/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/x-www-form-urlencoded'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(rule)

  # return_type
  return_type = opts[:debug_return_type] || 'RuleSingle'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['firefly_iii_auth']

  new_options = opts.merge(
    :operation => :"RulesApi.update_rule",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RulesApi#update_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end