myob-essentials-api 0.0.1

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 (58) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.rspec +2 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +12 -0
  6. data/Gemfile +14 -0
  7. data/Gemfile.lock +86 -0
  8. data/LICENSE +22 -0
  9. data/README.md +188 -0
  10. data/Rakefile +51 -0
  11. data/VERSION +1 -0
  12. data/lib/myob-essentials-api.rb +13 -0
  13. data/lib/myob/essentials/api/client.rb +86 -0
  14. data/lib/myob/essentials/api/helper.rb +29 -0
  15. data/lib/myob/essentials/api/model/account.rb +13 -0
  16. data/lib/myob/essentials/api/model/account_balance.rb +13 -0
  17. data/lib/myob/essentials/api/model/account_classification.rb +13 -0
  18. data/lib/myob/essentials/api/model/account_type.rb +13 -0
  19. data/lib/myob/essentials/api/model/base.rb +114 -0
  20. data/lib/myob/essentials/api/model/business.rb +13 -0
  21. data/lib/myob/essentials/api/model/contact.rb +13 -0
  22. data/lib/myob/essentials/api/model/inventory_item.rb +13 -0
  23. data/lib/myob/essentials/api/model/sale_invoice.rb +13 -0
  24. data/lib/myob/essentials/api/model/sale_payment.rb +13 -0
  25. data/lib/myob/essentials/api/model/tax_type.rb +13 -0
  26. data/myob-essentials-api.gemspec +102 -0
  27. data/spec/fixtures/account/classifications.json +104 -0
  28. data/spec/fixtures/account/classifications/1.json +11 -0
  29. data/spec/fixtures/account/types.json +170 -0
  30. data/spec/fixtures/account/types/1.json +11 -0
  31. data/spec/fixtures/base1.json +38 -0
  32. data/spec/fixtures/base2.json +42 -0
  33. data/spec/fixtures/base3.json +29 -0
  34. data/spec/fixtures/businesses.json +84 -0
  35. data/spec/fixtures/businesses/168254.json +34 -0
  36. data/spec/fixtures/businesses/168254/contacts.json +386 -0
  37. data/spec/fixtures/businesses/168254/contacts/3604150.json +37 -0
  38. data/spec/fixtures/businesses/168254/generalledger/accounts.json +1978 -0
  39. data/spec/fixtures/businesses/168254/generalledger/accounts/10108109.json +29 -0
  40. data/spec/fixtures/businesses/168254/inventory/items.json +331 -0
  41. data/spec/fixtures/businesses/168254/inventory/items/987816.json +45 -0
  42. data/spec/fixtures/businesses/168254/sale/invoices.json +131 -0
  43. data/spec/fixtures/businesses/168254/sale/invoices/35608735.json +55 -0
  44. data/spec/fixtures/tax/types.json +79 -0
  45. data/spec/fixtures/tax/types/5.json +7 -0
  46. data/spec/myob/essentials/api/client_spec.rb +78 -0
  47. data/spec/myob/essentials/api/model/account_classification_spec.rb +31 -0
  48. data/spec/myob/essentials/api/model/account_spec.rb +31 -0
  49. data/spec/myob/essentials/api/model/account_type_spec.rb +31 -0
  50. data/spec/myob/essentials/api/model/base_spec.rb +100 -0
  51. data/spec/myob/essentials/api/model/business_spec.rb +31 -0
  52. data/spec/myob/essentials/api/model/contact_spec.rb +32 -0
  53. data/spec/myob/essentials/api/model/inventory_item_spec.rb +32 -0
  54. data/spec/myob/essentials/api/model/sale_invoice_spec.rb +32 -0
  55. data/spec/myob/essentials/api/model/sale_payment_spec.rb +34 -0
  56. data/spec/myob/essentials/api/model/tax_type_spec.rb +31 -0
  57. data/spec/spec_helper.rb +94 -0
  58. metadata +143 -0
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Myob::Essentials::Api::Model::Contact do
4
+
5
+ let(:consumer) { {key: 'key', secret: 'secret'} }
6
+ let(:business_uid) { '168254' }
7
+ let(:params) { {consumer: consumer, access_token: 'access_token', refresh_token: 'refresh_token', business_uid: business_uid} }
8
+
9
+ subject { Myob::Essentials::Api::Client.new(params) }
10
+
11
+ describe ".contact.all_items" do
12
+ let(:contacts_response) { File.read("spec/fixtures/businesses/#{business_uid}/contacts.json") }
13
+
14
+ before { stub_request(:get, "https://api.myob.com/au/essentials/businesses/#{business_uid}/contacts").to_return(:status => 200, :body => contacts_response, :headers => {}) }
15
+
16
+ it "fetches the list of contacts" do
17
+ expect(subject.contact.all_items).to eql(JSON.parse(contacts_response)["items"])
18
+ end
19
+ end
20
+
21
+ describe ".contact.find" do
22
+ let(:contact_uid) { '3604150' }
23
+ let(:contact_response) { File.read("spec/fixtures/businesses/#{business_uid}/contacts/#{contact_uid}.json") }
24
+
25
+ before { stub_request(:get, "https://api.myob.com/au/essentials/businesses/#{business_uid}/contacts/#{contact_uid}").to_return(:status => 200, :body => contact_response, :headers => {}) }
26
+
27
+ it "fetches a contact by uid" do
28
+ expect(subject.contact.find(contact_uid)).to eql(JSON.parse(contact_response))
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Myob::Essentials::Api::Model::InventoryItem do
4
+
5
+ let(:consumer) { {key: 'key', secret: 'secret'} }
6
+ let(:business_uid) { '168254' }
7
+ let(:params) { {consumer: consumer, access_token: 'access_token', refresh_token: 'refresh_token', business_uid: business_uid} }
8
+
9
+ subject { Myob::Essentials::Api::Client.new(params) }
10
+
11
+ describe ".inventory_item.all_items" do
12
+ let(:contacts_response) { File.read("spec/fixtures/businesses/#{business_uid}/inventory/items.json") }
13
+
14
+ before { stub_request(:get, "https://api.myob.com/au/essentials/businesses/#{business_uid}/inventory/items").to_return(:status => 200, :body => contacts_response, :headers => {}) }
15
+
16
+ it "fetches the list of items" do
17
+ expect(subject.inventory_item.all_items).to eql(JSON.parse(contacts_response)["items"])
18
+ end
19
+ end
20
+
21
+ describe ".inventory_item.find" do
22
+ let(:item_uid) { '987816' }
23
+ let(:item_response) { File.read("spec/fixtures/businesses/#{business_uid}/inventory/items/#{item_uid}.json") }
24
+
25
+ before { stub_request(:get, "https://api.myob.com/au/essentials/businesses/#{business_uid}/inventory/items/#{item_uid}").to_return(:status => 200, :body => item_response, :headers => {}) }
26
+
27
+ it "fetches an item by uid" do
28
+ expect(subject.inventory_item.find(item_uid)).to eql(JSON.parse(item_response))
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Myob::Essentials::Api::Model::SaleInvoice do
4
+
5
+ let(:consumer) { {key: 'key', secret: 'secret'} }
6
+ let(:business_uid) { '168254' }
7
+ let(:params) { {consumer: consumer, access_token: 'access_token', refresh_token: 'refresh_token', business_uid: business_uid} }
8
+
9
+ subject { Myob::Essentials::Api::Client.new(params) }
10
+
11
+ describe ".sale_invoice.all_items" do
12
+ let(:contacts_response) { File.read("spec/fixtures/businesses/#{business_uid}/sale/invoices.json") }
13
+
14
+ before { stub_request(:get, "https://api.myob.com/au/essentials/businesses/#{business_uid}/sale/invoices").to_return(:status => 200, :body => contacts_response, :headers => {}) }
15
+
16
+ it "fetches the list of sale invoices" do
17
+ expect(subject.sale_invoice.all_items).to eql(JSON.parse(contacts_response)["items"])
18
+ end
19
+ end
20
+
21
+ describe ".sale_invoice.find" do
22
+ let(:invoice_uid) { '35608735' }
23
+ let(:invoice_response) { File.read("spec/fixtures/businesses/#{business_uid}/sale/invoices/#{invoice_uid}.json") }
24
+
25
+ before { stub_request(:get, "https://api.myob.com/au/essentials/businesses/#{business_uid}/sale/invoices/#{invoice_uid}").to_return(:status => 200, :body => invoice_response, :headers => {}) }
26
+
27
+ it "fetches a sale invoice by uid" do
28
+ expect(subject.sale_invoice.find(invoice_uid)).to eql(JSON.parse(invoice_response))
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ # http://developer.myob.com/api/essentials-accounting/endpoints/sale/payments/
4
+ # Endpoint not implemented yet
5
+ describe Myob::Essentials::Api::Model::SalePayment do
6
+
7
+ let(:consumer) { {key: 'key', secret: 'secret'} }
8
+ let(:business_uid) { '168254' }
9
+ let(:params) { {consumer: consumer, access_token: 'access_token', refresh_token: 'refresh_token', business_uid: business_uid} }
10
+
11
+ subject { Myob::Essentials::Api::Client.new(params) }
12
+
13
+ describe ".sale_payment.all_items" do
14
+ let(:contacts_response) { File.read("spec/fixtures/businesses/#{business_uid}/sale/payments.json") }
15
+
16
+ before { stub_request(:get, "https://api.myob.com/au/essentials/businesses/#{business_uid}/sale/payments").to_return(:status => 200, :body => contacts_response, :headers => {}) }
17
+
18
+ it "fetches the list of sale payments" do
19
+ expect(subject.sale_payment.all_items).to eql(JSON.parse(contacts_response)["items"])
20
+ end
21
+ end
22
+
23
+ describe ".sale_payment.find" do
24
+ let(:payment_uid) { '987816' }
25
+ let(:payment_response) { File.read("spec/fixtures/businesses/#{business_uid}/sale/payments/#{payment_uid}.json") }
26
+
27
+ before { stub_request(:get, "https://api.myob.com/au/essentials/businesses/#{business_uid}/sale/payments/#{payment_uid}").to_return(:status => 200, :body => payment_response, :headers => {}) }
28
+
29
+ it "fetches a sale payment by uid" do
30
+ expect(subject.sale_payment.find(payment_uid)).to eql(JSON.parse(payment_response))
31
+ end
32
+ end
33
+
34
+ end if false
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Myob::Essentials::Api::Model::TaxType do
4
+
5
+ let(:consumer) { {key: 'key', secret: 'secret'} }
6
+ let(:params) { {consumer: consumer, access_token: 'access_token', refresh_token: 'refresh_token'} }
7
+
8
+ subject { Myob::Essentials::Api::Client.new(params) }
9
+
10
+ describe ".tax_type.all_items" do
11
+ let(:tax_types_response) { File.read('spec/fixtures/tax/types.json') }
12
+
13
+ before { stub_request(:get, "https://api.myob.com/au/essentials/tax/types").to_return(:status => 200, :body => tax_types_response, :headers => {}) }
14
+
15
+ it "fetches the list of tax types" do
16
+ expect(subject.tax_type.all_items).to eql(JSON.parse(tax_types_response)["items"])
17
+ end
18
+ end
19
+
20
+ describe ".tax_type.find" do
21
+ let(:tax_type_uid) { '5' }
22
+ let(:tax_type_response) { File.read("spec/fixtures/tax/types/#{tax_type_uid}.json") }
23
+
24
+ before { stub_request(:get, "https://api.myob.com/au/essentials/tax/types/#{tax_type_uid}").to_return(:status => 200, :body => tax_type_response, :headers => {}) }
25
+
26
+ it "fetches a tax type by uid" do
27
+ expect(subject.tax_type.find(tax_type_uid)).to eql(JSON.parse(tax_type_response))
28
+ end
29
+ end
30
+
31
+ end
@@ -0,0 +1,94 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, consider making
10
+ # a separate helper file that requires the additional dependencies and performs
11
+ # the additional setup, and require it from the spec files that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+
18
+ require_relative '../lib/myob-essentials-api.rb'
19
+ require 'webmock/rspec'
20
+ require 'timecop'
21
+
22
+ RSpec.configure do |config|
23
+ # rspec-expectations config goes here. You can use an alternate
24
+ # assertion/expectation library such as wrong or the stdlib/minitest
25
+ # assertions if you prefer.
26
+ config.expect_with :rspec do |expectations|
27
+ # This option will default to `true` in RSpec 4. It makes the `description`
28
+ # and `failure_message` of custom matchers include text for helper methods
29
+ # defined using `chain`, e.g.:
30
+ # be_bigger_than(2).and_smaller_than(4).description
31
+ # # => "be bigger than 2 and smaller than 4"
32
+ # ...rather than:
33
+ # # => "be bigger than 2"
34
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
+ end
36
+
37
+ # rspec-mocks config goes here. You can use an alternate test double
38
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
39
+ config.mock_with :rspec do |mocks|
40
+ # Prevents you from mocking or stubbing a method that does not exist on
41
+ # a real object. This is generally recommended, and will default to
42
+ # `true` in RSpec 4.
43
+ mocks.verify_partial_doubles = true
44
+ end
45
+
46
+ # The settings below are suggested to provide a good initial experience
47
+ # with RSpec, but feel free to customize to your heart's content.
48
+ =begin
49
+ # These two settings work together to allow you to limit a spec run
50
+ # to individual examples or groups you care about by tagging them with
51
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
52
+ # get run.
53
+ config.filter_run :focus
54
+ config.run_all_when_everything_filtered = true
55
+
56
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
57
+ # For more details, see:
58
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
59
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
60
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
61
+ config.disable_monkey_patching!
62
+
63
+ # This setting enables warnings. It's recommended, but in some cases may
64
+ # be too noisy due to issues in dependencies.
65
+ config.warnings = true
66
+
67
+ # Many RSpec users commonly either run the entire suite or an individual
68
+ # file, and it's useful to allow more verbose output when running an
69
+ # individual spec file.
70
+ if config.files_to_run.one?
71
+ # Use the documentation formatter for detailed output,
72
+ # unless a formatter has already been configured
73
+ # (e.g. via a command-line flag).
74
+ config.default_formatter = 'doc'
75
+ end
76
+
77
+ # Print the 10 slowest examples and example groups at the
78
+ # end of the spec run, to help surface which specs are running
79
+ # particularly slow.
80
+ config.profile_examples = 10
81
+
82
+ # Run specs in random order to surface order dependencies. If you find an
83
+ # order dependency and want to debug it, you can fix the order by providing
84
+ # the seed, which is printed after each run.
85
+ # --seed 1234
86
+ config.order = :random
87
+
88
+ # Seed global randomization in this process using the `--seed` CLI option.
89
+ # Setting this allows you to use `--seed` to deterministically reproduce
90
+ # test failures related to randomization by passing the same `--seed` value
91
+ # as the one that triggered the failure.
92
+ Kernel.srand config.seed
93
+ =end
94
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: myob-essentials-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - BrunoChauvet
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jeweler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Integrate with MYOB Essentials Accounting
56
+ email: it@maestrano.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files:
60
+ - LICENSE
61
+ - README.md
62
+ files:
63
+ - ".document"
64
+ - ".rspec"
65
+ - ".ruby-version"
66
+ - ".travis.yml"
67
+ - Gemfile
68
+ - Gemfile.lock
69
+ - LICENSE
70
+ - README.md
71
+ - Rakefile
72
+ - VERSION
73
+ - lib/myob-essentials-api.rb
74
+ - lib/myob/essentials/api/client.rb
75
+ - lib/myob/essentials/api/helper.rb
76
+ - lib/myob/essentials/api/model/account.rb
77
+ - lib/myob/essentials/api/model/account_balance.rb
78
+ - lib/myob/essentials/api/model/account_classification.rb
79
+ - lib/myob/essentials/api/model/account_type.rb
80
+ - lib/myob/essentials/api/model/base.rb
81
+ - lib/myob/essentials/api/model/business.rb
82
+ - lib/myob/essentials/api/model/contact.rb
83
+ - lib/myob/essentials/api/model/inventory_item.rb
84
+ - lib/myob/essentials/api/model/sale_invoice.rb
85
+ - lib/myob/essentials/api/model/sale_payment.rb
86
+ - lib/myob/essentials/api/model/tax_type.rb
87
+ - myob-essentials-api.gemspec
88
+ - spec/fixtures/account/classifications.json
89
+ - spec/fixtures/account/classifications/1.json
90
+ - spec/fixtures/account/types.json
91
+ - spec/fixtures/account/types/1.json
92
+ - spec/fixtures/base1.json
93
+ - spec/fixtures/base2.json
94
+ - spec/fixtures/base3.json
95
+ - spec/fixtures/businesses.json
96
+ - spec/fixtures/businesses/168254.json
97
+ - spec/fixtures/businesses/168254/contacts.json
98
+ - spec/fixtures/businesses/168254/contacts/3604150.json
99
+ - spec/fixtures/businesses/168254/generalledger/accounts.json
100
+ - spec/fixtures/businesses/168254/generalledger/accounts/10108109.json
101
+ - spec/fixtures/businesses/168254/inventory/items.json
102
+ - spec/fixtures/businesses/168254/inventory/items/987816.json
103
+ - spec/fixtures/businesses/168254/sale/invoices.json
104
+ - spec/fixtures/businesses/168254/sale/invoices/35608735.json
105
+ - spec/fixtures/tax/types.json
106
+ - spec/fixtures/tax/types/5.json
107
+ - spec/myob/essentials/api/client_spec.rb
108
+ - spec/myob/essentials/api/model/account_classification_spec.rb
109
+ - spec/myob/essentials/api/model/account_spec.rb
110
+ - spec/myob/essentials/api/model/account_type_spec.rb
111
+ - spec/myob/essentials/api/model/base_spec.rb
112
+ - spec/myob/essentials/api/model/business_spec.rb
113
+ - spec/myob/essentials/api/model/contact_spec.rb
114
+ - spec/myob/essentials/api/model/inventory_item_spec.rb
115
+ - spec/myob/essentials/api/model/sale_invoice_spec.rb
116
+ - spec/myob/essentials/api/model/sale_payment_spec.rb
117
+ - spec/myob/essentials/api/model/tax_type_spec.rb
118
+ - spec/spec_helper.rb
119
+ homepage: http://github.com/BrunoChauvet/myob-essentials-api
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.4.5
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: Integrate with MYOB Essentials Accounting
143
+ test_files: []