freee 0.3.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +25 -1
- data/freee.gemspec +2 -0
- data/lib/freee/{account.rb → account_item.rb} +3 -3
- data/lib/freee/base.rb +13 -2
- data/lib/freee/company.rb +4 -0
- data/lib/freee/deal.rb +4 -2
- data/lib/freee/item.rb +4 -2
- data/lib/freee/obj/account_item.rb +5 -0
- data/lib/freee/obj/response.rb +1 -1
- data/lib/freee/obj/{account.rb → section.rb} +1 -1
- data/lib/freee/obj/{wallet.rb → tag.rb} +1 -1
- data/lib/freee/obj/{amount.rb → wallet_txn.rb} +1 -1
- data/lib/freee/partner.rb +4 -2
- data/lib/freee/section.rb +15 -0
- data/lib/freee/tag.rb +15 -0
- data/lib/freee/tax.rb +2 -2
- data/lib/freee/transfer.rb +4 -2
- data/lib/freee/version.rb +1 -1
- data/lib/freee/{wallet.rb → wallet_txn.rb} +5 -4
- data/lib/freee/walletable.rb +6 -0
- data/spec/account_item_spec.rb +44 -0
- data/spec/base_spec.rb +3 -9
- data/spec/company_spec.rb +53 -36
- data/spec/deal_spec.rb +150 -93
- data/spec/fixtures/account_items.json +20 -0
- data/spec/fixtures/companies.json +11 -0
- data/spec/fixtures/company.json +13 -0
- data/spec/fixtures/create_deal.json +1 -0
- data/spec/fixtures/create_item.json +6 -0
- data/spec/fixtures/create_partner.json +1 -0
- data/spec/fixtures/create_section.json +1 -0
- data/spec/fixtures/create_tag.json +1 -0
- data/spec/fixtures/create_transfer.json +1 -0
- data/spec/fixtures/create_wallet_txn.json +11 -0
- data/spec/fixtures/create_walletable.json +1 -0
- data/spec/fixtures/deal.json +34 -0
- data/spec/fixtures/deals.json +36 -0
- data/spec/fixtures/item.json +9 -0
- data/spec/fixtures/items.json +11 -0
- data/spec/fixtures/partner.json +9 -0
- data/spec/fixtures/partners.json +11 -0
- data/spec/fixtures/section.json +9 -0
- data/spec/fixtures/sections.json +11 -0
- data/spec/fixtures/tag.json +9 -0
- data/spec/fixtures/tags.json +11 -0
- data/spec/fixtures/taxes.json +8 -0
- data/spec/fixtures/taxes_with_code.json +9 -0
- data/spec/fixtures/transfer.json +13 -0
- data/spec/fixtures/transfers.json +37 -0
- data/spec/fixtures/user.json +10 -0
- data/spec/fixtures/user_with_companies.json +19 -0
- data/spec/fixtures/wallet_txn.json +14 -0
- data/spec/fixtures/wallet_txns.json +16 -0
- data/spec/fixtures/walletable.json +1 -0
- data/spec/fixtures/walletables.json +9 -0
- data/spec/item_spec.rb +74 -21
- data/spec/partner_spec.rb +59 -21
- data/spec/section_spec.rb +68 -0
- data/spec/setenv_spec.rb +0 -4
- data/spec/spec_helper.rb +41 -3
- data/spec/tag_spec.rb +68 -0
- data/spec/tax_spec.rb +63 -22
- data/spec/transfer_spec.rb +89 -34
- data/spec/user_spec.rb +47 -20
- data/spec/util_spec.rb +19 -10
- data/spec/wallet_txn_spec.rb +88 -0
- data/spec/walletable_spec.rb +74 -24
- metadata +109 -15
- data/lib/freee/amount.rb +0 -7
- data/spec/account_spec.rb +0 -34
- data/spec/amount_spec.rb +0 -26
- data/spec/wallet_spec.rb +0 -89
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"transfer" : {
|
3
|
+
"id" : 101,
|
4
|
+
"company_id" : -1,
|
5
|
+
"date" : "2013-01-01",
|
6
|
+
"amount" : 5000,
|
7
|
+
"from_walletable_type" : "bank_account",
|
8
|
+
"from_walletable_id" : 101,
|
9
|
+
"to_walletable_type" : "credit_card",
|
10
|
+
"to_walletable_id" : 201,
|
11
|
+
"description" : "備考"
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
{
|
2
|
+
"transfers" : [
|
3
|
+
{
|
4
|
+
"id" : 101,
|
5
|
+
"company_id" : 1,
|
6
|
+
"date" : "2013-01-01",
|
7
|
+
"amount" : 5000,
|
8
|
+
"from_walletable_type" : "bank_account",
|
9
|
+
"from_walletable_id" : 101,
|
10
|
+
"to_walletable_type" : "credit_card",
|
11
|
+
"to_walletable_id" : 201,
|
12
|
+
"description" : "備考"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"id" : 102,
|
16
|
+
"company_id" : 1,
|
17
|
+
"date" : "2013-02-01",
|
18
|
+
"amount" : 5000,
|
19
|
+
"from_walletable_type" : "bank_account",
|
20
|
+
"from_walletable_id" : 101,
|
21
|
+
"to_walletable_type" : "credit_card",
|
22
|
+
"to_walletable_id" : 201,
|
23
|
+
"description" : "備考"
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"id" : 103,
|
27
|
+
"company_id" : 1,
|
28
|
+
"date" : "2013-03-01",
|
29
|
+
"amount" : 5000,
|
30
|
+
"from_walletable_type" : "bank_account",
|
31
|
+
"from_walletable_id" : 101,
|
32
|
+
"to_walletable_type" : "credit_card",
|
33
|
+
"to_walletable_id" : 201,
|
34
|
+
"description" : "備考"
|
35
|
+
}
|
36
|
+
]
|
37
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"user" : {
|
3
|
+
"email" : "example@freee.co.jp",
|
4
|
+
"display_name" : "フリー太郎",
|
5
|
+
"first_name" : "太郎",
|
6
|
+
"last_name" : "フリー",
|
7
|
+
"first_name_kana" : "たろう",
|
8
|
+
"last_name_kana" : "ふりー",
|
9
|
+
"companies" : [
|
10
|
+
{
|
11
|
+
"id" : 101,
|
12
|
+
"name" : "freee事務所",
|
13
|
+
"name_kana" : "フリージムショ",
|
14
|
+
"display_name" : "freee事務所",
|
15
|
+
"role" : "admin"
|
16
|
+
}
|
17
|
+
]
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"wallet_txn" : {
|
3
|
+
"id" : 101,
|
4
|
+
"company_id" : 1,
|
5
|
+
"date" : "2013-01-01",
|
6
|
+
"amount" : 5000,
|
7
|
+
"due_amount" : 0,
|
8
|
+
"balance" : 10000,
|
9
|
+
"entry_side" : "income",
|
10
|
+
"walletable_type" : "bank_account",
|
11
|
+
"walletable_id" : 101,
|
12
|
+
"description" : "振込 カ)ABC"
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"wallet_txns" : [
|
3
|
+
{
|
4
|
+
"id" : 101,
|
5
|
+
"company_id" : 1,
|
6
|
+
"date" : "2013-01-01",
|
7
|
+
"amount" : 5000,
|
8
|
+
"due_amount" : 0,
|
9
|
+
"balance" : 10000,
|
10
|
+
"entry_side" : "income",
|
11
|
+
"walletable_type" : "bank_account",
|
12
|
+
"walletable_id" : 101,
|
13
|
+
"description" : "振込 カ)ABC"
|
14
|
+
}
|
15
|
+
]
|
16
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":10,"name":"〇〇銀行","type":"bank_account"}
|
data/spec/item_spec.rb
CHANGED
@@ -1,30 +1,83 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Freee::Item do
|
4
|
-
let(:client_id) { get_client_id }
|
5
|
-
let(:secret_key) { get_secret_key }
|
6
|
-
let(:token) { get_token }
|
7
|
-
let(:company_id) { get_company_id }
|
8
|
-
let(:item) { Freee::Item }
|
9
|
-
|
10
|
-
before(:each) do
|
11
|
-
Freee::Base.config(client_id, secret_key, token)
|
12
|
-
end
|
13
4
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
5
|
+
let(:company_id) { -1 }
|
6
|
+
let(:params) { fixture('create_deal.json') }
|
7
|
+
let(:json) { { params: params } }
|
8
|
+
|
9
|
+
before do
|
10
|
+
Freee::Base.config(get_client_id, get_secret_key, get_token)
|
11
|
+
@client = Freee::Item
|
18
12
|
end
|
19
13
|
|
20
|
-
describe '
|
21
|
-
|
14
|
+
describe 'item' do
|
15
|
+
context '#list' do
|
16
|
+
before do
|
17
|
+
stub_get('/api/1/items?company_id=-1').to_return(body: fixture('items.json'), headers: {content_type: 'application/json; charset=utf-8'} )
|
18
|
+
@responses = @client.list(company_id)
|
19
|
+
end
|
20
|
+
after { WebMock.reset! }
|
21
|
+
|
22
|
+
it 'requests the correct resource' do
|
23
|
+
assert_request_requested a_get('/api/1/items?company_id=-1')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should can be able to create instance' do
|
27
|
+
expect(@responses).to include('items')
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'should can be able to create instance' do
|
31
|
+
subject { @responses }
|
32
|
+
|
33
|
+
it { is_expected.not_to be_nil }
|
34
|
+
it { is_expected.to be_instance_of(Freee::Response::Item) }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'should get information of first item for the company' do
|
38
|
+
subject { @responses['items'].first }
|
39
|
+
|
40
|
+
it { is_expected.not_to be_nil }
|
41
|
+
it { is_expected.to include('id') }
|
42
|
+
it { is_expected.to include('company_id') }
|
43
|
+
it { is_expected.to include('name') }
|
44
|
+
it { is_expected.to include('shortcut1') }
|
45
|
+
it { is_expected.to include('shortcut2') }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context '#create' do
|
50
|
+
before do
|
51
|
+
stub_post('/api/1/items').
|
52
|
+
with(body: json).
|
53
|
+
to_return(body: fixture('item.json'), headers: {content_type: 'application/json; charset=utf-8'} )
|
54
|
+
@responses = @client.create(params)
|
55
|
+
end
|
56
|
+
after { WebMock.reset! }
|
57
|
+
|
58
|
+
it 'requests the correct resource' do
|
59
|
+
assert_request_requested a_post('/api/1/items').with(body: json)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should can be able to create instance' do
|
63
|
+
expect(@responses).to include('item')
|
64
|
+
end
|
65
|
+
|
66
|
+
describe 'should can be able to create instance' do
|
67
|
+
subject { @responses }
|
68
|
+
it { is_expected.to be_instance_of(Freee::Response::Item) }
|
69
|
+
end
|
70
|
+
|
71
|
+
describe 'should get information of first item for the company' do
|
72
|
+
subject { @responses['item'] }
|
22
73
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
74
|
+
it { is_expected.not_to be_nil }
|
75
|
+
it { is_expected.to include('id') }
|
76
|
+
it { is_expected.to include('company_id') }
|
77
|
+
it { is_expected.to include('name') }
|
78
|
+
it { is_expected.to include('shortcut1') }
|
79
|
+
it { is_expected.to include('shortcut2') }
|
80
|
+
end
|
81
|
+
end
|
29
82
|
end
|
30
83
|
end
|
data/spec/partner_spec.rb
CHANGED
@@ -1,30 +1,68 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Freee::Partner do
|
4
|
-
let(:client_id) { get_client_id }
|
5
|
-
let(:secret_key) { get_secret_key }
|
6
|
-
let(:token) { get_token }
|
7
|
-
let(:company_id) { get_company_id }
|
8
|
-
let(:partner) { Freee::Partner }
|
9
|
-
|
10
|
-
before(:each) do
|
11
|
-
Freee::Base.config(client_id, secret_key, token)
|
12
|
-
end
|
13
4
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
5
|
+
let(:company_id) { -1 }
|
6
|
+
let(:params) { fixture('create_partner.json') }
|
7
|
+
let(:json) { { params: params } }
|
8
|
+
|
9
|
+
before do
|
10
|
+
Freee::Base.config(get_client_id, get_secret_key, get_token)
|
11
|
+
@client = Freee::Partner
|
18
12
|
end
|
13
|
+
describe 'partner' do
|
14
|
+
context '#list' do
|
15
|
+
before do
|
16
|
+
stub_get('/api/1/partners?company_id=-1').to_return(body: fixture('partners.json'), headers: {content_type: 'application/json; charset=utf-8'} )
|
17
|
+
@responses = @client.list(company_id)
|
18
|
+
end
|
19
|
+
after { WebMock.reset! }
|
20
|
+
|
21
|
+
describe 'should can be able to create instance' do
|
22
|
+
subject { @responses }
|
23
|
+
|
24
|
+
it { is_expected.not_to be_nil }
|
25
|
+
it { is_expected.to be_instance_of(Freee::Response::Partner) }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'should get partners of first item for the company' do
|
29
|
+
subject { @responses['partners'].first }
|
30
|
+
|
31
|
+
it { is_expected.not_to be_nil }
|
32
|
+
it { is_expected.to include('id') }
|
33
|
+
it { is_expected.to include('company_id') }
|
34
|
+
it { is_expected.to include('name') }
|
35
|
+
it { is_expected.to include('shortcut1') }
|
36
|
+
it { is_expected.to include('shortcut2') }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context '#create' do
|
41
|
+
before do
|
42
|
+
stub_post('/api/1/partners').
|
43
|
+
with(body: json).
|
44
|
+
to_return(body: fixture('partner.json'), headers: {content_type: 'application/json; charset=utf-8'} )
|
45
|
+
@responses = @client.create(params)
|
46
|
+
end
|
47
|
+
after { WebMock.reset! }
|
48
|
+
|
49
|
+
describe 'should can be able to create instance' do
|
50
|
+
subject { @responses }
|
51
|
+
|
52
|
+
it { is_expected.not_to be_nil }
|
53
|
+
it { is_expected.to be_instance_of(Freee::Response::Partner) }
|
54
|
+
end
|
19
55
|
|
20
|
-
|
21
|
-
|
56
|
+
describe 'should get partners of first item for the company' do
|
57
|
+
subject { @responses['partner'] }
|
22
58
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
59
|
+
it { is_expected.not_to be_nil }
|
60
|
+
it { is_expected.to include('id') }
|
61
|
+
it { is_expected.to include('company_id') }
|
62
|
+
it { is_expected.to include('name') }
|
63
|
+
it { is_expected.to include('shortcut1') }
|
64
|
+
it { is_expected.to include('shortcut2') }
|
65
|
+
end
|
66
|
+
end
|
29
67
|
end
|
30
68
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Freee::Section do
|
4
|
+
|
5
|
+
let(:company_id) { -1 }
|
6
|
+
let(:params) { fixture('create_section.json') }
|
7
|
+
let(:json) { { params: params } }
|
8
|
+
|
9
|
+
before do
|
10
|
+
Freee::Base.config(get_client_id, get_secret_key, get_token)
|
11
|
+
@client = Freee::Section
|
12
|
+
end
|
13
|
+
describe 'section' do
|
14
|
+
context '#list' do
|
15
|
+
before do
|
16
|
+
stub_get('/api/1/sections?company_id=-1').to_return(body: fixture('sections.json'), headers: {content_type: 'application/json; charset=utf-8'} )
|
17
|
+
@responses = @client.list(company_id)
|
18
|
+
end
|
19
|
+
after { WebMock.reset! }
|
20
|
+
|
21
|
+
describe 'should can be able to create instance' do
|
22
|
+
subject { @responses }
|
23
|
+
|
24
|
+
it { is_expected.not_to be_nil }
|
25
|
+
it { is_expected.to be_instance_of(Freee::Response::Section) }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'should get sections of first item for the company' do
|
29
|
+
subject { @responses['sections'].first }
|
30
|
+
|
31
|
+
it { is_expected.not_to be_nil }
|
32
|
+
it { is_expected.to include('id') }
|
33
|
+
it { is_expected.to include('company_id') }
|
34
|
+
it { is_expected.to include('name') }
|
35
|
+
it { is_expected.to include('shortcut1') }
|
36
|
+
it { is_expected.to include('shortcut2') }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context '#create' do
|
41
|
+
before do
|
42
|
+
stub_post('/api/1/sections').
|
43
|
+
with(body: json).
|
44
|
+
to_return(body: fixture('section.json'), headers: {content_type: 'application/json; charset=utf-8'} )
|
45
|
+
@responses = @client.create(params)
|
46
|
+
end
|
47
|
+
after { WebMock.reset! }
|
48
|
+
|
49
|
+
describe 'should can be able to create instance' do
|
50
|
+
subject { @responses }
|
51
|
+
|
52
|
+
it { is_expected.not_to be_nil }
|
53
|
+
it { is_expected.to be_instance_of(Freee::Response::Section) }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe 'should get sections of first item for the company' do
|
57
|
+
subject { @responses['section'] }
|
58
|
+
|
59
|
+
it { is_expected.not_to be_nil }
|
60
|
+
it { is_expected.to include('id') }
|
61
|
+
it { is_expected.to include('company_id') }
|
62
|
+
it { is_expected.to include('name') }
|
63
|
+
it { is_expected.to include('shortcut1') }
|
64
|
+
it { is_expected.to include('shortcut2') }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|