myfinance 0.4.0 → 0.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.
- checksums.yaml +4 -4
- data/.codeclimate.yml +24 -0
- data/.rubocop.yml +1156 -0
- data/.travis.yml +3 -3
- data/Gemfile.lock +7 -7
- data/README.md +309 -2
- data/lib/myfinance.rb +15 -0
- data/lib/myfinance/client.rb +20 -0
- data/lib/myfinance/entities/account.rb +26 -0
- data/lib/myfinance/entities/account_collection.rb +16 -0
- data/lib/myfinance/entities/category.rb +22 -0
- data/lib/myfinance/entities/category_collection.rb +16 -0
- data/lib/myfinance/entities/classification_center.rb +15 -0
- data/lib/myfinance/entities/classification_center_collection.rb +18 -0
- data/lib/myfinance/entities/deposit_account.rb +24 -0
- data/lib/myfinance/entities/deposit_account_collection.rb +16 -0
- data/lib/myfinance/entities/person.rb +38 -0
- data/lib/myfinance/entities/person_collection.rb +14 -0
- data/lib/myfinance/resources/account.rb +25 -0
- data/lib/myfinance/resources/category.rb +81 -0
- data/lib/myfinance/resources/classification_center.rb +103 -0
- data/lib/myfinance/resources/deposit_account.rb +93 -0
- data/lib/myfinance/resources/person.rb +97 -0
- data/lib/myfinance/version.rb +1 -1
- data/spec/lib/myfinance/client_spec.rb +40 -0
- data/spec/lib/myfinance/entities/account_collection_spec.rb +19 -0
- data/spec/lib/myfinance/entities/account_spec.rb +13 -0
- data/spec/lib/myfinance/entities/category_collection_spec.rb +47 -0
- data/spec/lib/myfinance/entities/category_spec.rb +12 -0
- data/spec/lib/myfinance/entities/classification_center_collection_spec.rb +23 -0
- data/spec/lib/myfinance/entities/classification_center_spec.rb +8 -0
- data/spec/lib/myfinance/entities/deposit_account_collection_spec.rb +23 -0
- data/spec/lib/myfinance/entities/deposit_account_spec.rb +11 -0
- data/spec/lib/myfinance/entities/person_collection_spec.rb +26 -0
- data/spec/lib/myfinance/entities/person_spec.rb +18 -0
- data/spec/lib/myfinance/resources/account_spec.rb +28 -0
- data/spec/lib/myfinance/resources/category_spec.rb +118 -0
- data/spec/lib/myfinance/resources/classification_center_spec.rb +147 -0
- data/spec/lib/myfinance/resources/deposit_account_spec.rb +123 -0
- data/spec/lib/myfinance/resources/person_spec.rb +139 -0
- metadata +50 -3
@@ -0,0 +1,16 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Entities
|
3
|
+
#
|
4
|
+
# A wrapper to Myfinance entities collection
|
5
|
+
#
|
6
|
+
class AccountCollection < Collection
|
7
|
+
def build_collection
|
8
|
+
response.parsed_body.each do |attributes|
|
9
|
+
collection.push(
|
10
|
+
Myfinance::Entities::Account.new(attributes["account"])
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Entities
|
3
|
+
class Category < Base
|
4
|
+
attribute :account_id, Integer
|
5
|
+
attribute :cost, Boolean
|
6
|
+
attribute :created_at, DateTime
|
7
|
+
attribute :excel_import_id, Integer
|
8
|
+
attribute :force_destroy, Boolean
|
9
|
+
attribute :full_name, String
|
10
|
+
attribute :guid, String
|
11
|
+
attribute :id, Integer
|
12
|
+
attribute :imported_from_sync, Boolean
|
13
|
+
attribute :interested_users_ids, Array
|
14
|
+
attribute :modified_by_sync, Boolean
|
15
|
+
attribute :name, String
|
16
|
+
attribute :parent_id, Integer
|
17
|
+
attribute :revenue, Boolean
|
18
|
+
attribute :updated_at, DateTime
|
19
|
+
attribute :use_count, Integer
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Entities
|
3
|
+
#
|
4
|
+
# A wrapper to Myfinance categories collection
|
5
|
+
#
|
6
|
+
class CategoryCollection < Collection
|
7
|
+
def build_collection
|
8
|
+
response.parsed_body.each do |attributes|
|
9
|
+
collection.push(
|
10
|
+
Myfinance::Entities::Category.new(attributes["category"])
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Entities
|
3
|
+
class ClassificationCenter < Base
|
4
|
+
attribute :cost_center, Boolean
|
5
|
+
attribute :created_at, DateTime
|
6
|
+
attribute :entity_id, Integer
|
7
|
+
attribute :excel_import_id, Integer
|
8
|
+
attribute :id, Integer
|
9
|
+
attribute :name, String
|
10
|
+
attribute :revenue_center, Boolean
|
11
|
+
attribute :updated_at, DateTime
|
12
|
+
attribute :use_count, Integer
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Entities
|
3
|
+
#
|
4
|
+
# A wrapper to Myfinance classification center
|
5
|
+
#
|
6
|
+
class ClassificationCenterCollection < Collection
|
7
|
+
def build_collection
|
8
|
+
response.parsed_body.each do |attributes|
|
9
|
+
collection.push(
|
10
|
+
Myfinance::Entities::ClassificationCenter.new(
|
11
|
+
attributes["classification_center"]
|
12
|
+
)
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Entities
|
3
|
+
class DepositAccount < Base
|
4
|
+
attribute :archive, Boolean
|
5
|
+
attribute :bank_account_id, Integer
|
6
|
+
attribute :created_at, DateTime
|
7
|
+
attribute :currency_id, Integer
|
8
|
+
attribute :deposit_account_type_id, Integer
|
9
|
+
attribute :description, String
|
10
|
+
attribute :entity_id, Integer
|
11
|
+
attribute :force_destroy, Boolean
|
12
|
+
attribute :id, Integer
|
13
|
+
attribute :imported_from_sync, Boolean
|
14
|
+
attribute :initial_balance, String
|
15
|
+
attribute :last_transaction_date, Date
|
16
|
+
attribute :name, String
|
17
|
+
attribute :sync_response, String
|
18
|
+
attribute :updated_at, DateTime
|
19
|
+
attribute :calculated_balance, String
|
20
|
+
attribute :logo_image_url, String
|
21
|
+
attribute :links, Array
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Entities
|
3
|
+
#
|
4
|
+
# a wrapper to Myfinance deposit account collection
|
5
|
+
#
|
6
|
+
class DepositAccountCollection < Collection
|
7
|
+
def build_collection
|
8
|
+
response.parsed_body.each do |attributes|
|
9
|
+
collection.push(Myfinance::Entities::DepositAccount.new(
|
10
|
+
attributes["deposit_account"])
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Entities
|
3
|
+
class Person < Base
|
4
|
+
attribute :account_id, Integer
|
5
|
+
attribute :address, String
|
6
|
+
attribute :address_number, Integer
|
7
|
+
attribute :city, String
|
8
|
+
attribute :complement, String
|
9
|
+
attribute :country, String
|
10
|
+
attribute :created_at, DateTime
|
11
|
+
attribute :customer, Boolean
|
12
|
+
attribute :email, String
|
13
|
+
attribute :excel_import_id, Integer
|
14
|
+
attribute :febraban_favored_code, Integer
|
15
|
+
attribute :febraban_name, String
|
16
|
+
attribute :federation_subscription_number, String
|
17
|
+
attribute :federation_subscription_number_only_numbers, Integer
|
18
|
+
attribute :federation_subscription_type_id, Integer
|
19
|
+
attribute :force_destroy, Boolean
|
20
|
+
attribute :guid, String
|
21
|
+
attribute :id, Integer
|
22
|
+
attribute :imported_from_sync, Boolean
|
23
|
+
attribute :interested_users_ids, Array
|
24
|
+
attribute :modified_by_sync, Boolean
|
25
|
+
attribute :name, String
|
26
|
+
attribute :neighborhood, String
|
27
|
+
attribute :note, String
|
28
|
+
attribute :person_type, String
|
29
|
+
attribute :phone, String
|
30
|
+
attribute :site, String
|
31
|
+
attribute :state, String
|
32
|
+
attribute :supplier, Boolean
|
33
|
+
attribute :updated_at, DateTime
|
34
|
+
attribute :use_count, Integer
|
35
|
+
attribute :zip_code, String
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Entities
|
3
|
+
#
|
4
|
+
# A wrapper to Myfinance people collection
|
5
|
+
#
|
6
|
+
class PersonCollection < Collection
|
7
|
+
def build_collection
|
8
|
+
response.parsed_body.each do |attributes|
|
9
|
+
collection.push(Myfinance::Entities::Person.new(attributes["person"]))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Resources
|
3
|
+
#
|
4
|
+
# A wrapper to Myfinance accounts API
|
5
|
+
#
|
6
|
+
# [API]
|
7
|
+
# Documentation: https://app.myfinance.com.br/docs/api/multiple_accounts
|
8
|
+
#
|
9
|
+
class Account < Base
|
10
|
+
#
|
11
|
+
# List all account of the user
|
12
|
+
#
|
13
|
+
# [API]
|
14
|
+
# Method: <tt>GET /accounts</tt>
|
15
|
+
#
|
16
|
+
# Documentation: https://app.myfinance.com.br/docs/api/multiple_accounts#get_index
|
17
|
+
#
|
18
|
+
def find_all
|
19
|
+
http.get("/accounts", body: {}) do |response|
|
20
|
+
respond_with_collection(response)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Resources
|
3
|
+
#
|
4
|
+
# A wrapper to Myfinance categories API
|
5
|
+
#
|
6
|
+
# [API]
|
7
|
+
# Documentation: https://sandbox.myfinance.com.br/docs/api/categories
|
8
|
+
#
|
9
|
+
class Category < Base
|
10
|
+
#
|
11
|
+
# List all categories
|
12
|
+
#
|
13
|
+
# [API]
|
14
|
+
# Method: <tt>GET /categories</tt>
|
15
|
+
#
|
16
|
+
# Documentation: https://sandbox.myfinance.com.br/docs/api/categories#get_index
|
17
|
+
#
|
18
|
+
def find_all
|
19
|
+
http.get("/categories", body: {}) do |response|
|
20
|
+
respond_with_collection(response)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Find a category
|
26
|
+
#
|
27
|
+
# [API]
|
28
|
+
# Method: <tt>GET /categories/:id</tt>
|
29
|
+
#
|
30
|
+
# Documentation: https://sandbox.myfinance.com.br/docs/api/categories#get_show
|
31
|
+
#
|
32
|
+
def find(id)
|
33
|
+
http.get("/categories/#{id}", body: {}) do |response|
|
34
|
+
respond_with_object response, "category"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# Creates a category
|
40
|
+
#
|
41
|
+
# [API]
|
42
|
+
# Method: <tt>POST /categories</tt>
|
43
|
+
#
|
44
|
+
# Documentation: https://sandbox.myfinance.com.br/docs/api/categories#post_create
|
45
|
+
#
|
46
|
+
def create(params)
|
47
|
+
http.post("/categories", body: { category: params }) do |response|
|
48
|
+
respond_with_object response, "category"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Updates a category
|
54
|
+
#
|
55
|
+
# [API]
|
56
|
+
# Method: <tt>PUT /categories/:id</tt>
|
57
|
+
#
|
58
|
+
# Documentation: https://sandbox.myfinance.com.br/docs/api/categories#put_update
|
59
|
+
#
|
60
|
+
def update(id, params = {})
|
61
|
+
http.put("/categories/#{id}", body: { category: params }) do |response|
|
62
|
+
respond_with_object response, "category"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
#
|
67
|
+
# Destroy a category
|
68
|
+
#
|
69
|
+
# [API]
|
70
|
+
# Method: <tt>DELETE /categories/:id</tt>
|
71
|
+
#
|
72
|
+
# Documentation: https://sandbox.myfinance.com.br/docs/api/categories#delete_destroy
|
73
|
+
#
|
74
|
+
def destroy(id)
|
75
|
+
http.delete("/categories/#{id}", body: {}) do |response|
|
76
|
+
respond_with_object response, "category"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Resources
|
3
|
+
#
|
4
|
+
# A wrapper to Myfinance classification center API
|
5
|
+
#
|
6
|
+
# [API]
|
7
|
+
# Documentation: https://app.myfinance.com.br/docs/api/classification_centers
|
8
|
+
#
|
9
|
+
class ClassificationCenter < Base
|
10
|
+
#
|
11
|
+
# List all classification centers
|
12
|
+
#
|
13
|
+
# [API]
|
14
|
+
# Method: <tt>GET /classification_centers</tt>
|
15
|
+
#
|
16
|
+
# Documentation: https://app.myfinance.com.br/docs/api/classification_centers#get_index
|
17
|
+
#
|
18
|
+
def find_all
|
19
|
+
http.get("/classification_centers", body: {}) do |response|
|
20
|
+
respond_with_collection(response)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Show a classification center
|
26
|
+
#
|
27
|
+
# [API]
|
28
|
+
# Method: <tt>GET /classification_centers/:id</tt>
|
29
|
+
#
|
30
|
+
# Documentation: https://app.myfinance.com.br/docs/api/classification_centers#get_show
|
31
|
+
#
|
32
|
+
def find(id)
|
33
|
+
http.get("/classification_centers/#{id}", body: {}) do |response|
|
34
|
+
respond_with_object response, "classification_center"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# Find classification centers by attributtes
|
40
|
+
#
|
41
|
+
# [API]
|
42
|
+
# Method: <tt>GET /classification_centers</tt>
|
43
|
+
#
|
44
|
+
# Documentation: https://app.myfinance.com.br/docs/api/classification_centers
|
45
|
+
#
|
46
|
+
def find_by(params)
|
47
|
+
values = params.map { |k,v| "search[#{k}]=#{v}" }.join("&")
|
48
|
+
http.get(
|
49
|
+
"/classification_centers?#{values.gsub(%r/\s/, '+')}", body: {}
|
50
|
+
) do |response|
|
51
|
+
respond_with_collection(response)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# Creates a classification center
|
57
|
+
#
|
58
|
+
# [API]
|
59
|
+
# Method: <tt>POST /classification_centers</tt>
|
60
|
+
#
|
61
|
+
# Documentation: https://app.myfinance.com.br/docs/api/classification_centers#post_create
|
62
|
+
#
|
63
|
+
def create(params)
|
64
|
+
http.post(
|
65
|
+
"/classification_centers", body: { classification_center: params }
|
66
|
+
) do |response|
|
67
|
+
respond_with_object response, "classification_center"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
#
|
72
|
+
# Updates a classification center
|
73
|
+
#
|
74
|
+
# [API]
|
75
|
+
# Method: <tt>PUT /classification_centers/:id</tt>
|
76
|
+
#
|
77
|
+
# Documentation: https://app.myfinance.com.br/docs/api/classification_centers#put_update
|
78
|
+
#
|
79
|
+
def update(id, params)
|
80
|
+
http.put(
|
81
|
+
"/classification_centers/#{id}",
|
82
|
+
body: { classification_center: params }
|
83
|
+
) do |response|
|
84
|
+
respond_with_object response, "classification_center"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
#
|
89
|
+
# Destroy a classification center
|
90
|
+
#
|
91
|
+
# [API]
|
92
|
+
# Method: <tt>DELETE /classification_centers/:id</tt>
|
93
|
+
#
|
94
|
+
# Documentation: https://app.myfinance.com.br/docs/api/classification_centers#delete_destroy
|
95
|
+
#
|
96
|
+
def destroy(id)
|
97
|
+
http.delete("/classification_centers/#{id}", body: {}) do |response|
|
98
|
+
respond_with_object response, "classification_center"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Resources
|
3
|
+
#
|
4
|
+
# A wrapper to Myfinance deposit accounts API
|
5
|
+
#
|
6
|
+
# [API]
|
7
|
+
# Documentation: https://app.myfinance.com.br/docs/api/deposit_accounts
|
8
|
+
#
|
9
|
+
class DepositAccount < Base
|
10
|
+
#
|
11
|
+
# List all deposit accounts of entity
|
12
|
+
#
|
13
|
+
# [API]
|
14
|
+
# Method: <tt>GET /entities/:entity_id/deposit_accounts</tt>
|
15
|
+
#
|
16
|
+
# Documentation: https://app.myfinance.com.br/docs/api/deposit_accounts#get_index
|
17
|
+
#
|
18
|
+
def find_all(entity_id)
|
19
|
+
http.get(
|
20
|
+
"/entities/#{entity_id}/deposit_accounts", body: {}
|
21
|
+
) do |response|
|
22
|
+
respond_with_collection(response)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# List a deposit account of entity
|
28
|
+
#
|
29
|
+
# [API]
|
30
|
+
# Method: <tt>GET /entities/:entity_id/deposit_accounts/:id</tt>
|
31
|
+
#
|
32
|
+
# Documentation: https://app.myfinance.com.br/docs/api/deposit_accounts#get_show
|
33
|
+
#
|
34
|
+
def find(entity_id, id)
|
35
|
+
http.get(
|
36
|
+
"/entities/#{entity_id}/deposit_accounts/#{id}", body: {}
|
37
|
+
) do |response|
|
38
|
+
respond_with_object(response, "deposit_account")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# Creates a deposit account of entity
|
44
|
+
#
|
45
|
+
# [API]
|
46
|
+
# Method: <tt>POST /entities/:entity_id/deposit_accounts</tt>
|
47
|
+
#
|
48
|
+
# Documentation: https://app.myfinance.com.br/docs/api/deposit_accounts#post_create
|
49
|
+
#
|
50
|
+
def create(entity_id, params = {})
|
51
|
+
http.post(
|
52
|
+
"/entities/#{entity_id}/deposit_accounts",
|
53
|
+
body: { deposit_account: params }
|
54
|
+
) do |response|
|
55
|
+
respond_with_object(response, "deposit_account")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# Updates a deposit account of entity
|
61
|
+
#
|
62
|
+
# [API]
|
63
|
+
# Method: <tt>PUT /entities/:entity_id/deposit_accounts/:id</tt>
|
64
|
+
#
|
65
|
+
# Documentation: https://app.myfinance.com.br/docs/api/deposit_accounts#put_update
|
66
|
+
#
|
67
|
+
def update(entity_id, id, params = {})
|
68
|
+
http.put(
|
69
|
+
"/entities/#{entity_id}/deposit_accounts/#{id}",
|
70
|
+
body: { deposit_account: params }
|
71
|
+
) do |response|
|
72
|
+
respond_with_object(response, "deposit_account")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
#
|
77
|
+
# Destroy a deposit account of entity
|
78
|
+
#
|
79
|
+
# [API]
|
80
|
+
# Method: <tt>DELETE /entities/:entity_id/deposit_accounts/:id</tt>
|
81
|
+
#
|
82
|
+
# Documentation: https://app.myfinance.com.br/docs/api/deposit_accounts#delete_destroy
|
83
|
+
#
|
84
|
+
def destroy(entity_id, id)
|
85
|
+
http.delete(
|
86
|
+
"/entities/#{entity_id}/deposit_accounts/#{id}", body: {}
|
87
|
+
) do |response|
|
88
|
+
respond_with_object(response, "deposit_account")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|