myfinance 0.7.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -2
  3. data/CHANGELOG.md +15 -0
  4. data/Gemfile.lock +1 -1
  5. data/README.md +304 -1
  6. data/lib/myfinance.rb +12 -0
  7. data/lib/myfinance/client.rb +16 -0
  8. data/lib/myfinance/entities/bank_statement.rb +16 -0
  9. data/lib/myfinance/entities/credit_card.rb +19 -0
  10. data/lib/myfinance/entities/credit_card_collection.rb +11 -0
  11. data/lib/myfinance/entities/credit_card_transaction.rb +26 -0
  12. data/lib/myfinance/entities/credit_card_transaction_collection.rb +11 -0
  13. data/lib/myfinance/entities/financial_account.rb +1 -1
  14. data/lib/myfinance/entities/payable_account_collection.rb +14 -0
  15. data/lib/myfinance/entities/receivable_account_collection.rb +14 -0
  16. data/lib/myfinance/entities/reconcile_collection.rb +30 -0
  17. data/lib/myfinance/resources/bank_statement.rb +20 -0
  18. data/lib/myfinance/resources/category.rb +16 -0
  19. data/lib/myfinance/resources/classification_center.rb +1 -1
  20. data/lib/myfinance/resources/credit_card.rb +47 -0
  21. data/lib/myfinance/resources/credit_card_transaction.rb +47 -0
  22. data/lib/myfinance/resources/financial_account.rb +48 -7
  23. data/lib/myfinance/resources/financial_transaction.rb +13 -2
  24. data/lib/myfinance/resources/person.rb +1 -1
  25. data/lib/myfinance/resources/reconcile.rb +20 -0
  26. data/lib/myfinance/version.rb +1 -1
  27. data/spec/lib/myfinance/client_spec.rb +21 -0
  28. data/spec/lib/myfinance/entities/credit_card_collection_spec.rb +23 -0
  29. data/spec/lib/myfinance/entities/credit_card_spec.rb +7 -0
  30. data/spec/lib/myfinance/entities/credit_card_transaction_collection_spec.rb +21 -0
  31. data/spec/lib/myfinance/entities/credit_card_transaction_spec.rb +8 -0
  32. data/spec/lib/myfinance/entities/reconcile_collection_spec.rb +20 -0
  33. data/spec/lib/myfinance/resources/bank_statement_spec.rb +53 -0
  34. data/spec/lib/myfinance/resources/category_spec.rb +24 -3
  35. data/spec/lib/myfinance/resources/classification_center_spec.rb +12 -5
  36. data/spec/lib/myfinance/resources/credit_card_spec.rb +142 -0
  37. data/spec/lib/myfinance/resources/credit_card_transaction_spec.rb +162 -0
  38. data/spec/lib/myfinance/resources/financial_transaction_spec.rb +27 -2
  39. data/spec/lib/myfinance/resources/payable_account_spec.rb +131 -15
  40. data/spec/lib/myfinance/resources/person_spec.rb +16 -4
  41. data/spec/lib/myfinance/resources/receivable_account_spec.rb +132 -15
  42. data/spec/lib/myfinance/resources/reconcile_spec.rb +33 -0
  43. data/spec/support/bank_statements/extrato.ofx +207 -0
  44. metadata +35 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0cc4a1064aa43f5ea804054f28615cca76b55736
4
- data.tar.gz: 6c1865d21fb91219abcfd059ad6e7f90dccdc3d4
3
+ metadata.gz: f7d232896f250a7b2c78111a9fd498491e38be7e
4
+ data.tar.gz: 6ea40361789ab7210fae8e0fda62e2f04fe3d0b1
5
5
  SHA512:
