freee 0.3.1 → 1.0.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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +25 -1
  4. data/freee.gemspec +2 -0
  5. data/lib/freee/{account.rb → account_item.rb} +3 -3
  6. data/lib/freee/base.rb +13 -2
  7. data/lib/freee/company.rb +4 -0
  8. data/lib/freee/deal.rb +4 -2
  9. data/lib/freee/item.rb +4 -2
  10. data/lib/freee/obj/account_item.rb +5 -0
  11. data/lib/freee/obj/response.rb +1 -1
  12. data/lib/freee/obj/{account.rb → section.rb} +1 -1
  13. data/lib/freee/obj/{wallet.rb → tag.rb} +1 -1
  14. data/lib/freee/obj/{amount.rb → wallet_txn.rb} +1 -1
  15. data/lib/freee/partner.rb +4 -2
  16. data/lib/freee/section.rb +15 -0
  17. data/lib/freee/tag.rb +15 -0
  18. data/lib/freee/tax.rb +2 -2
  19. data/lib/freee/transfer.rb +4 -2
  20. data/lib/freee/version.rb +1 -1
  21. data/lib/freee/{wallet.rb → wallet_txn.rb} +5 -4
  22. data/lib/freee/walletable.rb +6 -0
  23. data/spec/account_item_spec.rb +44 -0
  24. data/spec/base_spec.rb +3 -9
  25. data/spec/company_spec.rb +53 -36
  26. data/spec/deal_spec.rb +150 -93
  27. data/spec/fixtures/account_items.json +20 -0
  28. data/spec/fixtures/companies.json +11 -0
  29. data/spec/fixtures/company.json +13 -0
  30. data/spec/fixtures/create_deal.json +1 -0
  31. data/spec/fixtures/create_item.json +6 -0
  32. data/spec/fixtures/create_partner.json +1 -0
  33. data/spec/fixtures/create_section.json +1 -0
  34. data/spec/fixtures/create_tag.json +1 -0
  35. data/spec/fixtures/create_transfer.json +1 -0
  36. data/spec/fixtures/create_wallet_txn.json +11 -0
  37. data/spec/fixtures/create_walletable.json +1 -0
  38. data/spec/fixtures/deal.json +34 -0
  39. data/spec/fixtures/deals.json +36 -0
  40. data/spec/fixtures/item.json +9 -0
  41. data/spec/fixtures/items.json +11 -0
  42. data/spec/fixtures/partner.json +9 -0
  43. data/spec/fixtures/partners.json +11 -0
  44. data/spec/fixtures/section.json +9 -0
  45. data/spec/fixtures/sections.json +11 -0
  46. data/spec/fixtures/tag.json +9 -0
  47. data/spec/fixtures/tags.json +11 -0
  48. data/spec/fixtures/taxes.json +8 -0
  49. data/spec/fixtures/taxes_with_code.json +9 -0
  50. data/spec/fixtures/transfer.json +13 -0
  51. data/spec/fixtures/transfers.json +37 -0
  52. data/spec/fixtures/user.json +10 -0
  53. data/spec/fixtures/user_with_companies.json +19 -0
  54. data/spec/fixtures/wallet_txn.json +14 -0
  55. data/spec/fixtures/wallet_txns.json +16 -0
  56. data/spec/fixtures/walletable.json +1 -0
  57. data/spec/fixtures/walletables.json +9 -0
  58. data/spec/item_spec.rb +74 -21
  59. data/spec/partner_spec.rb +59 -21
  60. data/spec/section_spec.rb +68 -0
  61. data/spec/setenv_spec.rb +0 -4
  62. data/spec/spec_helper.rb +41 -3
  63. data/spec/tag_spec.rb +68 -0
  64. data/spec/tax_spec.rb +63 -22
  65. data/spec/transfer_spec.rb +89 -34
  66. data/spec/user_spec.rb +47 -20
  67. data/spec/util_spec.rb +19 -10
  68. data/spec/wallet_txn_spec.rb +88 -0
  69. data/spec/walletable_spec.rb +74 -24
  70. metadata +109 -15
  71. data/lib/freee/amount.rb +0 -7
  72. data/spec/account_spec.rb +0 -34
  73. data/spec/amount_spec.rb +0 -26
  74. data/spec/wallet_spec.rb +0 -89
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+
3
+ describe Freee::WalletTxn do
4
+
5
+ let(:company_id) { -1 }
6
+ let(:params) { fixture('create_wallet_txn.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::WalletTxn
12
+ end
13
+
14
+ describe 'wallet_txn' do
15
+ context '#list' do
16
+ before do
17
+ stub_get('/api/1/wallet_txns?company_id=-1').to_return(body: fixture('wallet_txns.json'), headers: {content_type: 'application/json; charset=utf-8'} )
18
+ @responses = @client.list(company_id)
19
+ end
20
+ after { WebMock.reset! }
21
+
22
+ describe 'should can be able to create instance' do
23
+ subject { @responses }
24
+ it { is_expected.not_to be_nil }
25
+ it { is_expected.to be_instance_of(Freee::Response::WalletTxn) }
26
+ end
27
+
28
+ describe 'should get information of wallet txns for the company' do
29
+ subject { @responses }
30
+
31
+ it { is_expected.to include('wallet_txns') }
32
+ end
33
+
34
+ describe 'should get information of first wallet txns for the company' do
35
+ subject { @responses['wallet_txns'].first }
36
+
37
+ it { is_expected.not_to be_nil }
38
+ it { is_expected.to include('id') }
39
+ it { is_expected.to include('company_id') }
40
+ it { is_expected.to include('amount') }
41
+ it { is_expected.to include('balance') }
42
+ it { is_expected.to include('description') }
43
+ it { is_expected.to include('due_amount') }
44
+ it { is_expected.to include('date') }
45
+ it { is_expected.to include('entry_side') }
46
+ it { is_expected.to include('walletable_type') }
47
+ it { is_expected.to include('walletable_id') }
48
+ end
49
+ end
50
+
51
+ context '#create' do
52
+ before do
53
+ stub_post('/api/1/wallet_txns').
54
+ with(body: json).
55
+ to_return(body: fixture('wallet_txn.json'), headers: {content_type: 'application/json; charset=utf-8'} )
56
+ @responses = @client.create(params)
57
+ end
58
+ after { WebMock.reset! }
59
+
60
+ it 'requests the correct resource' do
61
+ assert_request_requested a_post('/api/1/wallet_txns').with(body: json)
62
+ end
63
+
64
+ it 'should can be able to create instance' do
65
+ expect(@responses).to include('wallet_txn')
66
+ end
67
+
68
+ describe 'should can be able to create instance' do
69
+ subject { @responses }
70
+ it { is_expected.not_to be_nil }
71
+ it { is_expected.to be_instance_of(Freee::Response::WalletTxn) }
72
+ end
73
+
74
+ describe "should set information of one's wallet txns" do
75
+ subject { @responses['wallet_txn'] }
76
+
77
+ it { is_expected.not_to be_nil }
78
+ it { is_expected.to include('id') }
79
+ it { is_expected.to include('company_id') }
80
+ it { is_expected.to include('walletable_id') }
81
+ it { is_expected.to include('date') }
82
+ it { is_expected.to include('walletable_type') }
83
+ it { is_expected.to include('amount') }
84
+ it { is_expected.to include('entry_side') }
85
+ end
86
+ end
87
+ end
88
+ end
@@ -1,35 +1,85 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Freee::Walletable 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(:walletable) { Freee::Walletable }
9
-
10
- before(:each) do
11
- Freee::Base.config(client_id, secret_key, token)
12
- end
13
4
 
14
- describe 'should can be able to create instance' do
15
- subject { walletable.list(company_id) }
16
- it { is_expected.not_to be_nil }
17
- it { is_expected.to be_instance_of(Freee::Response::Walletable) }
5
+ let(:company_id) { -1 }
6
+ let(:params) { fixture('create_walletable.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::Walletable
18
12
  end
19
13
 
20
- describe 'should get information of walletable for the company' do
21
- subject { walletable.list(company_id) }
14
+ describe 'walletable' do
15
+ context '#list' do
16
+ before do
17
+ stub_get('/api/1/walletables?company_id=-1').to_return(body: fixture('walletables.json'), headers: {content_type: 'application/json; charset=utf-8'} )
18
+ @responses = @client.list(company_id)
19
+ end
20
+ after { WebMock.reset! }
22
21
 
23
- it { is_expected.not_to be_nil }
24
- it { is_expected.to include('walletables') }
25
- end
22
+ it 'requests the correct resource' do
23
+ assert_request_requested a_get('/api/1/walletables?company_id=-1')
24
+ end
25
+
26
+ describe 'should can be able to create instance' do
27
+ subject { @responses }
28
+ it { is_expected.not_to be_nil }
29
+ it { is_expected.to be_instance_of(Freee::Response::Walletable) }
30
+ end
31
+
32
+ describe 'should get information of walletable for the company' do
33
+ subject { @responses }
34
+
35
+ it { is_expected.not_to be_nil }
36
+ it { is_expected.to include('walletables') }
37
+ end
38
+
39
+ describe 'should get information of first walletable for the company' do
40
+ subject { @responses['walletables'].first }
41
+
42
+ it { is_expected.not_to be_nil }
43
+ it { is_expected.to include('id') }
44
+ it { is_expected.to include('name') }
45
+ it { is_expected.to include('type') }
46
+ end
47
+ end
48
+
49
+ context '#create' do
50
+ before do
51
+ stub_post('/api/1/walletables').
52
+ with(body: json).
53
+ to_return(body: fixture('walletable.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/walletables').with(body: json)
60
+ end
61
+
62
+ describe 'should can be able to create instance' do
63
+ subject { @responses }
64
+ it { is_expected.not_to be_nil }
65
+ it { is_expected.to be_instance_of(Freee::Response::Walletable) }
66
+ end
67
+
68
+ describe 'should get information of walletable for the company' do
69
+ subject { @responses }
70
+
71
+ it { is_expected.not_to be_nil }
72
+ end
73
+
74
+ describe 'should get information of first walletable for the company' do
75
+ subject { @responses }
26
76
 
27
- describe 'should get information of first walletable for the company' do
28
- subject { walletable.list(company_id)['walletables'].first }
77
+ it { is_expected.not_to be_nil }
78
+ it { is_expected.to include('id') }
79
+ it { is_expected.to include('name') }
80
+ it { is_expected.to include('type') }
81
+ end
29
82
 
30
- it { is_expected.not_to be_nil }
31
- it { is_expected.to include('id') }
32
- it { is_expected.to include('name') }
33
- it { is_expected.to include('type') }
83
+ end
34
84
  end
35
85
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keiji Matsuzaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-04 00:00:00.000000000 Z
11
+ date: 2015-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rspec
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +150,20 @@ dependencies:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
152
  version: '3.0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: webmock
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
139
167
  description: Ruby implementation of the freee API.
140
168
  email:
141
169
  - futoase@gmail.com
@@ -153,46 +181,80 @@ files:
153
181
  - bin/freee
154
182
  - freee.gemspec
155
183
  - lib/freee.rb
156
- - lib/freee/account.rb
157
- - lib/freee/amount.rb
184
+ - lib/freee/account_item.rb
158
185
  - lib/freee/base.rb
159
186
  - lib/freee/company.rb
160
187
  - lib/freee/deal.rb
161
188
  - lib/freee/item.rb
162
- - lib/freee/obj/account.rb
163
- - lib/freee/obj/amount.rb
189
+ - lib/freee/obj/account_item.rb
164
190
  - lib/freee/obj/company.rb
165
191
  - lib/freee/obj/deal.rb
166
192
  - lib/freee/obj/item.rb
167
193
  - lib/freee/obj/partner.rb
168
194
  - lib/freee/obj/response.rb
195
+ - lib/freee/obj/section.rb
196
+ - lib/freee/obj/tag.rb
169
197
  - lib/freee/obj/tax.rb
170
198
  - lib/freee/obj/transfer.rb
171
199
  - lib/freee/obj/user.rb
172
- - lib/freee/obj/wallet.rb
200
+ - lib/freee/obj/wallet_txn.rb
173
201
  - lib/freee/obj/walletable.rb
174
202
  - lib/freee/partner.rb
203
+ - lib/freee/section.rb
204
+ - lib/freee/tag.rb
175
205
  - lib/freee/tax.rb
176
206
  - lib/freee/transfer.rb
177
207
  - lib/freee/user.rb
178
208
  - lib/freee/util.rb
179
209
  - lib/freee/version.rb
180
- - lib/freee/wallet.rb
210
+ - lib/freee/wallet_txn.rb
181
211
  - lib/freee/walletable.rb
182
- - spec/account_spec.rb
183
- - spec/amount_spec.rb
212
+ - spec/account_item_spec.rb
184
213
  - spec/base_spec.rb
185
214
  - spec/company_spec.rb
186
215
  - spec/deal_spec.rb
216
+ - spec/fixtures/account_items.json
217
+ - spec/fixtures/companies.json
218
+ - spec/fixtures/company.json
219
+ - spec/fixtures/create_deal.json
220
+ - spec/fixtures/create_item.json
221
+ - spec/fixtures/create_partner.json
222
+ - spec/fixtures/create_section.json
223
+ - spec/fixtures/create_tag.json
224
+ - spec/fixtures/create_transfer.json
225
+ - spec/fixtures/create_wallet_txn.json
226
+ - spec/fixtures/create_walletable.json
227
+ - spec/fixtures/deal.json
228
+ - spec/fixtures/deals.json
229
+ - spec/fixtures/item.json
230
+ - spec/fixtures/items.json
231
+ - spec/fixtures/partner.json
232
+ - spec/fixtures/partners.json
233
+ - spec/fixtures/section.json
234
+ - spec/fixtures/sections.json
235
+ - spec/fixtures/tag.json
236
+ - spec/fixtures/tags.json
237
+ - spec/fixtures/taxes.json
238
+ - spec/fixtures/taxes_with_code.json
239
+ - spec/fixtures/transfer.json
240
+ - spec/fixtures/transfers.json
241
+ - spec/fixtures/user.json
242
+ - spec/fixtures/user_with_companies.json
243
+ - spec/fixtures/wallet_txn.json
244
+ - spec/fixtures/wallet_txns.json
245
+ - spec/fixtures/walletable.json
246
+ - spec/fixtures/walletables.json
187
247
  - spec/item_spec.rb
188
248
  - spec/partner_spec.rb
249
+ - spec/section_spec.rb
189
250
  - spec/setenv_spec.rb
190
251
  - spec/spec_helper.rb
252
+ - spec/tag_spec.rb
191
253
  - spec/tax_spec.rb
192
254
  - spec/transfer_spec.rb
193
255
  - spec/user_spec.rb
194
256
  - spec/util_spec.rb
195
- - spec/wallet_spec.rb
257
+ - spec/wallet_txn_spec.rb
196
258
  - spec/walletable_spec.rb
197
259
  homepage: https://github.com/futoase/freee-gem
198
260
  licenses:
@@ -214,23 +276,55 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
276
  version: '0'
215
277
  requirements: []
216
278
  rubyforge_project:
217
- rubygems_version: 2.2.2
279
+ rubygems_version: 2.4.5
218
280
  signing_key:
219
281
  specification_version: 4
220
282
  summary: freee API.
221
283
  test_files:
222
- - spec/account_spec.rb
223
- - spec/amount_spec.rb
284
+ - spec/account_item_spec.rb
224
285
  - spec/base_spec.rb
225
286
  - spec/company_spec.rb
226
287
  - spec/deal_spec.rb
288
+ - spec/fixtures/account_items.json
289
+ - spec/fixtures/companies.json
290
+ - spec/fixtures/company.json
291
+ - spec/fixtures/create_deal.json
292
+ - spec/fixtures/create_item.json
293
+ - spec/fixtures/create_partner.json
294
+ - spec/fixtures/create_section.json
295
+ - spec/fixtures/create_tag.json
296
+ - spec/fixtures/create_transfer.json
297
+ - spec/fixtures/create_wallet_txn.json
298
+ - spec/fixtures/create_walletable.json
299
+ - spec/fixtures/deal.json
300
+ - spec/fixtures/deals.json
301
+ - spec/fixtures/item.json
302
+ - spec/fixtures/items.json
303
+ - spec/fixtures/partner.json
304
+ - spec/fixtures/partners.json
305
+ - spec/fixtures/section.json
306
+ - spec/fixtures/sections.json
307
+ - spec/fixtures/tag.json
308
+ - spec/fixtures/tags.json
309
+ - spec/fixtures/taxes.json
310
+ - spec/fixtures/taxes_with_code.json
311
+ - spec/fixtures/transfer.json
312
+ - spec/fixtures/transfers.json
313
+ - spec/fixtures/user.json
314
+ - spec/fixtures/user_with_companies.json
315
+ - spec/fixtures/wallet_txn.json
316
+ - spec/fixtures/wallet_txns.json
317
+ - spec/fixtures/walletable.json
318
+ - spec/fixtures/walletables.json
227
319
  - spec/item_spec.rb
228
320
  - spec/partner_spec.rb
321
+ - spec/section_spec.rb
229
322
  - spec/setenv_spec.rb
230
323
  - spec/spec_helper.rb
324
+ - spec/tag_spec.rb
231
325
  - spec/tax_spec.rb
232
326
  - spec/transfer_spec.rb
233
327
  - spec/user_spec.rb
234
328
  - spec/util_spec.rb
235
- - spec/wallet_spec.rb
329
+ - spec/wallet_txn_spec.rb
236
330
  - spec/walletable_spec.rb
@@ -1,7 +0,0 @@
1
- module Freee
2
- class Amount < Freee::Base
3
- def self.current_report
4
- Freee.client.get('/api/p/reports/amounts/current', :amount)
5
- end
6
- end
7
- end
@@ -1,34 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- describe Freee::Account do
4
- let(:client_id) { get_token }
5
- let(:secret_key) { get_secret_key }
6
- let(:token) { get_token }
7
- let(:company_id) { get_company_id }
8
- let(:account) { Freee::Account }
9
-
10
- before(:each) do
11
- Freee::Base.config(client_id, secret_key, token)
12
- end
13
-
14
- it 'should can be able to create instance' do
15
- expect(account.items(company_id)).to include('account_items')
16
- end
17
-
18
- describe 'should be get information of account' do
19
- subject { account.items(company_id) }
20
- it { is_expected.to include('account_items') }
21
- it { is_expected.to be_instance_of(Freee::Response::Account) }
22
- end
23
-
24
- describe 'should be get information of account_items' do
25
- subject { account.items(company_id)['account_items'].first }
26
-
27
- it { is_expected.not_to be_nil }
28
- it { is_expected.to include('id') }
29
- it { is_expected.to include('name') }
30
- it { is_expected.to include('shortcut') }
31
- it { is_expected.to include('default_tax_id') }
32
- it { is_expected.to include('categories') }
33
- end
34
- end