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
data/lib/myfinance/version.rb
CHANGED
@@ -43,120 +43,23 @@ describe Myfinance::Client do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
it "instantiates a new Myfinance::Resources::ReceivableAccount" do
|
62
|
-
expect(Myfinance::Resources::ReceivableAccount).to receive(:new).with(subject.http)
|
63
|
-
subject.receivable_accounts
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "#attachments" do
|
68
|
-
it "instantiates a new Myfinance::Resources::Attachment" do
|
69
|
-
expect(Myfinance::Resources::Attachment).to receive(:new).with(subject.http)
|
70
|
-
subject.attachments
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe "#classification_centers" do
|
75
|
-
it "instantiates a new Myfinance::Resources::ClassificationCenter" do
|
76
|
-
expect(
|
77
|
-
Myfinance::Resources::ClassificationCenter
|
78
|
-
).to receive(:new).with(subject.http)
|
79
|
-
subject.classification_centers
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "#categories" do
|
84
|
-
it "instantiates a new Myfinance::Resources::Category" do
|
85
|
-
expect(Myfinance::Resources::Category).to receive(:new).with(subject.http)
|
86
|
-
subject.categories
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe "#accounts" do
|
91
|
-
it "instantiates a new Myfinance::Resources::Account" do
|
92
|
-
expect(Myfinance::Resources::Account).to receive(:new).with(subject.http)
|
93
|
-
subject.accounts
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "#financial_transactions" do
|
98
|
-
it "instantiates a new Myfinance::Resources::FinancialTransaction" do
|
99
|
-
expect(
|
100
|
-
Myfinance::Resources::FinancialTransaction
|
101
|
-
).to receive(:new).with(subject.http)
|
102
|
-
|
103
|
-
subject.financial_transactions
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe "#deposit_accounts" do
|
108
|
-
it "instantiates a new Myfinance::Resources::DepositAccount" do
|
109
|
-
expect(
|
110
|
-
Myfinance::Resources::DepositAccount
|
111
|
-
).to receive(:new).with(subject.http)
|
112
|
-
|
113
|
-
subject.deposit_accounts
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
describe "#people" do
|
118
|
-
it "instantiates a new Myfinance::Resources::Person" do
|
119
|
-
expect(Myfinance::Resources::Person).to receive(:new).with(subject.http)
|
120
|
-
subject.people
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
describe "#webhooks" do
|
125
|
-
it "instantiates a new Myfinance::Resources::Webhook" do
|
126
|
-
expect(Myfinance::Resources::Webhook).to receive(:new).with(subject.http)
|
127
|
-
subject.webhooks
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
describe "#taxes" do
|
132
|
-
it "instantiates a new Myfinance::Resources::Tax" do
|
133
|
-
expect(Myfinance::Resources::Tax).to receive(:new).with(subject.http)
|
134
|
-
subject.taxes
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
describe "#credit_cards" do
|
139
|
-
it "instantiates a new Myfinance::Resources::CreditCard" do
|
140
|
-
expect(Myfinance::Resources::CreditCard).to receive(:new).with(subject.http)
|
141
|
-
subject.credit_cards
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
describe "#credit_card_transactions" do
|
146
|
-
it "instantiates a new Myfinance::Resources::CreditCardTransaction" do
|
147
|
-
expect(Myfinance::Resources::CreditCardTransaction).to receive(:new).with(subject.http)
|
148
|
-
subject.credit_card_transactions
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
describe "#reconciles" do
|
153
|
-
it "instantiates a new Myfinance::Resources::Reconcile" do
|
154
|
-
expect(Myfinance::Resources::Reconcile).to receive(:new).with(subject.http)
|
155
|
-
subject.reconciles
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
46
|
+
include_examples :resource, :entities, Myfinance::Resources::Entity
|
47
|
+
include_examples :resource, :payable_accounts, Myfinance::Resources::PayableAccount
|
48
|
+
include_examples :resource, :receivable_accounts, Myfinance::Resources::ReceivableAccount
|
49
|
+
include_examples :resource, :attachments, Myfinance::Resources::Attachment
|
50
|
+
include_examples :resource, :classification_centers, Myfinance::Resources::ClassificationCenter
|
51
|
+
include_examples :resource, :categories, Myfinance::Resources::Category
|
52
|
+
include_examples :resource, :accounts, Myfinance::Resources::Account
|
53
|
+
include_examples :resource, :financial_transactions, Myfinance::Resources::FinancialTransaction
|
54
|
+
include_examples :resource, :deposit_accounts, Myfinance::Resources::DepositAccount
|
55
|
+
include_examples :resource, :people, Myfinance::Resources::Person
|
56
|
+
include_examples :resource, :webhooks, Myfinance::Resources::Webhook
|
57
|
+
include_examples :resource, :taxes, Myfinance::Resources::Tax
|
58
|
+
include_examples :resource, :credit_cards, Myfinance::Resources::CreditCard
|
59
|
+
include_examples :resource, :credit_card_transactions, Myfinance::Resources::CreditCardTransaction
|
60
|
+
include_examples :resource, :reconciles, Myfinance::Resources::Reconcile
|
159
61
|
include_examples :resource, :sales, Myfinance::Resources::Sale
|
160
62
|
include_examples :resource, :sale_accounts, Myfinance::Resources::SaleAccount
|
161
63
|
include_examples :resource, :sale_rules, Myfinance::Resources::SaleRule
|
64
|
+
include_examples :resource, :custom_classifiers, Myfinance::Resources::CustomClassifier
|
162
65
|
end
|
@@ -1,19 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Myfinance::Entities::AccountCollection do
|
4
|
-
|
5
|
-
|
6
|
-
subject { described_class.new(response) }
|
7
|
-
|
8
|
-
describe "#build" do
|
9
|
-
it "returns orders collection" do
|
10
|
-
expect(subject.build).to be_a(Myfinance::Entities::AccountCollection)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "returns orders" do
|
14
|
-
subject.build
|
15
|
-
expect(subject.collection.count).to eq(1)
|
16
|
-
expect(subject.collection.first.class).to eq(Myfinance::Entities::Account)
|
17
|
-
end
|
18
|
-
end
|
4
|
+
it_behaves_like :entity_collection, Myfinance::Entities::Account
|
19
5
|
end
|
@@ -1,20 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Myfinance::Entities::AttachmentCollection do
|
4
|
-
|
5
|
-
parsed_body: [{"attachment" => {"id" => 12,"entity_id" => 1,"title" => "","attachment_file_name" => "extratoPoup.ofx","attachment_content_type" => "application/octet-stream","attachment_file_size" => 5517,"created_at" => "2011-11-10T15:52:59-02:00","updated_at" => "2011-11-10T15:52:59-02:00","download_url" => "https://app.myfinance.com.br/entities/1/attachments/12/download","attachables" => [],"links" => []}}]) }
|
6
|
-
|
7
|
-
subject { Myfinance::Entities::AttachmentCollection.new(response) }
|
8
|
-
|
9
|
-
describe '#build' do
|
10
|
-
it 'returns order collection' do
|
11
|
-
expect(subject.build.class).to eq(Myfinance::Entities::AttachmentCollection)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "returns orders" do
|
15
|
-
subject.build
|
16
|
-
expect(subject.collection.count).to eq(1)
|
17
|
-
expect(subject.collection.first.class).to eq(Myfinance::Entities::Attachment)
|
18
|
-
end
|
19
|
-
end
|
4
|
+
it_behaves_like :entity_collection, Myfinance::Entities::Attachment
|
20
5
|
end
|
@@ -1,47 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Myfinance::Entities::CategoryCollection do
|
4
|
-
|
5
|
-
|
6
|
-
let(:response) do
|
7
|
-
double(
|
8
|
-
headers: {},
|
9
|
-
parsed_body: [
|
10
|
-
{
|
11
|
-
"category" => {
|
12
|
-
"account_id" => 3613,
|
13
|
-
"cost" => true,
|
14
|
-
"created_at" => "2015-07-29T11:04:50-03:00",
|
15
|
-
"excel_import_id" => nil,
|
16
|
-
"force_destroy" => false,
|
17
|
-
"full_name" => "Alimentação",
|
18
|
-
"guid" => nil,
|
19
|
-
"id" => 532314,
|
20
|
-
"imported_from_sync" => false,
|
21
|
-
"interested_users_ids" => [],
|
22
|
-
"modified_by_sync" => false,
|
23
|
-
"name" => "Alimentação",
|
24
|
-
"parent_id" => nil,
|
25
|
-
"revenue" => true,
|
26
|
-
"updated_at" => "2015-07-29T11:04:50-03:00",
|
27
|
-
"use_count" => 0
|
28
|
-
}
|
29
|
-
}
|
30
|
-
]
|
31
|
-
)
|
32
|
-
end
|
33
|
-
|
34
|
-
subject { Myfinance::Entities::CategoryCollection.new(response) }
|
35
|
-
|
36
|
-
describe "#build" do
|
37
|
-
it "returns order collection" do
|
38
|
-
expect(subject.build.class).to eq(Myfinance::Entities::CategoryCollection)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "returns order" do
|
42
|
-
subject.build
|
43
|
-
expect(subject.collection.count).to eq(1)
|
44
|
-
expect(subject.collection.first.class).to eq(entity_klass)
|
45
|
-
end
|
46
|
-
end
|
4
|
+
it_behaves_like :entity_collection, Myfinance::Entities::Category
|
47
5
|
end
|
@@ -1,23 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Myfinance::Entities::ClassificationCenterCollection do
|
4
|
-
|
5
|
-
|
6
|
-
let(:params) { double(headers: {}, parsed_body: [{}]) }
|
7
|
-
|
8
|
-
subject { described_class.new(params) }
|
9
|
-
|
10
|
-
context "#build" do
|
11
|
-
it "returns order collection" do
|
12
|
-
expect(subject.build).to be_a(entity_klass)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "returns order" do
|
16
|
-
subject.build
|
17
|
-
expect(subject.collection.count).to eq(1)
|
18
|
-
expect(
|
19
|
-
subject.collection.first
|
20
|
-
).to be_a(Myfinance::Entities::ClassificationCenter)
|
21
|
-
end
|
22
|
-
end
|
4
|
+
it_behaves_like :entity_collection, Myfinance::Entities::ClassificationCenter
|
23
5
|
end
|
@@ -1,23 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Myfinance::Entities::CreditCardCollection do
|
4
|
-
|
5
|
-
|
6
|
-
let(:params) { double(headers: {}, parsed_body: [{}]) }
|
7
|
-
|
8
|
-
subject { described_class.new(params) }
|
9
|
-
|
10
|
-
context "#build" do
|
11
|
-
it "returns order collection" do
|
12
|
-
expect(subject.build).to be_a(entity_klass)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "returns order" do
|
16
|
-
subject.build
|
17
|
-
expect(subject.collection.count).to eq(1)
|
18
|
-
expect(
|
19
|
-
subject.collection.first
|
20
|
-
).to be_a(Myfinance::Entities::CreditCard)
|
21
|
-
end
|
22
|
-
end
|
4
|
+
it_behaves_like :entity_collection, Myfinance::Entities::CreditCard
|
23
5
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Myfinance::Entities::CreditCard do
|
4
|
-
it_behaves_like "entity_attributes", [
|
5
|
-
|
6
|
-
|
4
|
+
it_behaves_like "entity_attributes", %i[created_at id name updated_at entity_id person_id flag
|
5
|
+
flag_image_url observation classification_center_id category_id
|
6
|
+
closing_day expiration_day custom_classifications]
|
7
7
|
end
|
@@ -1,21 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Myfinance::Entities::CreditCardTransactionCollection do
|
4
|
-
|
5
|
-
|
6
|
-
let(:params) { double(headers: {}, parsed_body: [{}]) }
|
7
|
-
|
8
|
-
subject { described_class.new(params) }
|
9
|
-
|
10
|
-
context "#build" do
|
11
|
-
it "returns order collection" do
|
12
|
-
expect(subject.build).to be_a(entity_klass)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "returns order" do
|
16
|
-
subject.build
|
17
|
-
expect(subject.collection.count).to eq(1)
|
18
|
-
expect(subject.collection.first).to be_a(Myfinance::Entities::CreditCardTransaction)
|
19
|
-
end
|
20
|
-
end
|
4
|
+
it_behaves_like :entity_collection, Myfinance::Entities::CreditCardTransaction
|
21
5
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Myfinance::Entities::CreditCardTransaction do
|
4
|
-
it_behaves_like "entity_attributes", [
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
it_behaves_like "entity_attributes", %i[credit_card_invoice_id classification_center_id category_id amount
|
5
|
+
description occurred_at type document observation created_at
|
6
|
+
updated_at invoice_payment excel_import_id financial_account_id
|
7
|
+
person_id moved recurrence_id indexed_at credit_card_id id
|
8
|
+
custom_classifications]
|
8
9
|
end
|
@@ -1,23 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Myfinance::Entities::DepositAccountCollection do
|
4
|
-
|
5
|
-
|
6
|
-
let(:params) { double(headers: {}, parsed_body: [{}]) }
|
7
|
-
|
8
|
-
subject { entity_klass.new(params) }
|
9
|
-
|
10
|
-
describe "#build" do
|
11
|
-
it "returns order collection" do
|
12
|
-
expect(subject.build).to be_a(entity_klass)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "returns order" do
|
16
|
-
subject.build
|
17
|
-
expect(subject.collection.count).to eq(1)
|
18
|
-
expect(subject.collection.first).to be_a(
|
19
|
-
Myfinance::Entities::DepositAccount
|
20
|
-
)
|
21
|
-
end
|
22
|
-
end
|
4
|
+
it_behaves_like :entity_collection, Myfinance::Entities::DepositAccount
|
23
5
|
end
|
@@ -1,23 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Myfinance::Entities::FinancialTransactionCollection do
|
4
|
-
|
5
|
-
|
6
|
-
let(:params) { double(headers: {}, parsed_body: [{}]) }
|
7
|
-
|
8
|
-
subject { described_class.new(params) }
|
9
|
-
|
10
|
-
context "#build" do
|
11
|
-
it "returns order collection" do
|
12
|
-
expect(subject.build).to be_a(entity_klass)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "returns order" do
|
16
|
-
subject.build
|
17
|
-
expect(subject.collection.count).to eq(1)
|
18
|
-
expect(
|
19
|
-
subject.collection.first
|
20
|
-
).to be_a(Myfinance::Entities::FinancialTransaction)
|
21
|
-
end
|
22
|
-
end
|
4
|
+
it_behaves_like :entity_collection, Myfinance::Entities::FinancialTransaction
|
23
5
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Myfinance::Entities::FinancialTransaction do
|
4
|
-
it_behaves_like "entity_attributes", [
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
it_behaves_like "entity_attributes", %i[deposit_account_id person_id parent_id owner_id currency_id
|
5
|
+
category_id type occurred_at document original_description
|
6
|
+
user_description notes amount id is_pending created_at
|
7
|
+
updated_at guid imported_from_sync transfer_id absolute_amount
|
8
|
+
bank_statement_id balance_difference force_destroy divided
|
9
|
+
attachments_count duplicity_suspicion_id excel_import_id
|
10
|
+
observation api_related bank_slips_count reconciled indexed_at
|
11
|
+
automatic_rule_related classification_center_id custom_classifications]
|
12
12
|
end
|