6
- metadata.gz: 2697a1a00cb82c86a0c0f0a1737e4179eb05b10ffd42740a2e70aa0c3d23c2e734593d881e76baf6506d96a3e4429b1e723a1f1b9cf48b972191e871b35a5c0c
7
- data.tar.gz: c4ed5d1bf31c386dca979788f458aa4e4e86ec4f46dffb959c601767ffc94bb914347125f37c11555c8aa7cb89445559f433f12fb1fb69fdf8705894a49576c7
6
+ metadata.gz: 7d4096f7fd67ec4da65075b7f6e76bc93ef2bfb4495e46140a6a91d99550a82c398bf6fd1445cf172804bcc82fc6cff09cbe9d5e26f9587fb6c664607b05cda4
7
+ data.tar.gz: 1d72e21517c1aabc1030c77c0486776d36a1ac8c394fa100e5714e37c1cf1001b93f8343f8402666b7f8b9d2839399b46ee6f4930a4f9c801c97bfe7a7979ae6
@@ -231,9 +231,10 @@ Metrics/CyclomaticComplexity:
231
231
  Enabled: true
232
232
 
233
233
  Metrics/LineLength:
234
- Description: 'Limit lines to 80 characters.'
234
+ Description: 'Limit lines to 120 characters.'
235
235
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
236
- Enabled: false
236
+ Enabled: true
237
+ Max: 120
237
238
 
238
239
  Metrics/MethodLength:
239
240
  Description: 'Avoid methods longer than 30 lines of code.'
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## v1.0.0
4
+
5
+ ### New Endpoints
6
+ - Add Bank Statements endpoints
7
+ - Add Categories endpoints
8
+ - Add Credit Cards endpoints
9
+ - Add Credit Cards Transactions endpoints
10
+ - Add Reconciles endpoints
11
+ - More endpoints for Financial Accounts (`find_all`, `find`)
12
+ ### Improvements
13
+ - Implement search by attributes in Categories
14
+ ### Deprecations
15
+ - `FinancialAccount#destroy` and `#update` signatures are now `(entity_id, id, params)` instead of `(id, entity_id, params)`
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- myfinance (0.7.0)
4
+ myfinance (1.0.0)
5
5
  mime-types (~> 2.99)
6
6
  multi_json (~> 1.11)
7
7
  typhoeus (~> 0.8)
data/README.md CHANGED
@@ -25,6 +25,19 @@ Or install it yourself as:
25
25
 
26
26
  $ gem install myfinance
27
27
 
28
+ ## Configuration
29
+
30
+ Use `Myfinance.configure` to setup your environment:
31
+
32
+ ```ruby
33
+ require 'myfinance'
34
+
35
+ Myfinance.configure do |config|
36
+ config.url = 'https://sandbox.myfinance.com.br' # defaults to 'https://app.myfinance.com.br'
37
+ config.user_agent = 'My App v1.0' # optional, but you should pass a custom user-agent identifying your app
38
+ end
39
+ ```
40
+
28
41
  ## Usage
29
42
 
30
43
  ##### Given your token, create an instance of Myfinance::Client, as below:
