myfinance 1.4.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/Gemfile.lock +2 -2
- data/README.md +131 -0
- data/lib/myfinance/client.rb +8 -0
- data/lib/myfinance/entities/credit_card.rb +1 -0
- data/lib/myfinance/entities/credit_card_transaction.rb +1 -0
- data/lib/myfinance/entities/custom_classifier.rb +11 -0
- data/lib/myfinance/entities/custom_classifier_collection.rb +16 -0
- data/lib/myfinance/entities/custom_classifier_value.rb +11 -0
- data/lib/myfinance/entities/custom_classifier_value_collection.rb +16 -0
- data/lib/myfinance/entities/financial_account.rb +1 -0
- data/lib/myfinance/entities/financial_transaction.rb +1 -0
- data/lib/myfinance/entities/sale.rb +0 -1
- data/lib/myfinance/resources/custom_classifier.rb +83 -0
- data/lib/myfinance/resources/custom_classifier_value.rb +92 -0
- data/lib/myfinance/version.rb +1 -1
- data/spec/lib/myfinance/client_spec.rb +16 -113
- data/spec/lib/myfinance/entities/account_collection_spec.rb +1 -15
- data/spec/lib/myfinance/entities/attachment_collection_spec.rb +1 -16
- data/spec/lib/myfinance/entities/category_collection_spec.rb +1 -43
- data/spec/lib/myfinance/entities/classification_center_collection_spec.rb +1 -19
- data/spec/lib/myfinance/entities/credit_card_collection_spec.rb +1 -19
- data/spec/lib/myfinance/entities/credit_card_spec.rb +3 -3
- data/spec/lib/myfinance/entities/credit_card_transaction_collection_spec.rb +1 -17
- data/spec/lib/myfinance/entities/credit_card_transaction_spec.rb +5 -4
- data/spec/lib/myfinance/entities/custom_classifier_collection_spec.rb +5 -0
- data/spec/lib/myfinance/entities/custom_classifier_spec.rb +7 -0
- data/spec/lib/myfinance/entities/custom_classifier_value_collection_spec.rb +5 -0
- data/spec/lib/myfinance/entities/custom_classifier_value_spec.rb +7 -0
- data/spec/lib/myfinance/entities/deposit_account_collection_spec.rb +1 -19
- data/spec/lib/myfinance/entities/financial_transaction_collection_spec.rb +1 -19
- data/spec/lib/myfinance/entities/financial_transaction_spec.rb +8 -8
- data/spec/lib/myfinance/entities/payable_account_spec.rb +7 -7
- data/spec/lib/myfinance/entities/person_collection_spec.rb +1 -22
- data/spec/lib/myfinance/entities/receivable_account_spec.rb +7 -7
- data/spec/lib/myfinance/entities/reconcile_collection_spec.rb +1 -3
- data/spec/lib/myfinance/entities/tax_collection_spec.rb +1 -19
- data/spec/lib/myfinance/entities/webhook_collection_spec.rb +1 -44
- data/spec/lib/myfinance/resources/custom_classifier_spec.rb +90 -0
- data/spec/lib/myfinance/resources/custom_classifier_value_spec.rb +111 -0
- data/spec/lib/myfinance_spec.rb +14 -5
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 589e8dda000cd743433879d1fc4d1055347b167c
|
4
|
+
data.tar.gz: 157ffd66f873d623ebcc00a20124272c0b191d43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
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
|
|
data/lib/myfinance/client.rb
CHANGED
@@ -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,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,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
|
@@ -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
|