business-central 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa79fbf2f11dba355ca4486b9bed998dc3a481aa2c52f66d311bf1525e3f8620
4
- data.tar.gz: 13910cff1f4af8e26fe89921c1021e2799f074134ebb797163aff3aac863e510
3
+ metadata.gz: a33078b9f42de6667181a50991b793edcc2bdedb118be70e26fdfe9224e23ba6
4
+ data.tar.gz: cd67e00b86499bc25fa912a8ff662991c809f13add9f892611591e45e04453bf
5
5
  SHA512:
6
- metadata.gz: 67aa6439003bd9b3ec1599a97cfd2b235af9c68c140cac188609c0e3d496aac0a67447548c7acb9eef4182d7888a14cf5996bfbb48584db08ed9fb7ac97a8c4e
7
- data.tar.gz: b5dfd537dd2c023f71196d8960b9bcc5b8ae88115f62bb53c1840531862312689eaba558b5903d0979b2c87070203c80a85294b69078efc014eb0caadf3d8dd2
6
+ metadata.gz: 1e2616ef4f1cb78780924fe1741dcceb97ab02460b0838dccc0f94eb1fd990a4c1a8ac72e6a4a87a1189c1834557fa2efa0755f207eb6aa399d815802f663374
7
+ data.tar.gz: 5d3a27c2fcfcaaabb52832382a90d74527fdb8c5c5adf4cda26c5e2be48b52a5bcda500b8733eb52406c8f3be8c958379c833a3571aca4954f8b0e51a13f627e
@@ -12,7 +12,12 @@ require 'business_central/object/response'
12
12
  require 'business_central/object/request'
13
13
 
14
14
  require 'business_central/object/account'
15
+ require 'business_central/object/aged_account_payable'
16
+ require 'business_central/object/aged_account_receivable'
17
+ require 'business_central/object/cash_flow_statement'
18
+ require 'business_central/object/balance_sheet'
15
19
  require 'business_central/object/company'
20
+ require 'business_central/object/company_information'
16
21
  require 'business_central/object/vendor'
17
22
  require 'business_central/object/item'
18
23
  require 'business_central/object/purchase_invoice'
@@ -15,7 +15,12 @@ module BusinessCentral
15
15
  alias_method :access_token, :oauth2_client
16
16
 
17
17
  object :account
18
+ object :aged_account_payable
19
+ object :aged_account_receivable
20
+ object :balance_sheet
21
+ object :cash_flow_statement
18
22
  object :company
23
+ object :company_information
19
24
  object :vendor
20
25
  object :purchase_invoice
21
26
  object :purchase_invoice_line
@@ -6,6 +6,16 @@ module BusinessCentral
6
6
  OBJECT_METHODS = [
7
7
  :get
8
8
  ].freeze
9
+
10
+ def initialize(client, company_id:)
11
+ super(client, company_id: company_id)
12
+ @parent_path = [
13
+ {
14
+ path: 'companies',
15
+ id: company_id
16
+ }
17
+ ]
18
+ end
9
19
  end
10
20
  end
11
21
  end
@@ -0,0 +1,21 @@
1
+ module BusinessCentral
2
+ module Object
3
+ class AgedAccountPayable < Base
4
+ OBJECT = 'agedAccountsPayable'.freeze
5
+
6
+ OBJECT_METHODS = [
7
+ :get
8
+ ].freeze
9
+
10
+ def initialize(client, company_id:)
11
+ super(client, company_id: company_id)
12
+ @parent_path = [
13
+ {
14
+ path: 'companies',
15
+ id: company_id
16
+ }
17
+ ]
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module BusinessCentral
2
+ module Object
3
+ class AgedAccountReceivable < Base
4
+ OBJECT = 'agedAccountsReceivable'.freeze
5
+
6
+ OBJECT_METHODS = [
7
+ :get
8
+ ].freeze
9
+
10
+ def initialize(client, company_id:)
11
+ super(client, company_id: company_id)
12
+ @parent_path = [
13
+ {
14
+ path: 'companies',
15
+ id: company_id
16
+ }
17
+ ]
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module BusinessCentral
2
+ module Object
3
+ class BalanceSheet < Base
4
+ OBJECT = 'balanceSheet'.freeze
5
+
6
+ OBJECT_METHODS = [
7
+ :get
8
+ ].freeze
9
+
10
+ def initialize(client, company_id:)
11
+ super(client, company_id: company_id)
12
+ @parent_path = [
13
+ {
14
+ path: 'companies',
15
+ id: company_id
16
+ }
17
+ ]
18
+ end
19
+ end
20
+ end
21
+ end
@@ -76,7 +76,7 @@ module BusinessCentral
76
76
  end
