myfinance 1.4.1 → 1.5.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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -1
  3. data/Gemfile.lock +2 -2
  4. data/README.md +131 -0
  5. data/lib/myfinance/client.rb +8 -0
  6. data/lib/myfinance/entities/credit_card.rb +1 -0
  7. data/lib/myfinance/entities/credit_card_transaction.rb +1 -0
  8. data/lib/myfinance/entities/custom_classifier.rb +11 -0
  9. data/lib/myfinance/entities/custom_classifier_collection.rb +16 -0
  10. data/lib/myfinance/entities/custom_classifier_value.rb +11 -0
  11. data/lib/myfinance/entities/custom_classifier_value_collection.rb +16 -0
  12. data/lib/myfinance/entities/financial_account.rb +1 -0
  13. data/lib/myfinance/entities/financial_transaction.rb +1 -0
  14. data/lib/myfinance/entities/sale.rb +0 -1
  15. data/lib/myfinance/resources/custom_classifier.rb +83 -0
  16. data/lib/myfinance/resources/custom_classifier_value.rb +92 -0
  17. data/lib/myfinance/version.rb +1 -1
  18. data/spec/lib/myfinance/client_spec.rb +16 -113
  19. data/spec/lib/myfinance/entities/account_collection_spec.rb +1 -15
  20. data/spec/lib/myfinance/entities/attachment_collection_spec.rb +1 -16
  21. data/spec/lib/myfinance/entities/category_collection_spec.rb +1 -43
  22. data/spec/lib/myfinance/entities/classification_center_collection_spec.rb +1 -19
  23. data/spec/lib/myfinance/entities/credit_card_collection_spec.rb +1 -19
  24. data/spec/lib/myfinance/entities/credit_card_spec.rb +3 -3
  25. data/spec/lib/myfinance/entities/credit_card_transaction_collection_spec.rb +1 -17
  26. data/spec/lib/myfinance/entities/credit_card_transaction_spec.rb +5 -4
  27. data/spec/lib/myfinance/entities/custom_classifier_collection_spec.rb +5 -0
  28. data/spec/lib/myfinance/entities/custom_classifier_spec.rb +7 -0
  29. data/spec/lib/myfinance/entities/custom_classifier_value_collection_spec.rb +5 -0
  30. data/spec/lib/myfinance/entities/custom_classifier_value_spec.rb +7 -0
  31. data/spec/lib/myfinance/entities/deposit_account_collection_spec.rb +1 -19
  32. data/spec/lib/myfinance/entities/financial_transaction_collection_spec.rb +1 -19
  33. data/spec/lib/myfinance/entities/financial_transaction_spec.rb +8 -8
  34. data/spec/lib/myfinance/entities/payable_account_spec.rb +7 -7
  35. data/spec/lib/myfinance/entities/person_collection_spec.rb +1 -22
  36. data/spec/lib/myfinance/entities/receivable_account_spec.rb +7 -7
  37. data/spec/lib/myfinance/entities/reconcile_collection_spec.rb +1 -3
  38. data/spec/lib/myfinance/entities/tax_collection_spec.rb +1 -19
  39. data/spec/lib/myfinance/entities/webhook_collection_spec.rb +1 -44
  40. data/spec/lib/myfinance/resources/custom_classifier_spec.rb +90 -0
  41. data/spec/lib/myfinance/resources/custom_classifier_value_spec.rb +111 -0
  42. data/spec/lib/myfinance_spec.rb +14 -5
  43. metadata +20 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec920463cf5999546a46af9d396ecf921a6ff371
4
- data.tar.gz: a1ab1557e5e85a10689c011fd349ea1993448d3b
3
+ metadata.gz: 589e8dda000cd743433879d1fc4d1055347b167c
4
+ data.tar.gz: 157ffd66f873d623ebcc00a20124272c0b191d43
5
5
  SHA512:
6
- metadata.gz: 5017df20951a4193830850c3a87b04f3fba16bd3599f2e9dd1c3797bf4bd5d54e81f50b1281d71760f93bee217ebe3d8de8bb3a0eef81b4274c068d0d8eea30d
7
- data.tar.gz: 97223a355291502fae10e73cf81fb60f3b7996c27ba90f417686aed704b016a6111d77259943b8d634050bc4506964075c22db79e81db4697ba36ea471385b83
6
+ metadata.gz: 2bec2de68fc39a90ac6e916db7e2b4ee2eab79e062de0ed7a3c2d25a3196fdc623c8f4bc4aa4698dc9765ef2b5d157a00a980d1e52f6cc35d284661f72da9bb5
7
+ data.tar.gz: 3abcdac4f99c38b63a4cd596ff7e5b6c7f3035d84ed0e90067efaac355ccc5eb380f32106165da7481661025f95aa9cb0cb6037d9054fe6792f6f50fea58286f
data/CHANGELOG.md CHANGED
@@ -1,7 +1,13 @@
1
1
  # Changelog
