freee 0.3.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Freee::Amount do
4
- let(:client_id) { get_client_id }
5
- let(:secret_key) { get_secret_key }
6
- let(:token) { get_token }
7
- let(:amount) { Freee::Amount }
8
-
9
- before(:each) do
10
- Freee::Base.config(client_id, secret_key, token)
11
- end
12
-
13
- describe 'should can be able to create instance' do
14
- subject { amount.current_report }
15
- it { is_expected.not_to be_nil }
16
- it { is_expected.to be_instance_of(Freee::Response::Amount) }
17
- end
18
-
19
- describe 'should be get information of amount by current' do
20
- subject { amount.current_report }
21
-
22
- it { is_expected.to include('company_id') }
23
- it { is_expected.to include('start_date') }
24
- it { is_expected.to include('end_date') }
25
- end
26
- end
@@ -1,89 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Freee::Wallet 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_id) { get_walletable_id }
9
- let(:wallet) { Freee::Wallet }
10
- let(:response) do
11
- wallet.create(
12
- company_id: company_id,
13
- walletable_id: walletable_id,
14
- date: '2014-07-10',
15
- walletable_type: 'bank_account',
16
- amount: '1000000',
17
- entry_side: 'income'
18
- )['wallet_txn']
19
- end
20
-
21
- before(:each) do
22
- Freee::Base.config(client_id, secret_key, token)
23
- end
24
-
25
- describe 'should can be able to create instance' do
26
- subject { wallet.list(company_id) }
27
- it { is_expected.not_to be_nil }
28
- it { is_expected.to be_instance_of(Freee::Response::Wallet) }
29
- end
30
-
31
- describe 'should get information of wallet txns for the company' do
32
- subject { wallet.list(company_id) }
33
-
34
- it { is_expected.to include('wallet_txns') }
35
- end
36
-
37
- describe 'should get information of first wallet txns for the company' do
38
- subject { wallet.list(company_id)['wallet_txns'].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('amount') }
44
- it { is_expected.to include('balance') }
45
- it { is_expected.to include('description') }
46
- it { is_expected.to include('due_amount') }
47
- it { is_expected.to include('date') }
48
- it { is_expected.to include('entry_side') }
49
- it { is_expected.to include('walletable_type') }
50
- it { is_expected.to include('walletable_id') }
51
- end
52
-
53
- describe 'should get information of first wallet txns with walletable type' do
54
- subject do
55
- result = wallet.list(company_id, walletable_type: 'bank_account')['wallet_txns']
56
- result.map! { |x| x['walletable_type'] }
57
- Set.new(result).length
58
- end
59
-
60
- it { is_expected.not_to be_nil }
61
- it { is_expected.to eq 1 }
62
- end
63
-
64
- describe "should get information of one's wallet txns" do
65
- subject do
66
- wallet.list(company_id, limit: 2)['wallet_txns'].length
67
- end
68
-
69
- it { is_expected.not_to be_nil }
70
- it { is_expected.to eq 2 }
71
- end
72
-
73
- it "should set information of one's wallet txns" do
74
- expect(response).to include('id')
75
- expect(response).to include('company_id')
76
- expect(response).to include('walletable_id')
77
- expect(response).to include('date')
78
- expect(response).to include('walletable_type')
79
- expect(response).to include('amount')
80
- expect(response).to include('entry_side')
81
-
82
- expect(response['company_id']).to eq company_id.to_i
83
- expect(response['walletable_id']).to eq walletable_id.to_i
84
- expect(response['date']).to eq '2014-07-10'
85
- expect(response['walletable_type']).to eq 'bank_account'
86
- expect(response['amount']).to eq 1000000
87
- expect(response['entry_side']).to eq 'income'
88
- end
89
- end