77
77
 
78
78
  def object_validation
79
- self.class.const_get(:OBJECT_VALIDATION)
79
+ self.class.const_defined?(:OBJECT_VALIDATION) ? self.class.const_get(:OBJECT_VALIDATION) : []
80
80
  end
81
81
 
82
82
  def object_methods
@@ -0,0 +1,21 @@
1
+ module BusinessCentral
2
+ module Object
3
+ class CashFlowStatement < Base
4
+ OBJECT = 'cashFlowStatement'.freeze
5
+
6
+ OBJECT_METHODS = [
7
+ :get
8
+ ].freeze
9
+
10
+ def initialize(client, company_id:)
11
+ super(client, company_id: company_id)
12
+ @parent_path = [
13
+ {
14
+ path: 'companies',
15
+ id: company_id
16
+ }
17
+ ]
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ module BusinessCentral
2
+ module Object
3
+ class CompanyInformation < Base
4
+ OBJECT = 'companyInformation'.freeze
5
+
6
+ OBJECT_METHODS = [
7
+ :get,
8
+ :patch
9
+ ].freeze
10
+
11
+ def initialize(client, company_id:)
12
+ super(client, company_id: company_id)
13
+ @parent_path = [
14
+ {
15
+ path: 'companies',
16
+ id: company_id
17
+ }
18
+ ]
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,7 +1,7 @@
1
1
  module BusinessCentral
2
2
  module Object
3
3
  class Validation
4
- def initialize(validation_rules, object_params)
4
+ def initialize(validation_rules = [], object_params = {})
5
5
  @validation_rules = validation_rules
6
6
  @object_params = object_params
7
7
  @errors = []
@@ -1,3 +1,3 @@
1
1
  module BusinessCentral
2
- VERSION = "1.0.0".freeze
2
+ VERSION = "1.0.1".freeze
3
3
  end
@@ -45,4 +45,22 @@ class BusinessCentral::Object::AccountTest < Minitest::Test
45
45
  response = @account.find_by_id(test_account_id)
46
46
  assert_equal response[:display_name], 'account2'
47
47
  end
48
+
49
+ def test_create
50
+ assert_raises BusinessCentral::NoSupportedMethod do
51
+ @account.create({})
52
+ end
53
+ end
54
+
55
+ def test_update
56
+ assert_raises BusinessCentral::NoSupportedMethod do
57
+ @account.update('123', {})
58
+ end
59
+ end
60
+
61
+ def test_delete
62
+ assert_raises BusinessCentral::NoSupportedMethod do
63
+ @account.destroy('123')
64
+ end
65
+ end
48
66
  end