2
+ ## v1.5.0
3
+ ### New Endpoints
4
+ - Add endpoints for `CustomClassifier` and `CustomClassifierValue`
5
+ ### New Attributes
6
+ - `CreditCard`, `CreditCardTransaction`, `FinancialAccount`, `FinancialTransaction`, `Sale` and `SaleAccount`
7
+ now respond_to `custom_classifications`
2
8
  ## v1.4.1
3
9
  - In v1.4.0 we broke the API by renaming `financial_account_taxes_attributes` to `tax_charges_attributes`.
4
- We add `financial_account_taxes_attributes` back. Both can be used for the same purpose.
10
+ We added `financial_account_taxes_attributes` back. Both can be used for the same purpose.
5
11
  - We also renamed `tax_charges_attributes` to `tax_charges` as an effort to move away from the `_attributes` suffix.
6
12
  ## v1.4.0
7
13
  ### New attributes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- myfinance (1.4.1)
4
+ myfinance (1.5.0)
5
5
  mime-types (~> 2.99)
6
6
  multi_json (~> 1.11)
7
7
  require_all (~> 1.4.0)
@@ -97,4 +97,4 @@ DEPENDENCIES
97
97
  webmock (~> 1.9.3)
98
98
 
99
99
  BUNDLED WITH
100
- 1.15.1
100
+ 1.15.2
data/README.md CHANGED
@@ -67,6 +67,8 @@ client = Myfinance.client("YOUR_TOKEN_HERE")
67
67
  * [Sales API](https://app.myfinance.com.br/docs/api/sales) as `client.sales`
68
68
  * [SaleAccounts API](https://app.myfinance.com.br/docs/api/sale_accounts) as `client.sale_accounts`
69
69
  * [SaleRules API](https://app.myfinance.com.br/docs/api/sale_rules) as `client.sale_rules`
70
+ * [CustomClassifiers API](https://app.myfinance.com.br/docs/api/custom_classifiers) as `client.custom_classifiers`
71
+ * [CustomClassifierValues API](https://app.myfinance.com.br/docs/api/custom_classifier_values) as `client.custom_classifier_values`
70
72
 
71
73
  ### Endpoints
72
74
 
@@ -1221,6 +1223,135 @@ client = Myfinance.client("YOUR_TOKEN_HERE")
1221
1223
  </tr>
1222
1224
  </table>
1223
1225
 
1226
+ #### [CustomClassifiers](https://app.myfinance.com.br/docs/api/custom_classifiers)
1227
+
1228
+ <table>
1229
+ <tr>
1230
+ <th>HTTP method</th>
1231
+ <th>Endpoint</th>
1232
+ <th>Client method</th>
1233
+ </tr>
1234
+ <tr>
1235
+ <td><code>GET</code></td>
1236
+ <td>
1237
+ <a href="https://app.myfinance.com.br/docs/api/custom_classifiers#get_index" target="_blank">
1238
+ /custom_classifiers
1239
+ </a>
1240
+ </td>
1241
+ <td>
1242
+ <code>client.custom_classifiers.find_all</code>
1243
+ </td>
1244
+ </tr>
1245
+ <tr>
1246
+ <td><code>GET</code></td>
1247
+ <td>
1248
+ <a href="https://app.myfinance.com.br/docs/api/custom_classifiers#get_show" target="_blank">
1249
+ /custom_classifiers/:id
1250
+ </a>
1251
+ </td>
1252
+ <td>
1253
+ <code>client.custom_classifiers.find</code>
1254
+ </td>
1255
+ </tr>
1256
+ <tr>
1257
+ <td><code>POST</code></td>
1258
+ <td>
1259
+ <a href="https://app.myfinance.com.br/docs/api/custom_classifiers#post_create" target="_blank">
1260
+ /custom_classifiers
1261
+ </a>
1262
+ </td>
1263
+ <td>
1264
+ <code>client.custom_classifiers.create</code>
1265
+ </td>
1266
+ </tr>
1267
+ <tr>
1268
+ <td><code>PUT</code></td>
1269
+ <td>
1270
+ <a href="https://app.myfinance.com.br/docs/api/custom_classifiers#put_update" target="_blank">
1271
+ /custom_classifiers/:id
1272
+ </a>
1273
+ </td>
1274
+ <td>
1275
+ <code>client.custom_classifiers.update</code>
1276
+ </td>
1277
+ </tr>
1278
+ <tr>
1279
+ <td><code>DELETE</code></td>
1280
+ <td>
1281
+ <a href="https://app.myfinance.com.br/docs/api/custom_classifiers#delete_destroy" target="_blank">
1282
+ /custom_classifiers/:id
1283
+ </a>
1284
+ </td>
1285
+ <td>
1286
+ <code>client.custom_classifiers.destroy</code>
1287
+ </td>
1288
+ </tr>
1289
+ </table>
1290
+
1291
+ #### [CustomClassifierValues](https://app.myfinance.com.br/docs/api/custom_classifier_values)
1292
+
1293
+ <table>
1294
+ <tr>
1295
+ <th>HTTP method</th>
1296
+ <th>Endpoint</th>
1297
+ <th>Client method</th>
1298
+ </tr>
1299
+ <tr>
1300
+ <td><code>GET</code></td>
1301
+ <td>
1302
+ <a href="https://app.myfinance.com.br/docs/api/custom_classifier_values#get_index" target="_blank">
1303
+ /custom_classifiers/:custom_classifier_value_id/values
1304
+ </a>
1305
+ </td>
1306
+ <td>
1307
+ <code>client.custom_classifier_values.find_all</code>
1308
+ </td>
1309
+ </tr>
1310
+ <tr>
1311
+ <td><code>GET</code></td>
1312
+ <td>
1313
+ <a href="https://app.myfinance.com.br/docs/api/custom_classifier_values#get_show" target="_blank">
1314
+ /custom_classifiers/:custom_classifier_value_id/values/:id
1315
+ </a>
1316
+ </td>
1317
+ <td>
1318
+ <code>client.custom_classifier_values.find</code>
1319
+ </td>
1320
+ </tr>
1321
+ <tr>
1322
+ <td><code>POST</code></td>
1323
+ <td>
1324
+ <a href="https://app.myfinance.com.br/docs/api/custom_classifier_values#post_create" target="_blank">
1325
+ /custom_classifiers/:custom_classifier_value_id/values
1326
+ </a>
1327
+ </td>
1328
+ <td>
1329
+ <code>client.custom_classifier_values.create</code>
1330
+ </td>
1331
+ </tr>
1332
+ <tr>
1333
+ <td><code>PUT</code></td>
1334
+ <td>
1335
+ <a href="https://app.myfinance.com.br/docs/api/custom_classifier_values#put_update" target="_blank">
1336
+ /custom_classifiers/:custom_classifier_value_id/values/:id
1337
+ </a>
1338
+ </td>
1339
+ <td>
1340
+ <code>client.custom_classifier_values.update</code>
1341
+ </td>
1342
+ </tr>
1343
+ <tr>
1344
+ <td><code>DELETE</code></td>
1345
+ <td>
1346
+ <a href="https://app.myfinance.com.br/docs/api/custom_classifier_values#delete_destroy" target="_blank">
1347
+ /custom_classifiers/:custom_classifier_value_id/values/:id
1348
+ </a>
1349
+ </td>
1350
+ <td>
1351
+ <code>client.custom_classifier_values.destroy</code>
1352
+ </td>
1353
+ </tr>
1354
+ </table>
1224
1355
 
1225
1356
  ### Configuration
1226
1357
 
@@ -91,5 +91,13 @@ module Myfinance
91
91
  def sale_rules
92
92
  Myfinance::Resources::SaleRule.new(http)
93
93
  end
94
+
95
+ def custom_classifiers
96
+ Myfinance::Resources::CustomClassifier.new(http)
97
+ end
98
+
99
+ def custom_classifier_values
100
+ Myfinance::Resources::CustomClassifierValue.new(http)
101
+ end
94
102
  end
95
103
  end
@@ -7,6 +7,7 @@ module Myfinance
7
7
  attribute :classification_center_id, Integer
8
8
  attribute :category_id, Integer
9
9
  attribute :closing_day, Integer
10
+ attribute :custom_classifications, Array[Hash]
10
11
  attribute :expiration_day, Integer
11
12
  attribute :name, String
12
13
  attribute :flag, String
@@ -6,6 +6,7 @@ module Myfinance
6
6
  attribute :credit_card_id, Integer
7
7
  attribute :classification_center_id, Integer
8
8
  attribute :category_id, Integer
9
+ attribute :custom_classifications, Array[Hash]
9
10
  attribute :amount, Decimal
10
11
  attribute :description, String
11
12
  attribute :occurred_at, Date
@@ -0,0 +1,11 @@
1
+ module Myfinance
2
+ module Entities
3
+ class CustomClassifier < Base
4
+ attribute :account_id, Integer
5
+ attribute :id, Integer
6
+ attribute :name, String
7
+ attribute :updated_at, DateTime
8
+ attribute :created_at, DateTime
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ module Myfinance
2
+ module Entities
3
+ #
4
+ # A wrapper to Myfinance custom_classifiers collection
5
+ #
6
+ class CustomClassifierCollection < Collection
7
+ def build_collection
8
+ response.parsed_body.each do |attributes|
9
+ collection.push(
10
+ Myfinance::Entities::CustomClassifier.new(attributes["custom_classifier"])
11
+ )
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ module Myfinance
2
+ module Entities
3
+ class CustomClassifierValue < Base
4
+ attribute :custom_classifier_id, Integer
5
+ attribute :id, Integer
6
+ attribute :value, String
7
+ attribute :updated_at, DateTime
8
+ attribute :created_at, DateTime
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ module Myfinance
2
+ module Entities
3
+ #
4
+ # A wrapper to Myfinance custom_classifiers collection
5
+ #
6
+ class CustomClassifierValueCollection < Collection
7
+ def build_collection
8
+ response.parsed_body.each do |attributes|
9
+ collection.push(
10
+ Myfinance::Entities::CustomClassifierValue.new(attributes["custom_classifier_value"])
11
+ )
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -24,6 +24,7 @@ module Myfinance
24
24
 
25
25
  attribute :tax_charges, Array[Hash]
26
26
  attribute :financial_account_taxes_attributes, Array[Hash]
27
+ attribute :custom_classifications, Array[Hash]
27
28
  attribute :reconciliations, Hash[String => Array]
28
29
  attribute :links, Array[Hash[String => String]]
29
30
  end
@@ -8,6 +8,7 @@ module Myfinance
8
8
  attribute :owner_id, Integer
9
9
  attribute :currency_id, Integer
10
10
  attribute :category_id, Integer
11
+ attribute :custom_classifications, Array[Hash]
11
12
  attribute :type, String
12
13
  attribute :occurred_at, Date
13
14
  attribute :document, String
@@ -8,7 +8,6 @@ module Myfinance
8
8
  attribute :confirmed_at
9
9
  attribute :created_at
10
10
  attribute :custom_classifications
11
- attribute :custom_classifications
12
11
  attribute :days_to_liquidation
13
12
  attribute :description
14
13
  attribute :discount_amount
@@ -0,0 +1,83 @@
1
+ module Myfinance
2
+ module Resources
3
+ class CustomClassifier < Base
4
+ #
5
+ # List all custom classifiers
6
+ #
7
+ # [API]
8
+ # Method: <tt>GET /custom_classifiers</tt>
9
+ #
10
+ # Documentation: https://sandbox.myfinance.com.br/docs/api/custom_classifiers#get_index
11
+ #
12
+ def find_all(params = {})
13
+ search_endpoint = build_search_endpoint(params)
14
+
15
+ http.get(search_endpoint) do |response|
16
+ respond_with_collection(response)
17
+ end
18
+ end
19
+
20
+ #
21
+ # Find a custom classifier
22
+ #
23
+ # [API]
24
+ # Method: <tt>GET /custom_classifiers/:id</tt>
25
+ #
26
+ # Documentation: https://sandbox.myfinance.com.br/docs/api/custom_classifiers#get_show
27
+ #
28
+ def find(id)
29
+ http.get("/custom_classifiers/#{id}", body: {}) do |response|
30
+ respond_with_object response, "custom_classifier"
31
+ end
32
+ end
33
+
34
+ #
35
+ # Creates a custom classifier
36
+ #
37
+ # [API]
38
+ # Method: <tt>POST /custom_classifiers</tt>
39
+ #
40
+ # Documentation: https://sandbox.myfinance.com.br/docs/api/custom_classifiers#post_create
41
+ #
42
+ def create(params)
43
+ http.post("/custom_classifiers", body: { custom_classifier: params }) do |response|
44
+ respond_with_object response, "custom_classifier"
45
+ end
46
+ end
47
+
48
+ #
49
+ # Updates a custom classifier
50
+ #
51
+ # [API]
52
+ # Method: <tt>PUT /custom_classifiers/:id</tt>
53
+ #
54
+ # Documentation: https://sandbox.myfinance.com.br/docs/api/custom_classifiers#put_update
55
+ #
56
+ def update(id, params = {})
57
+ http.put("/custom_classifiers/#{id}", body: { custom_classifier: params }) do |response|
58
+ respond_with_object response, "custom_classifier"
59
+ end
60
+ end
61
+
62
+ #
63
+ # Destroy a custom_classifier
64
+ #
65
+ # [API]
66
+ # Method: <tt>DELETE /custom_classifiers/:id</tt>
67
+ #
68
+ # Documentation: https://sandbox.myfinance.com.br/docs/api/custom_classifiers#delete_destroy
69
+ #
70
+ def destroy(id)
71
+ http.delete("/custom_classifiers/#{id}", body: {}) do |response|
72
+ respond_with_object response, "custom_classifier"
73
+ end
74
+ end
75
+
76
+ private
77
+
78
+ def endpoint
79
+ "/custom_classifiers"
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,92 @@
1
+ module Myfinance
2
+ module Resources
3
+ class CustomClassifierValue < Base
4
+ #
5
+ # List all custom classifier values
6
+ #
7
+ # [API]
8
+ # Method: <tt>GET /custom_classifiers/:custom_classifier_id/values</tt>
9
+ #
10
+ # Documentation: https://sandbox.myfinance.com.br/docs/api/custom_classifier_values#get_index
11
+ #
12
+ def find_all(custom_classifier_id, params = {})
13
+ search_endpoint = build_search_endpoint(custom_classifier_id, params)
14
+
15
+ http.get(search_endpoint) do |response|
16
+ respond_with_collection(response)
17
+ end
18
+ end
19
+
20
+ #
21
+ # Find a custom classifier value
22
+ #
23
+ # [API]
24
+ # Method: <tt>GET /custom_classifiers/:custom_classifier_id/values/:id</tt>
25
+ #
26
+ # Documentation: https://sandbox.myfinance.com.br/docs/api/custom_classifier_values#get_show
27
+ #
28
+ def find(custom_classifier_id, id)
29
+ http.get("/custom_classifiers/#{custom_classifier_id}/values/#{id}", body: {}) do |response|
30
+ respond_with_object(response, "custom_classifier_value")
31
+ end
32
+ end
33
+
34
+ #
35
+ # Creates a custom classifier value
36
+ #
37
+ # [API]
38
+ # Method: <tt>POST /custom_classifiers/:custom_classifier_id/values</tt>
39
+ #
40
+ # Documentation: https://sandbox.myfinance.com.br/docs/api/custom_classifiers#post_create
41
+ #
42
+ def create(custom_classifier_id, params)
43
+ body = { custom_classifier_value: params }
44
+ http.post("/custom_classifiers/#{custom_classifier_id}/values", body: body) do |response|
45
+ respond_with_object(response, "custom_classifier_value")
46
+ end
47
+ end
48
+
49
+ #
50
+ # Updates a custom classifier value
51
+ #
52
+ # [API]
53
+ # Method: <tt>PUT /custom_classifiers/:custom_classifier_id/values/:id</tt>
54
+ #
55
+ # Documentation: https://sandbox.myfinance.com.br/docs/api/custom_classifiers#put_update
56
+ #
57
+ def update(custom_classifier_id, id, params = {})
58
+ body = { custom_classifier_value: params }
59
+ http.put("/custom_classifiers/#{custom_classifier_id}/values/#{id}", body: body) do |response|
60
+ respond_with_object(response, "custom_classifier_value")
61
+ end
62
+ end
63
+
64
+ #
65
+ # Destroy a custom classifier value
66
+ #
67
+ # [API]
68
+ # Method: <tt>DELETE /custom_classifiers/:custom_classifier_id/values/:id</tt>
69
+ #
70
+ # Documentation: https://sandbox.myfinance.com.br/docs/api/custom_classifiers#delete_destroy
71
+ #
72
+ def destroy(custom_classifier_id, id)
73
+ http.delete("/custom_classifiers/#{custom_classifier_id}/values/#{id}", body: {}) do |response|
74
+ respond_with_object(response, "custom_classifier_value")
75
+ end
76
+ end
77
+
78
+ private
79
+
80
+ def build_search_endpoint(custom_classifier_id, params)
81
+ query_string = query(params).join("&")
82
+ custom_classifier_endpoint = endpoint(custom_classifier_id)
83
+
84
+ URI.encode("#{custom_classifier_endpoint}?#{query_string}")
85
+ end
86
+
87
+ def endpoint(custom_classifier_id)
88
+ "/custom_classifiers/#{custom_classifier_id}/values"
89
+ end
90
+ end
91
+ end
92
+ end