business-central 1.0.5 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +45 -32
- data/lib/business_central/client.rb +7 -52
- data/lib/business_central/exceptions.rb +11 -29
- data/lib/business_central/object/{attachment.rb → attachments.rb} +9 -11
- data/lib/business_central/object/base.rb +42 -114
- data/lib/business_central/object/companies.rb +19 -0
- data/lib/business_central/object/filter_query.rb +2 -0
- data/lib/business_central/object/object_helper.rb +10 -37
- data/lib/business_central/object/picture.rb +4 -40
- data/lib/business_central/object/request.rb +14 -15
- data/lib/business_central/object/response.rb +5 -1
- data/lib/business_central/object/url_builder.rb +16 -12
- data/lib/business_central/object/url_helper.rb +16 -2
- data/lib/business_central/version.rb +1 -1
- data/lib/business_central/web_service.rb +2 -0
- data/lib/business_central.rb +4 -55
- data/lib/refinements/strings.rb +42 -0
- data/test/business_central/client_test.rb +24 -0
- data/test/business_central/exceptions_test.rb +40 -0
- data/test/business_central/object/{attachment_test.rb → attachments_test.rb} +5 -6
- data/test/business_central/object/base_test.rb +59 -22
- data/test/business_central/object/{company_test.rb → companies_test.rb} +3 -21
- data/test/business_central/object/picture_test.rb +7 -16
- data/test/business_central/object/response_test.rb +5 -0
- data/test/business_central/web_service_test.rb +7 -2
- metadata +38 -167
- data/lib/business_central/object/account.rb +0 -13
- data/lib/business_central/object/aged_account_payable.rb +0 -13
- data/lib/business_central/object/aged_account_receivable.rb +0 -13
- data/lib/business_central/object/argument_helper.rb +0 -22
- data/lib/business_central/object/balance_sheet.rb +0 -13
- data/lib/business_central/object/cash_flow_statement.rb +0 -13
- data/lib/business_central/object/company.rb +0 -18
- data/lib/business_central/object/company_information.rb +0 -14
- data/lib/business_central/object/country_region.rb +0 -26
- data/lib/business_central/object/currency.rb +0 -29
- data/lib/business_central/object/customer.rb +0 -34
- data/lib/business_central/object/customer_financial_detail.rb +0 -13
- data/lib/business_central/object/customer_payment.rb +0 -43
- data/lib/business_central/object/customer_payment_journal.rb +0 -25
- data/lib/business_central/object/customer_sale.rb +0 -13
- data/lib/business_central/object/default_dimension.rb +0 -51
- data/lib/business_central/object/dimension.rb +0 -20
- data/lib/business_central/object/dimension_line.rb +0 -37
- data/lib/business_central/object/dimension_value.rb +0 -28
- data/lib/business_central/object/employee.rb +0 -21
- data/lib/business_central/object/general_ledger_entry.rb +0 -13
- data/lib/business_central/object/income_statement.rb +0 -13
- data/lib/business_central/object/irs1099_code.rb +0 -16
- data/lib/business_central/object/item.rb +0 -47
- data/lib/business_central/object/item_category.rb +0 -16
- data/lib/business_central/object/journal.rb +0 -29
- data/lib/business_central/object/journal_line.rb +0 -48
- data/lib/business_central/object/payment_method.rb +0 -16
- data/lib/business_central/object/payment_term.rb +0 -16
- data/lib/business_central/object/purchase_invoice.rb +0 -69
- data/lib/business_central/object/purchase_invoice_line.rb +0 -37
- data/lib/business_central/object/retained_earning_statement.rb +0 -13
- data/lib/business_central/object/sales_credit_memo.rb +0 -20
- data/lib/business_central/object/sales_credit_memo_line.rb +0 -30
- data/lib/business_central/object/sales_invoice.rb +0 -62
- data/lib/business_central/object/sales_invoice_line.rb +0 -30
- data/lib/business_central/object/sales_order.rb +0 -20
- data/lib/business_central/object/sales_order_line.rb +0 -30
- data/lib/business_central/object/sales_quote.rb +0 -20
- data/lib/business_central/object/sales_quote_line.rb +0 -30
- data/lib/business_central/object/shipment_method.rb +0 -16
- data/lib/business_central/object/subscription.rb +0 -16
- data/lib/business_central/object/tax_area.rb +0 -16
- data/lib/business_central/object/tax_group.rb +0 -16
- data/lib/business_central/object/time_registration_entry.rb +0 -16
- data/lib/business_central/object/trial_balance.rb +0 -13
- data/lib/business_central/object/units_of_measure.rb +0 -16
- data/lib/business_central/object/validation.rb +0 -57
- data/lib/business_central/object/vendor.rb +0 -42
- data/lib/business_central/object/vendor_purchase.rb +0 -13
- data/lib/core_ext/string.rb +0 -31
- data/test/business_central/object/account_test.rb +0 -67
- data/test/business_central/object/aged_account_payable_test.rb +0 -61
- data/test/business_central/object/aged_account_receivable_test.rb +0 -61
- data/test/business_central/object/balance_sheet_test.rb +0 -61
- data/test/business_central/object/cash_flow_statement_test.rb +0 -61
- data/test/business_central/object/company_information_test.rb +0 -81
- data/test/business_central/object/country_region_test.rb +0 -129
- data/test/business_central/object/currency_test.rb +0 -150
- data/test/business_central/object/customer_financial_detail_test.rb +0 -68
- data/test/business_central/object/customer_payment_journal_test.rb +0 -134
- data/test/business_central/object/customer_payment_test.rb +0 -141
- data/test/business_central/object/customer_sale_test.rb +0 -72
- data/test/business_central/object/customer_test.rb +0 -168
- data/test/business_central/object/default_dimension_test.rb +0 -170
- data/test/business_central/object/dimension_line_test.rb +0 -165
- data/test/business_central/object/dimension_test.rb +0 -65
- data/test/business_central/object/dimension_value_test.rb +0 -68
- data/test/business_central/object/employee_test.rb +0 -141
- data/test/business_central/object/general_ledger_entry_test.rb +0 -82
- data/test/business_central/object/income_statement_test.rb +0 -82
- data/test/business_central/object/irs1099_code_test.rb +0 -124
- data/test/business_central/object/item_category_test.rb +0 -122
- data/test/business_central/object/item_test.rb +0 -121
- data/test/business_central/object/journal_line_test.rb +0 -152
- data/test/business_central/object/journal_test.rb +0 -144
- data/test/business_central/object/payment_method_test.rb +0 -134
- data/test/business_central/object/payment_term_test.rb +0 -134
- data/test/business_central/object/purchase_invoice_line_test.rb +0 -123
- data/test/business_central/object/purchase_invoice_test.rb +0 -119
- data/test/business_central/object/retained_earning_statement_test.rb +0 -52
- data/test/business_central/object/sales_credit_memo_line_test.rb +0 -134
- data/test/business_central/object/sales_credit_memo_test.rb +0 -146
- data/test/business_central/object/sales_invoice_line_test.rb +0 -164
- data/test/business_central/object/sales_invoice_test.rb +0 -156
- data/test/business_central/object/sales_order_line_test.rb +0 -134
- data/test/business_central/object/sales_order_test.rb +0 -146
- data/test/business_central/object/sales_quote_line_test.rb +0 -134
- data/test/business_central/object/sales_quote_test.rb +0 -146
- data/test/business_central/object/shipment_method_test.rb +0 -133
- data/test/business_central/object/subscription_test.rb +0 -126
- data/test/business_central/object/tax_area_test.rb +0 -126
- data/test/business_central/object/tax_group_test.rb +0 -126
- data/test/business_central/object/time_registration_entry_test.rb +0 -126
- data/test/business_central/object/trial_balance_test.rb +0 -82
- data/test/business_central/object/units_of_measure_test.rb +0 -126
- data/test/business_central/object/validation_test.rb +0 -62
- data/test/business_central/object/vendor_purchase_test.rb +0 -82
- data/test/business_central/object/vendor_test.rb +0 -119
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module BusinessCentral
|
4
|
-
module Object
|
5
|
-
class SalesOrderLine < Base
|
6
|
-
OBJECT = 'salesOrderLines'
|
7
|
-
|
8
|
-
OBJECT_METHODS = %i[
|
9
|
-
get
|
10
|
-
post
|
11
|
-
patch
|
12
|
-
delete
|
13
|
-
].freeze
|
14
|
-
|
15
|
-
OBJECT_PARENTS = %w[
|
16
|
-
salesOrders
|
17
|
-
].freeze
|
18
|
-
|
19
|
-
def initialize(client, parent: 'salesOrders', parent_id:, **args)
|
20
|
-
return if !valid_parent?(parent)
|
21
|
-
|
22
|
-
super(client, args)
|
23
|
-
@parent_path << {
|
24
|
-
path: parent,
|
25
|
-
id: parent_id
|
26
|
-
}
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module BusinessCentral
|
4
|
-
module Object
|
5
|
-
class SalesQuote < Base
|
6
|
-
extend BusinessCentral::Object::ObjectHelper
|
7
|
-
|
8
|
-
OBJECT = 'salesQuotes'
|
9
|
-
|
10
|
-
OBJECT_METHODS = %i[
|
11
|
-
get
|
12
|
-
post
|
13
|
-
patch
|
14
|
-
delete
|
15
|
-
].freeze
|
16
|
-
|
17
|
-
navigation :sales_quote_line
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module BusinessCentral
|
4
|
-
module Object
|
5
|
-
class SalesQuoteLine < Base
|
6
|
-
OBJECT = 'salesQuoteLines'
|
7
|
-
|
8
|
-
OBJECT_METHODS = %i[
|
9
|
-
get
|
10
|
-
post
|
11
|
-
patch
|
12
|
-
delete
|
13
|
-
].freeze
|
14
|
-
|
15
|
-
OBJECT_PARENTS = %w[
|
16
|
-
salesQuotes
|
17
|
-
].freeze
|
18
|
-
|
19
|
-
def initialize(client, parent: 'salesQuotes', parent_id:, **args)
|
20
|
-
return if !valid_parent?(parent)
|
21
|
-
|
22
|
-
super(client, args)
|
23
|
-
@parent_path << {
|
24
|
-
path: parent,
|
25
|
-
id: parent_id
|
26
|
-
}
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module BusinessCentral
|
4
|
-
module Object
|
5
|
-
class Validation
|
6
|
-
def initialize(validation_rules = [], object_params = {})
|
7
|
-
@validation_rules = validation_rules
|
8
|
-
@object_params = object_params
|
9
|
-
@errors = []
|
10
|
-
end
|
11
|
-
|
12
|
-
def valid?
|
13
|
-
@validation_rules.each do |rules_key, rules_value|
|
14
|
-
rules_value.each do |validation_key, validation_value|
|
15
|
-
if required?(validation_key, validation_value, @object_params[rules_key].to_s)
|
16
|
-
@errors << { field: rules_key, message: 'is a required field' }
|
17
|
-
end
|
18
|
-
|
19
|
-
if exceeds_maximum_length?(validation_key, validation_value, @object_params[rules_key].to_s)
|
20
|
-
@errors << { field: rules_key, message: "has exceeded the maximum length #{validation_value}" }
|
21
|
-
end
|
22
|
-
|
23
|
-
if not_inclusive_of?(validation_key, validation_value, @object_params[rules_key].to_s)
|
24
|
-
@errors << { field: rules_key, message: "is not one of #{validation_value.join(', ')}" }
|
25
|
-
end
|
26
|
-
|
27
|
-
if date_type?(validation_key, validation_value, @object_params[rules_key])
|
28
|
-
@errors << { field: rules_key, message: 'is not a date' }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
raise InvalidObjectException, @errors if @errors.any?
|
34
|
-
|
35
|
-
true
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def required?(validation_rule, validation_value, value)
|
41
|
-
validation_rule == :required && validation_value == true && value.blank?
|
42
|
-
end
|
43
|
-
|
44
|
-
def exceeds_maximum_length?(validation_rule, validation_value, value)
|
45
|
-
validation_rule == :maximum_length && value.length > validation_value
|
46
|
-
end
|
47
|
-
|
48
|
-
def not_inclusive_of?(validation_rule, validation_value, value)
|
49
|
-
validation_rule == :inclusion_of && !validation_value.include?(value) && !value.blank?
|
50
|
-
end
|
51
|
-
|
52
|
-
def date_type?(validation_rule, validation_value, value)
|
53
|
-
validation_rule == :date && validation_value == true && !value.is_a?(Date) && !value.nil?
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module BusinessCentral
|
4
|
-
module Object
|
5
|
-
class Vendor < Base
|
6
|
-
extend BusinessCentral::Object::ObjectHelper
|
7
|
-
|
8
|
-
OBJECT = 'vendors'
|
9
|
-
|
10
|
-
OBJECT_VALIDATION = {
|
11
|
-
number: {
|
12
|
-
maximum_length: 20
|
13
|
-
},
|
14
|
-
display_name: {
|
15
|
-
maximum_length: 100
|
16
|
-
},
|
17
|
-
phone_number: {
|
18
|
-
maximum_length: 30
|
19
|
-
},
|
20
|
-
email: {
|
21
|
-
maximum_length: 80
|
22
|
-
},
|
23
|
-
website: {
|
24
|
-
maximum_length: 80
|
25
|
-
},
|
26
|
-
tax_registration_number: {
|
27
|
-
maximum_length: 20
|
28
|
-
}
|
29
|
-
}.freeze
|
30
|
-
|
31
|
-
OBJECT_METHODS = %i[
|
32
|
-
get
|
33
|
-
post
|
34
|
-
patch
|
35
|
-
delete
|
36
|
-
].freeze
|
37
|
-
|
38
|
-
navigation :default_dimension
|
39
|
-
navigation :picture
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
data/lib/core_ext/string.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class String
|
4
|
-
def blank?
|
5
|
-
empty? || /\A[[:space:]]*\z/.match?(self)
|
6
|
-
end
|
7
|
-
|
8
|
-
def present?
|
9
|
-
!blank?
|
10
|
-
end
|
11
|
-
|
12
|
-
# Convert string to CamelCase
|
13
|
-
def to_camel_case(uppercase_first_letter = false)
|
14
|
-
string = self
|
15
|
-
string = if uppercase_first_letter
|
16
|
-
string.sub(/^[a-z\d]*/, &:capitalize)
|
17
|
-
else
|
18
|
-
string.sub(/^(?:(?=\b|[A-Z_])|\w)/, &:downcase)
|
19
|
-
end
|
20
|
-
string.gsub(%r{(?:_|(/))([a-z\d]*)}) { "#{Regexp.last_match(1)}#{Regexp.last_match(2).capitalize}" }.gsub('/', '::')
|
21
|
-
end
|
22
|
-
|
23
|
-
# Convert string to snake_case
|
24
|
-
def to_snake_case
|
25
|
-
gsub(/::/, '/')
|
26
|
-
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
27
|
-
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
28
|
-
.tr('-', '_')
|
29
|
-
.downcase
|
30
|
-
end
|
31
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
# rake test TEST=test/business_central/object/account_test.rb
|
5
|
-
|
6
|
-
class BusinessCentral::Object::AccountTest < Minitest::Test
|
7
|
-
def setup
|
8
|
-
@company_id = '123456'
|
9
|
-
@client = BusinessCentral::Client.new
|
10
|
-
@client.authorize_from_token(
|
11
|
-
token: '123',
|
12
|
-
refresh_token: '456',
|
13
|
-
expires_at: Time.now + 3600,
|
14
|
-
expires_in: 3600
|
15
|
-
)
|
16
|
-
@account = @client.account(company_id: @company_id)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_find_all
|
20
|
-
stub_request(:get, /accounts/)
|
21
|
-
.to_return(
|
22
|
-
status: 200,
|
23
|
-
body: {
|
24
|
-
'value': [
|
25
|
-
{
|
26
|
-
displayName: 'account1'
|
27
|
-
}
|
28
|
-
]
|
29
|
-
}.to_json
|
30
|
-
)
|
31
|
-
|
32
|
-
response = @account.find_all
|
33
|
-
assert_equal response.first[:display_name], 'account1'
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_find_by_id
|
37
|
-
test_account_id = '123'
|
38
|
-
stub_request(:get, /accounts\(#{test_account_id}\)/)
|
39
|
-
.to_return(
|
40
|
-
status: 200,
|
41
|
-
body: {
|
42
|
-
displayName: 'account2'
|
43
|
-
}.to_json
|
44
|
-
)
|
45
|
-
|
46
|
-
response = @account.find_by_id(test_account_id)
|
47
|
-
assert_equal response[:display_name], 'account2'
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_create
|
51
|
-
assert_raises BusinessCentral::NoSupportedMethod do
|
52
|
-
@account.create({})
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_update
|
57
|
-
assert_raises BusinessCentral::NoSupportedMethod do
|
58
|
-
@account.update('123', {})
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_delete
|
63
|
-
assert_raises BusinessCentral::NoSupportedMethod do
|
64
|
-
@account.destroy('123')
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
# rake test TEST=test/business_central/object/aged_account_payable_test.rb
|
5
|
-
|
6
|
-
class BusinessCentral::Object::AgedAccountPayableTest < Minitest::Test
|
7
|
-
def setup
|
8
|
-
@company_id = '123456'
|
9
|
-
@client = BusinessCentral::Client.new
|
10
|
-
@aged_account_payable = @client.aged_account_payable(company_id: @company_id)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_find_all
|
14
|
-
stub_request(:get, /agedAccountsPayable/)
|
15
|
-
.to_return(
|
16
|
-
status: 200,
|
17
|
-
body: {
|
18
|
-
'value': [
|
19
|
-
{
|
20
|
-
name: 'vendor1'
|
21
|
-
}
|
22
|
-
]
|
23
|
-
}.to_json
|
24
|
-
)
|
25
|
-
|
26
|
-
response = @aged_account_payable.find_all
|
27
|
-
assert_equal response.first[:name], 'vendor1'
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_find_by_id
|
31
|
-
test_id = '123'
|
32
|
-
stub_request(:get, /agedAccountsPayable\(#{test_id}\)/)
|
33
|
-
.to_return(
|
34
|
-
status: 200,
|
35
|
-
body: {
|
36
|
-
name: 'vendor2'
|
37
|
-
}.to_json
|
38
|
-
)
|
39
|
-
|
40
|
-
response = @aged_account_payable.find_by_id(test_id)
|
41
|
-
assert_equal response[:name], 'vendor2'
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_create
|
45
|
-
assert_raises BusinessCentral::NoSupportedMethod do
|
46
|
-
@aged_account_payable.create({})
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_update
|
51
|
-
assert_raises BusinessCentral::NoSupportedMethod do
|
52
|
-
@aged_account_payable.update('123', {})
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_delete
|
57
|
-
assert_raises BusinessCentral::NoSupportedMethod do
|
58
|
-
@aged_account_payable.destroy('123')
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
# rake test TEST=test/business_central/object/aged_account_receivable_test.rb
|
5
|
-
|
6
|
-
class BusinessCentral::Object::AgedAccountReceivableTest < Minitest::Test
|
7
|
-
def setup
|
8
|
-
@company_id = '123456'
|
9
|
-
@client = BusinessCentral::Client.new
|
10
|
-
@aged_account_receivable = @client.aged_account_receivable(company_id: @company_id)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_find_all
|
14
|
-
stub_request(:get, /agedAccountsReceivable/)
|
15
|
-
.to_return(
|
16
|
-
status: 200,
|
17
|
-
body: {
|
18
|
-
'value': [
|
19
|
-
{
|
20
|
-
name: 'customer1'
|
21
|
-
}
|
22
|
-
]
|
23
|
-
}.to_json
|
24
|
-
)
|
25
|
-
|
26
|
-
response = @aged_account_receivable.find_all
|
27
|
-
assert_equal response.first[:name], 'customer1'
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_find_by_id
|
31
|
-
test_id = '123'
|
32
|
-
stub_request(:get, /agedAccountsReceivable\(#{test_id}\)/)
|
33
|
-
.to_return(
|
34
|
-
status: 200,
|
35
|
-
body: {
|
36
|
-
name: 'customer2'
|
37
|
-
}.to_json
|
38
|
-
)
|
39
|
-
|
40
|
-
response = @aged_account_receivable.find_by_id(test_id)
|
41
|
-
assert_equal response[:name], 'customer2'
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_create
|
45
|
-
assert_raises BusinessCentral::NoSupportedMethod do
|
46
|
-
@aged_account_receivable.create({})
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_update
|
51
|
-
assert_raises BusinessCentral::NoSupportedMethod do
|
52
|
-
@aged_account_receivable.update('123', {})
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_delete
|
57
|
-
assert_raises BusinessCentral::NoSupportedMethod do
|
58
|
-
@aged_account_receivable.destroy('123')
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
# rake test TEST=test/business_central/object/balance_sheet_test.rb
|
5
|
-
|
6
|
-
class BusinessCentral::Object::BalanceSheetTest < Minitest::Test
|
7
|
-
def setup
|
8
|
-
@company_id = '123456'
|
9
|
-
@client = BusinessCentral::Client.new
|
10
|
-
@balance_sheet = @client.balance_sheet(company_id: @company_id)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_find_all
|
14
|
-
stub_request(:get, /balanceSheet/)
|
15
|
-
.to_return(
|
16
|
-
status: 200,
|
17
|
-
body: {
|
18
|
-
'value': [
|
19
|
-
{
|
20
|
-
display: 'balance item 1'
|
21
|
-
}
|
22
|
-
]
|
23
|
-
}.to_json
|
24
|
-
)
|
25
|
-
|
26
|
-
response = @balance_sheet.find_all
|
27
|
-
assert_equal response.first[:display], 'balance item 1'
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_find_by_id
|
31
|
-
test_id = '123'
|
32
|
-
stub_request(:get, /balanceSheet\(#{test_id}\)/)
|
33
|
-
.to_return(
|
34
|
-
status: 200,
|
35
|
-
body: {
|
36
|
-
display: 'balance item 2'
|
37
|
-
}.to_json
|
38
|
-
)
|
39
|
-
|
40
|
-
response = @balance_sheet.find_by_id(test_id)
|
41
|
-
assert_equal response[:display], 'balance item 2'
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_create
|
45
|
-
assert_raises BusinessCentral::NoSupportedMethod do
|
46
|
-
@balance_sheet.create({})
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_update
|
51
|
-
assert_raises BusinessCentral::NoSupportedMethod do
|
52
|
-
@balance_sheet.update('123', {})
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_delete
|
57
|
-
assert_raises BusinessCentral::NoSupportedMethod do
|
58
|
-
@balance_sheet.destroy('123')
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
# rake test TEST=test/business_central/object/cash_flow_statement_test.rb
|
5
|
-
|
6
|
-
class BusinessCentral::Object::CashFlowStatementTest < Minitest::Test
|
7
|
-
def setup
|
8
|
-
@company_id = '123456'
|
9
|
-
@client = BusinessCentral::Client.new
|
10
|
-
@cash_flow_statement = @client.cash_flow_statement(company_id: @company_id)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_find_all
|
14
|
-
stub_request(:get, /cashFlowStatement/)
|
15
|
-
.to_return(
|
16
|
-
status: 200,
|
17
|
-
body: {
|
18
|
-
'value': [
|
19
|
-
{
|
20
|
-
display: 'assets 1'
|
21
|
-
}
|
22
|
-
]
|
23
|
-
}.to_json
|
24
|
-
)
|
25
|
-
|
26
|
-
response = @cash_flow_statement.find_all
|
27
|
-
assert_equal response.first[:display], 'assets 1'
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_find_by_id
|
31
|
-
test_id = '123'
|
32
|
-
stub_request(:get, /cashFlowStatement\(#{test_id}\)/)
|
33
|
-
.to_return(
|
34
|
-
status: 200,
|
35
|
-
body: {
|
36
|
-
display: 'assets 2'
|
37
|
-
}.to_json
|
38
|
-
)
|
39
|
-
|
40
|
-
response = @cash_flow_statement.find_by_id(test_id)
|
41
|
-
assert_equal response[:display], 'assets 2'
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_create
|
45
|
-
assert_raises BusinessCentral::NoSupportedMethod do
|
46
|
-
@cash_flow_statement.create({})
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_update
|
51
|
-
assert_raises BusinessCentral::NoSupportedMethod do
|
52
|
-
@cash_flow_statement.update('123', {})
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_delete
|
57
|
-
assert_raises BusinessCentral::NoSupportedMethod do
|
58
|
-
@cash_flow_statement.destroy('123')
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|