@@ -47,6 +60,10 @@ client = Myfinance.client("YOUR_TOKEN_HERE")
47
60
  * [People API](https://app.myfinance.com.br/docs/api/people) as `client.people`
48
61
  * [Webhooks API](https://app.myfinance.com.br/docs/api/webhooks) as `client.webhooks`
49
62
  * [Taxes API](https://app.myfinance.com.br/docs/api/taxes) as `client.taxes`
63
+ * [CreditCards API](https://app.myfinance.com.br/docs/api/credit_cards) as `client.credit_cards`
64
+ * [CreditCardsTransactions API](https://app.myfinance.com.br/docs/api/credit_cards_transactions) as `client.credit_cards_transactions`
65
+ * [Reconciles API](https://app.myfinance.com.br/docs/api/reconciles) as `client.reconciles`
66
+ * [BankStatements API](https://app.myfinance.com.br/docs/api/bank_statements) as `client.bank_statements`
50
67
 
51
68
  ### Endpoints
52
69
 
@@ -167,6 +184,30 @@ client = Myfinance.client("YOUR_TOKEN_HERE")
167
184
  <th>Endpoint</th>
168
185
  <th>Client method</th>
169
186
  </tr>
187
+ <tr>
188
+ <td><code>GET</code></td>
189
+ <td>
190
+ <a href="https://app.myfinance.com.br/docs/api/payable_accounts#get_index" target="_blank">
191
+ /entities/:entity_id/payable_accounts
192
+ </a>
193
+ </td>
194
+ <td>
195
+ <code>client.payable_accounts.find_all</code>
196
+ </td>
197
+ </tr>
198
+
199
+ <tr>
200
+ <td><code>GET</code></td>
201
+ <td>
202
+ <a href="https://app.myfinance.com.br/docs/api/payable_accounts#get_show" target="_blank">
203
+ /entities/:entity_id/payable_accounts/:id
204
+ </a>
205
+ </td>
206
+ <td>
207
+ <code>client.payable_accounts.find</code>
208
+ </td>
209
+ </tr>
210
+
170
211
  <tr>
171
212
  <td><code>POST</code></td>
172
213
  <td>
@@ -222,6 +263,29 @@ client = Myfinance.client("YOUR_TOKEN_HERE")
222
263
  <code>client.payable_accounts.destroy</code>
223
264
  </td>
224
265
  </tr>
266
+ <tr>
267
+ <td><code>DELETE</code></td>
268
+ <td>
269
+ <a href="https://app.myfinance.com.br/docs/api/payable_accounts#delete_destroy_as_recurrent" target="_blank">
270
+ /entities/:entity_id/payable_accounts/:id/recurrence
271
+ </a>
272
+ </td>
273
+ <td>
274
+ <code>client.payable_accounts.destroy_recurrence</code>
275
+ </td>
276
+ </tr>
277
+ <tr>
278
+ <td><code>DELETE</code></td>
279
+ <td>
280
+ <a href="https://app.myfinance.com.br/docs/api/payable_accounts#delete_destroy_many" target="_blank">
281
+ /entities/:entity_id/payable_accounts?selected_ids=:id1,id2,id3
282
+ </a>
283
+ </td>
284
+ <td>
285
+ <code>client.payable_accounts.destroy_many</code>
286
+ </td>
287
+ </tr>
288
+
225
289
  </table>
226
290
 
227
291
  #### [ReceivableAccounts](https://app.myfinance.com.br/docs/api/receivable_accounts)
@@ -232,6 +296,29 @@ client = Myfinance.client("YOUR_TOKEN_HERE")
232
296
  <th>Endpoint</th>
233
297
  <th>Client method</th>
234
298
  </tr>
299
+ <tr>
300
+ <td><code>GET</code></td>
301
+ <td>
302
+ <a href="https://app.myfinance.com.br/docs/api/receivable_accounts#get_index" target="_blank">
303
+ /entities/:entity_id/receivable_accounts
304
+ </a>
305
+ </td>
306
+ <td>
307
+ <code>client.receivable_accounts.find_all</code>
308
+ </td>
309
+ </tr>
310
+
311
+ <tr>
312
+ <td><code>GET</code></td>
313
+ <td>
314
+ <a href="https://app.myfinance.com.br/docs/api/receivable_accounts#get_show" target="_blank">
315
+ /entities/:entity_id/receivable_accounts/:id
316
+ </a>
317
+ </td>
318
+ <td>
319
+ <code>client.receivable_accounts.find</code>
320
+ </td>
321
+ </tr>
235
322
  <tr>
236
323
  <td><code>POST</code></td>
237
324
  <td>
@@ -287,6 +374,28 @@ client = Myfinance.client("YOUR_TOKEN_HERE")
287
374
  <code>client.receivable_accounts.destroy</code>
288
375
  </td>
289
376
  </tr>
377
+ <tr>
378
+ <td><code>DELETE</code></td>
379
+ <td>
380
+ <a href="https://app.myfinance.com.br/docs/api/receivable_accounts#delete_destroy_as_recurrent" target="_blank">
381
+ /entities/:entity_id/receivable_accounts/:id/recurrence
382
+ </a>
383
+ </td>
384
+ <td>
385
+ <code>client.receivable_accounts.destroy_recurrence</code>
386
+ </td>
387
+ </tr>
388
+ <tr>
389
+ <td><code>DELETE</code></td>
390
+ <td>
391
+ <a href="https://app.myfinance.com.br/docs/api/receivable_accounts#delete_destroy_many" target="_blank">
392
+ /entities/:entity_id/receivable_accounts?selected_ids=:id1,id2,id3
393
+ </a>
394
+ </td>
395
+ <td>
396
+ <code>client.receivable_accounts.destroy_many</code>
397
+ </td>
398
+ </tr>
290
399
  </table>
291
400
 
292
401
  #### [Attachments](https://app.myfinance.com.br/docs/api/attachments)
@@ -743,6 +852,198 @@ client = Myfinance.client("YOUR_TOKEN_HERE")
743
852
  </tr>
744
853
  </table>
745
854
 
855
+ #### [CreditCards](https://app.myfinance.com.br/docs/api/credit_cards)
856
+ <table>
857
+ <tr>
858
+ <th>HTTP method</th>
859
+ <th>Endpoint</th>
860
+ <th>Client method</th>
861
+ </tr>
862
+ <tr>
863
+ <td><code>GET</code></td>
864
+ <td>
865
+ <a href="https://app.myfinance.com.br/docs/api/credit_cards#get_index" target="_blank">
866
+ /entities/:entity_id/credit_cards
867
+ </a>
868
+ </td>
869
+ <td>
870
+ <code>client.credit_cards.find_all</code>
871
+ </td>
872
+ </tr>
873
+ <tr>
874
+ <td><code>GET</code></td>
875
+ <td>
876
+ <a href="https://app.myfinance.com.br/docs/api/credit_cards#get_show" target="_blank">
877
+ /entities/:entity_id/credit_cards/:id
878
+ </a>
879
+ </td>
880
+ <td>
881
+ <code>client.credit_cards.find</code>
882
+ </td>
883
+ </tr>
884
+ <tr>
885
+ <td><code>POST</code></td>
886
+ <td>
887
+ <a href="https://app.myfinance.com.br/docs/api/credit_cards#post_create" target="_blank">
888
+ /entities/:entity_id/credit_cards
889
+ </a>
890
+ </td>
891
+ <td>
892
+ <code>client.credit_cards.create</code>
893
+ </td>
894
+ </tr>
895
+ <tr>
896
+ <td><code>PUT</code></td>
897
+ <td>
898
+ <a href="https://app.myfinance.com.br/docs/api/credit_cards#put_update" target="_blank">
899
+ /entities/:entity_id/credit_cards/:id
900
+ </a>
901
+ </td>
902
+ <td>
903
+ <code>client.credit_cards.update</code>
904
+ </td>
905
+ </tr>
906
+ <tr>
907
+ <td><code>DELETE</code></td>
908
+ <td>
909
+ <a href="https://app.myfinance.com.br/docs/api/credit_cards#delete_destroy" target="_blank">
910
+ /entities/:entity_id/credit_cards/:id
911
+ </a>
912
+ </td>
913
+ <td>
914
+ <code>client.credit_cards.destroy</code>
915
+ </td>
916
+ </tr>
917
+ </table>
918
+
919
+ #### [CreditCardTransactions](https://app.myfinance.com.br/docs/api/credit_card_transactions)
920
+
921
+ <table>
922
+ <tr>
923
+ <th>HTTP method</th>
924
+ <th>Endpoint</th>
925
+ <th>Client method</th>
926
+ </tr>
927
+ <tr>
928
+ <td><code>GET</code></td>
929
+ <td>
930
+ <a href="https://app.myfinance.com.br/docs/api/credit_card_transactions#get_index" target="_blank">
931
+ /entities/:entity_id/credit_cards/:credit_card_id/transactions
932
+ </a>
933
+ </td>
934
+ <td>
935
+ <code>client.credit_card_transactions.find_all</code>
936
+ </td>
937
+ </tr>
938
+ <tr>
939
+ <td><code>GET</code></td>
940
+ <td>
941
+ <a href="https://app.myfinance.com.br/docs/api/credit_card_transactions#get_show" target="_blank">
942
+ /entities/:entity_id/credit_cards/:credit_card_id/transactions/:id
943
+ </a>
944
+ </td>
945
+ <td>
946
+ <code>client.credit_card_transactions.find</code>
947
+ </td>
948
+ </tr>
949
+ <tr>
950
+ <td><code>POST</code></td>
951
+ <td>
952
+ <a href="https://app.myfinance.com.br/docs/api/credit_card_transactions#post_create" target="_blank">
953
+ /entities/:entity_id/credit_cards/:credit_card_id/transactions
954
+ </a>
955
+ </td>
956
+ <td>
957
+ <code>client.credit_card_transactions.create</code>
958
+ </td>
959
+ </tr>
960
+ <tr>
961
+ <td><code>PUT</code></td>
962
+ <td>
963
+ <a href="https://app.myfinance.com.br/docs/api/credit_card_transactions#put_update" target="_blank">
964
+ /entities/:entity_id/credit_cards/:credit_card_id/transactions/:id
965
+ </a>
966
+ </td>
967
+ <td>
968
+ <code>client.credit_card_transactions.update</code>
969
+ </td>
970
+ </tr>
971
+ <tr>
972
+ <td><code>DELETE</code></td>
973
+ <td>
974
+ <a href="https://app.myfinance.com.br/docs/api/credit_card_transactions#delete_destroy" target="_blank">
975
+ /entities/:entity_id/credit_cards/:credit_card_id/transactions/:id
976
+ </a>
977
+ </td>
978
+ <td>
979
+ <code>client.credit_card_transactions.destroy</code>
980
+ </td>
981
+ </tr>
982
+ <tr>
983
+ <td><code>DELETE</code></td>
984
+ <td>
985
+ <a href="https://app.myfinance.com.br/docs/api/credit_card_transactions#delete_destroy_parcelled" target="_blank">
986
+ /entities/:entity_id/credit_cards/:credit_card_id/transactions/:id/recurrence
987
+ </a>
988
+ </td>
989
+ <td>
990
+ <code>client.credit_card_transactions.destroy_parcelled</code>
991
+ </td>
992
+ </tr>
993
+ </table>
994
+
995
+ #### [Reconciles](https://app.myfinance.com.br/docs/api/reconciles)
996
+
997
+ <table>
998
+ <tr>
999
+ <th>HTTP method</th>
1000
+ <th>Endpoint</th>
1001
+ <th>Client method</th>
1002
+ </tr>
1003
+ <tr>
1004
+ <td><code>POST</code></td>
1005
+ <td>
1006
+ <a href="https://app.myfinance.com.br/docs/api/reconciles#post_reconciles" target="_blank">
1007
+ /entities/:entity_id/reconciles
1008
+ </a>
1009
+ </td>
1010
+ <td>
1011
+ <code>client.reconciles.reconcile</code>
1012
+ </td>
1013
+ </tr>
1014
+ </table>
1015
+
1016
+ #### [BankStatements](https://app.myfinance.com.br/docs/api/bank_statements)
1017
+ <table>
1018
+ <tr>
1019
+ <th>HTTP method</th>
1020
+ <th>Endpoint</th>
1021
+ <th>Client method</th>
1022
+ </tr>
1023
+ <tr>
1024
+ <td><code>POST</code></td>
1025
+ <td>
1026
+ <a href="https://app.myfinance.com.br/docs/api/bank_statements" target="_blank">
1027
+ /entities/:entity_id/deposit_accounts/:deposit_account_id/bank_statements
1028
+ </a>
1029
+ </td>
1030
+ <td>
1031
+ <code>client.bank_statements.import</code>
1032
+ </td>
1033
+ </tr>
1034
+ <tr>
1035
+ <td><code>GET</code></td>
1036
+ <td>
1037
+ <a href="https://app.myfinance.com.br/docs/api/bank_statements" target="_blank">
1038
+ /entities/:entity_id/deposit_accounts/:deposit_account_id/bank_statements/:id
1039
+ </a>
1040
+ </td>
1041
+ <td>
1042
+ <code>client.bank_statements.status</code>
1043
+ </td>
1044
+ </tr>
1045
+ </table>
1046
+
746
1047
  ### Configuration
747
1048
 
748
1049
  ```ruby
@@ -778,7 +1079,9 @@ end
778
1079
 
779
1080
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
780
1081
 
781
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
1082
+ To install this gem onto your local machine, run `bundle exec rake install`.
1083
+
1084
+ To release a new version, update the version number in `lib/myfinance/version.rb`, run `bundle install` and commit & push the changes to the repository. Then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). Make sure you have publishing rights for the gem on RubyGems beforehand, though.
782
1085
 
783
1086
  ## Contributing
784
1087
 
@@ -16,7 +16,9 @@ require "myfinance/entities/financial_transaction"
16
16
  require "myfinance/entities/financial_transaction_collection"
17
17
  require "myfinance/entities/financial_account"
18
18
  require "myfinance/entities/payable_account"
19
+ require "myfinance/entities/payable_account_collection"
19
20
  require "myfinance/entities/receivable_account"
21
+ require "myfinance/entities/receivable_account_collection"
20
22
  require "myfinance/entities/attachment"
21
23
  require "myfinance/entities/classification_center"
22
24
  require "myfinance/entities/classification_center_collection"
@@ -32,6 +34,12 @@ require "myfinance/entities/webhook"
32
34
  require "myfinance/entities/webhook_collection"
33
35
  require "myfinance/entities/tax"
34
36
  require "myfinance/entities/tax_collection"
37
+ require "myfinance/entities/credit_card"
38
+ require "myfinance/entities/credit_card_collection"
39
+ require "myfinance/entities/credit_card_transaction"
40
+ require "myfinance/entities/credit_card_transaction_collection"
41
+ require "myfinance/entities/reconcile_collection"
42
+ require "myfinance/entities/bank_statement"
35
43
 
36
44
  require "myfinance/resources/base"
37
45
  require "myfinance/resources/entity"
@@ -47,6 +55,10 @@ require "myfinance/resources/deposit_account"
47
55
  require "myfinance/resources/person"
48
56
  require "myfinance/resources/webhook"
49
57
  require "myfinance/resources/tax"
58
+ require "myfinance/resources/credit_card"
59
+ require "myfinance/resources/credit_card_transaction"
60
+ require "myfinance/resources/reconcile"
61
+ require "myfinance/resources/bank_statement"
50
62
 
51
63
  module Myfinance
52
64
  def self.configuration
@@ -63,5 +63,21 @@ module Myfinance
63
63
  def taxes
64
64
  Myfinance::Resources::Tax.new(http)
65
65
  end
66
+
67
+ def credit_cards
68
+ Myfinance::Resources::CreditCard.new(http)
69
+ end
70
+
71
+ def credit_card_transactions
72
+ Myfinance::Resources::CreditCardTransaction.new(http)
73
+ end
74
+
75
+ def reconciles
76
+ Myfinance::Resources::Reconcile.new(http)
77
+ end
78
+
79
+ def bank_statements
80
+ Myfinance::Resources::BankStatement.new(http)
81
+ end
66
82
  end
67
83
  end