@@ -0,0 +1,60 @@
1
+ require "test_helper"
2
+ # rake test TEST=test/business_central/object/aged_account_payable_test.rb
3
+
4
+ class BusinessCentral::Object::AgedAccountPayableTest < Minitest::Test
5
+ def setup
6
+ @company_id = '123456'
7
+ @client = BusinessCentral::Client.new
8
+ @aged_account_payable = @client.aged_account_payable(company_id: @company_id)
9
+ end
10
+
11
+ def test_find_all
12
+ stub_request(:get, /agedAccountsPayable/)
13
+ .to_return(
14
+ status: 200,
15
+ body: {
16
+ 'value': [
17
+ {
18
+ name: 'vendor1'
19
+ }
20
+ ]
21
+ }.to_json
22
+ )
23
+
24
+
25
+ response = @aged_account_payable.find_all
26
+ assert_equal response.first[:name], 'vendor1'
27
+ end
28
+
29
+ def test_find_by_id
30
+ test_id = '123'
31
+ stub_request(:get, /agedAccountsPayable\(#{test_id}\)/)
32
+ .to_return(
33
+ status: 200,
34
+ body: {
35
+ name: 'vendor2'
36
+ }.to_json
37
+ )
38
+
39
+ response = @aged_account_payable.find_by_id(test_id)
40
+ assert_equal response[:name], 'vendor2'
41
+ end
42
+
43
+ def test_create
44
+ assert_raises BusinessCentral::NoSupportedMethod do
45
+ @aged_account_payable.create({})
46
+ end
47
+ end
48
+
49
+ def test_update
50
+ assert_raises BusinessCentral::NoSupportedMethod do
51
+ @aged_account_payable.update('123', {})
52
+ end
53
+ end
54
+
55
+ def test_delete
56
+ assert_raises BusinessCentral::NoSupportedMethod do
57
+ @aged_account_payable.destroy('123')
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,60 @@
1
+ require "test_helper"
2
+ # rake test TEST=test/business_central/object/aged_account_receivable_test.rb
3
+
4
+ class BusinessCentral::Object::AgedAccountReceivableTest < Minitest::Test
5
+ def setup
6
+ @company_id = '123456'
7
+ @client = BusinessCentral::Client.new
8
+ @aged_account_receivable = @client.aged_account_receivable(company_id: @company_id)
9
+ end
10
+
11
+ def test_find_all
12
+ stub_request(:get, /agedAccountsReceivable/)
13
+ .to_return(
14
+ status: 200,
15
+ body: {
16
+ 'value': [
17
+ {
18
+ name: 'customer1'
19
+ }
20
+ ]
21
+ }.to_json
22
+ )
23
+
24
+
25
+ response = @aged_account_receivable.find_all
26
+ assert_equal response.first[:name], 'customer1'
27
+ end
28
+
29
+ def test_find_by_id
30
+ test_id = '123'
31
+ stub_request(:get, /agedAccountsReceivable\(#{test_id}\)/)
32
+ .to_return(
33
+ status: 200,
34
+ body: {
35
+ name: 'customer2'
36
+ }.to_json
37
+ )
38
+
39
+ response = @aged_account_receivable.find_by_id(test_id)
40
+ assert_equal response[:name], 'customer2'
41
+ end
42
+
43
+ def test_create
44
+ assert_raises BusinessCentral::NoSupportedMethod do
45
+ @aged_account_receivable.create({})
46
+ end
47
+ end
48
+
49
+ def test_update
50
+ assert_raises BusinessCentral::NoSupportedMethod do
51
+ @aged_account_receivable.update('123', {})
52
+ end
53
+ end
54
+
55
+ def test_delete
56
+ assert_raises BusinessCentral::NoSupportedMethod do
57
+ @aged_account_receivable.destroy('123')
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,60 @@
1
+ require "test_helper"
2
+ # rake test TEST=test/business_central/object/balance_sheet_test.rb
3
+
4
+ class BusinessCentral::Object::BalanceSheetTest < Minitest::Test
5
+ def setup
6
+ @company_id = '123456'
7
+ @client = BusinessCentral::Client.new
8
+ @balance_sheet = @client.balance_sheet(company_id: @company_id)
9
+ end
10
+
11
+ def test_find_all
12
+ stub_request(:get, /balanceSheet/)
13
+ .to_return(
14
+ status: 200,
15
+ body: {
16
+ 'value': [
17
+ {
18
+ display: 'balance item 1'
19
+ }
20
+ ]
21
+ }.to_json
22
+ )
23
+
24
+
25
+ response = @balance_sheet.find_all
26
+ assert_equal response.first[:display], 'balance item 1'
27
+ end
28
+
29
+ def test_find_by_id
30
+ test_id = '123'
31
+ stub_request(:get, /balanceSheet\(#{test_id}\)/)
32
+ .to_return(
33
+ status: 200,
34
+ body: {
35
+ display: 'balance item 2'
36
+ }.to_json
37
+ )
38
+
39
+ response = @balance_sheet.find_by_id(test_id)
40
+ assert_equal response[:display], 'balance item 2'
41
+ end
42
+
43
+ def test_create
44
+ assert_raises BusinessCentral::NoSupportedMethod do
45
+ @balance_sheet.create({})
46
+ end
47
+ end
48
+
49
+ def test_update
50
+ assert_raises BusinessCentral::NoSupportedMethod do
51
+ @balance_sheet.update('123', {})
52
+ end
53
+ end
54
+
55
+ def test_delete
56
+ assert_raises BusinessCentral::NoSupportedMethod do
57
+ @balance_sheet.destroy('123')
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,60 @@
1
+ require "test_helper"
2
+ # rake test TEST=test/business_central/object/cash_flow_statement_test.rb
3
+
4
+ class BusinessCentral::Object::CashFlowStatementTest < Minitest::Test
5
+ def setup
6
+ @company_id = '123456'
7
+ @client = BusinessCentral::Client.new
8
+ @cash_flow_statement = @client.cash_flow_statement(company_id: @company_id)
9
+ end
10
+
11
+ def test_find_all
12
+ stub_request(:get, /cashFlowStatement/)
13
+ .to_return(
14
+ status: 200,
15
+ body: {
16
+ 'value': [
17
+ {
18
+ display: 'assets 1'
19
+ }
20
+ ]
21
+ }.to_json
22
+ )
23
+
24
+
25
+ response = @cash_flow_statement.find_all
26
+ assert_equal response.first[:display], 'assets 1'
27
+ end
28
+
29
+ def test_find_by_id
30
+ test_id = '123'
31
+ stub_request(:get, /cashFlowStatement\(#{test_id}\)/)
32
+ .to_return(
33
+ status: 200,
34
+ body: {
35
+ display: 'assets 2'
36
+ }.to_json
37
+ )
38
+
39
+ response = @cash_flow_statement.find_by_id(test_id)
40
+ assert_equal response[:display], 'assets 2'
41
+ end
42
+
43
+ def test_create
44
+ assert_raises BusinessCentral::NoSupportedMethod do
45
+ @cash_flow_statement.create({})
46
+ end
47
+ end
48
+
49
+ def test_update
50
+ assert_raises BusinessCentral::NoSupportedMethod do
51
+ @cash_flow_statement.update('123', {})
52
+ end
53
+ end
54
+
55
+ def test_delete
56
+ assert_raises BusinessCentral::NoSupportedMethod do
57
+ @cash_flow_statement.destroy('123')
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,82 @@
1
+ require "test_helper"
2
+ # rake test TEST=test/business_central/object/company_information_test.rb
3
+
4
+ class BusinessCentral::Object::CompanyInformationTest < Minitest::Test
5
+ def setup
6
+ @company_id = '123456'
7
+ @client = BusinessCentral::Client.new
8
+ @company_information = @client.company_information(company_id: @company_id)
9
+ end
10
+
11
+ def test_find_all
12
+ stub_request(:get, /companyInformation/)
13
+ .to_return(
14
+ status: 200,
15
+ body: {
16
+ 'value': [
17
+ {
18
+ displayName: 'business1'
19
+ }
20
+ ]
21
+ }.to_json
22
+ )
23
+
24
+
25
+ response = @company_information.find_all
26
+ assert_equal response.first[:display_name], 'business1'
27
+ end
28
+
29
+ def test_find_by_id
30
+ test_company_id = '123'
31
+ stub_request(:get, /companyInformation\(#{test_company_id}\)/)
32
+ .to_return(
33
+ status: 200,
34
+ body: {
35
+ displayName: 'business2'
36
+ }.to_json
37
+ )
38
+
39
+ response = @company_information.find_by_id(test_company_id)
40
+ assert_equal response[:display_name], 'business2'
41
+ end
42
+
43
+ def test_create
44
+ assert_raises BusinessCentral::NoSupportedMethod do
45
+ @company_information.create({})
46
+ end
47
+ end
48
+
49
+ def test_update
50
+ test_company_id = '123'
51
+ stub_request(:get, /companyInformation\(#{test_company_id}\)/)
52
+ .to_return(
53
+ status: 200,
54
+ body: {
55
+ etag: '112',
56
+ displayName: 'business3'
57
+ }.to_json
58
+ )
59
+
60
+ stub_request(:patch, /companyInformation\(#{test_company_id}\)/)
61
+ .to_return(
62
+ status: 200,
63
+ body: {
64
+ displayName: 'business4'
65
+ }.to_json
66
+ )
67
+
68
+ response = @company_information.update(
69
+ test_company_id,
70
+ {
71
+ display_name: 'business4'
72
+ }
73
+ )
74
+ assert_equal response[:display_name], 'business4'
75
+ end
76
+
77
+ def test_delete
78
+ assert_raises BusinessCentral::NoSupportedMethod do
79
+ @company_information.destroy('123')
80
+ end
81
+ end
82
+ end
@@ -4,12 +4,6 @@ require "test_helper"
4
4
  class BusinessCentral::Object::CompanyTest < Minitest::Test
5
5
  def setup
6
6
  @client = BusinessCentral::Client.new
7
- @client.authorize_from_token(
8
- token: '123',
9
- refresh_token: '456',
10
- expires_at: Time.now + 3600,
11
- expires_in: 3600
12
- )
13
7
  @company = @client.company
14
8
  end
15
9
 
@@ -44,4 +38,22 @@ class BusinessCentral::Object::CompanyTest < Minitest::Test
44
38
  response = @company.find_by_id(test_company_id)
45
39
  assert_equal response[:display_name], 'business2'
46
40
  end
41
+
42
+ def test_create
43
+ assert_raises BusinessCentral::NoSupportedMethod do
44
+ @company.create({})
45
+ end
46
+ end
47
+
48
+ def test_update
49
+ assert_raises BusinessCentral::NoSupportedMethod do
50
+ @company.update('123', {})
51
+ end
52
+ end
53
+
54
+ def test_delete
55
+ assert_raises BusinessCentral::NoSupportedMethod do
56
+ @company.destroy('123')
57
+ end
58
+ end
47
59
  end
@@ -5,12 +5,6 @@ class BusinessCentral::Object::ItemTest < Minitest::Test
5
5
  def setup
6
6
  @company_id = '123456'
7
7
  @client = BusinessCentral::Client.new
8
- @client.authorize_from_token(
9
- token: '123',
10
- refresh_token: '456',
11
- expires_at: Time.now + 3600,
12
- expires_in: 3600
13
- )
14
8
  @item = @client.item(company_id: @company_id)
15
9
  end
16
10
 
@@ -6,12 +6,6 @@ class BusinessCentral::Object::PurchaseInvoiceLineTest < Minitest::Test
6
6
  @company_id = '123456'
7
7
  @purchase_invoice_id = '789456'
8
8
  @client = BusinessCentral::Client.new
9
- @client.authorize_from_token(
10
- token: '123',
11
- refresh_token: '456',
12
- expires_at: Time.now + 3600,
13
- expires_in: 3600
14
- )
15
9
  @purchase_invoice_line = @client.purchase_invoice_line(
16
10
  company_id: @company_id,
17
11
  purchase_invoice_id: @purchase_invoice_id
@@ -5,12 +5,6 @@ class BusinessCentral::Object::PurchaseInvoiceTest < Minitest::Test
5
5
  def setup
6
6
  @company_id = '123456'
7
7
  @client = BusinessCentral::Client.new
8
- @client.authorize_from_token(
9
- token: '123',
10
- refresh_token: '456',
11
- expires_at: Time.now + 3600,
12
- expires_in: 3600
13
- )
14
8
  @purchase_invoice = @client.purchase_invoice(company_id: @company_id)
15
9
  end
16
10
 
@@ -5,12 +5,6 @@ class BusinessCentral::Object::RequestTest < Minitest::Test
5
5
  def setup
6
6
  @url = BusinessCentral::Client::DEFAULT_URL
7
7
  @client = BusinessCentral::Client.new
8
- @client.authorize_from_token(
9
- token: '123',
10
- refresh_token: '456',
11
- expires_at: Time.now + 3600,
12
- expires_in: 3600
13
- )
14
8
  end
15
9
 
16
10
  def test_get_request
@@ -5,12 +5,6 @@ class BusinessCentral::Object::VendorTest < Minitest::Test
5
5
  def setup
6
6
  @company_id = '123456'
7
7
  @client = BusinessCentral::Client.new
8
- @client.authorize_from_token(
9
- token: '123',
10
- refresh_token: '456',
11
- expires_at: Time.now + 3600,
12
- expires_in: 3600
13
- )
14
8
  @vendor = @client.vendor(company_id: @company_id)
15
9
  end
16
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: business-central
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarrad Muir
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-04 00:00:00.000000000 Z
11
+ date: 2019-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -125,8 +125,13 @@ files:
125
125
  - lib/business_central/client.rb
126
126
  - lib/business_central/exceptions.rb
127
127
  - lib/business_central/object/account.rb
128
+ - lib/business_central/object/aged_account_payable.rb
129
+ - lib/business_central/object/aged_account_receivable.rb
130
+ - lib/business_central/object/balance_sheet.rb
128
131
  - lib/business_central/object/base.rb
132
+ - lib/business_central/object/cash_flow_statement.rb
129
133
  - lib/business_central/object/company.rb
134
+ - lib/business_central/object/company_information.rb
130
135
  - lib/business_central/object/helper.rb
131
136
  - lib/business_central/object/item.rb
132
137
  - lib/business_central/object/purchase_invoice.rb
@@ -139,6 +144,11 @@ files:
139
144
  - lib/core_ext/string.rb
140
145
  - test/business_central/client_test.rb
141
146
  - test/business_central/object/account_test.rb
147
+ - test/business_central/object/aged_account_payable_test.rb
148
+ - test/business_central/object/aged_account_receivable_test.rb
149
+ - test/business_central/object/balance_sheet_test.rb
150
+ - test/business_central/object/cash_flow_statement_test.rb
151
+ - test/business_central/object/company_information_test.rb
142
152
  - test/business_central/object/company_test.rb
143
153
  - test/business_central/object/item_test.rb
144
154
  - test/business_central/object/purchase_invoice_line_test.rb
@@ -178,6 +188,11 @@ summary: Integration library for Microsoft Dynamic365 business central
178
188
  test_files:
179
189
  - test/business_central/client_test.rb
180
190
  - test/business_central/object/account_test.rb
191
+ - test/business_central/object/aged_account_payable_test.rb
192
+ - test/business_central/object/aged_account_receivable_test.rb
193
+ - test/business_central/object/balance_sheet_test.rb
194
+ - test/business_central/object/cash_flow_statement_test.rb
195
+ - test/business_central/object/company_information_test.rb
181
196
  - test/business_central/object/company_test.rb
182
197
  - test/business_central/object/item_test.rb
183
198
  - test/business_central/object/purchase_invoice_line_test.rb