rconomic 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +40 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +14 -3
  5. data/CHANGELOG.md +28 -0
  6. data/Gemfile +5 -4
  7. data/Guardfile +9 -4
  8. data/README.md +23 -4
  9. data/Rakefile +5 -5
  10. data/gemfiles/Gemfile.ruby-2.0 +14 -0
  11. data/lib/economic/account.rb +3 -3
  12. data/lib/economic/cash_book.rb +4 -7
  13. data/lib/economic/cash_book_entry.rb +4 -24
  14. data/lib/economic/company.rb +61 -0
  15. data/lib/economic/creditor.rb +4 -5
  16. data/lib/economic/creditor_contact.rb +5 -6
  17. data/lib/economic/creditor_entry.rb +1 -3
  18. data/lib/economic/current_invoice.rb +14 -21
  19. data/lib/economic/current_invoice_line.rb +4 -13
  20. data/lib/economic/debtor.rb +10 -11
  21. data/lib/economic/debtor_contact.rb +7 -8
  22. data/lib/economic/debtor_entry.rb +1 -3
  23. data/lib/economic/endpoint.rb +36 -6
  24. data/lib/economic/entity/handle.rb +54 -29
  25. data/lib/economic/entity/mapper.rb +1 -1
  26. data/lib/economic/entity.rb +26 -29
  27. data/lib/economic/entry.rb +1 -2
  28. data/lib/economic/invoice.rb +15 -8
  29. data/lib/economic/order.rb +2 -4
  30. data/lib/economic/product.rb +73 -0
  31. data/lib/economic/proxies/account_proxy.rb +2 -4
  32. data/lib/economic/proxies/actions/debtor_contact/all.rb +63 -0
  33. data/lib/economic/proxies/actions/find_by_ci_number.rb +1 -3
  34. data/lib/economic/proxies/actions/find_by_date_interval.rb +3 -6
  35. data/lib/economic/proxies/actions/find_by_handle_with_number.rb +1 -1
  36. data/lib/economic/proxies/actions/find_by_name.rb +1 -1
  37. data/lib/economic/proxies/actions/find_by_number.rb +2 -4
  38. data/lib/economic/proxies/actions/find_by_telephone_and_fax_number.rb +1 -3
  39. data/lib/economic/proxies/cash_book_entry_proxy.rb +19 -22
  40. data/lib/economic/proxies/cash_book_proxy.rb +5 -10
  41. data/lib/economic/proxies/company_proxy.rb +9 -0
  42. data/lib/economic/proxies/creditor_contact_proxy.rb +2 -2
  43. data/lib/economic/proxies/creditor_entry_proxy.rb +8 -14
  44. data/lib/economic/proxies/creditor_proxy.rb +8 -11
  45. data/lib/economic/proxies/current_invoice_line_proxy.rb +2 -2
  46. data/lib/economic/proxies/current_invoice_proxy.rb +3 -3
  47. data/lib/economic/proxies/debtor_contact_proxy.rb +6 -2
  48. data/lib/economic/proxies/debtor_entry_proxy.rb +6 -10
  49. data/lib/economic/proxies/debtor_proxy.rb +40 -55
  50. data/lib/economic/proxies/entity_proxy.rb +15 -15
  51. data/lib/economic/proxies/entry_proxy.rb +10 -16
  52. data/lib/economic/proxies/invoice_proxy.rb +3 -3
  53. data/lib/economic/proxies/order_proxy.rb +3 -3
  54. data/lib/economic/proxies/product_proxy.rb +11 -0
  55. data/lib/economic/session.rb +48 -21
  56. data/lib/economic/support/string.rb +5 -5
  57. data/lib/rconomic/version.rb +1 -1
  58. data/lib/rconomic.rb +39 -34
  59. data/lib/savon_ext/request.rb +17 -0
  60. data/rconomic.gemspec +8 -7
  61. data/spec/economic/account_spec.rb +3 -3
  62. data/spec/economic/cash_book_entry_spec.rb +26 -3
  63. data/spec/economic/cash_book_spec.rb +7 -7
  64. data/spec/economic/company_spec.rb +20 -0
  65. data/spec/economic/creditor_contact_spec.rb +4 -5
  66. data/spec/economic/creditor_entry_spec.rb +20 -0
  67. data/spec/economic/creditor_spec.rb +3 -3
  68. data/spec/economic/current_invoice_line_spec.rb +3 -3
  69. data/spec/economic/current_invoice_spec.rb +19 -19
  70. data/spec/economic/debtor_contact_spec.rb +4 -5
  71. data/spec/economic/debtor_entry_spec.rb +1 -1
  72. data/spec/economic/debtor_spec.rb +13 -13
  73. data/spec/economic/endpoint_spec.rb +27 -11
  74. data/spec/economic/entity/handle_spec.rb +10 -23
  75. data/spec/economic/entity/mapper_spec.rb +26 -30
  76. data/spec/economic/entity_spec.rb +36 -31
  77. data/spec/economic/entry_spec.rb +1 -1
  78. data/spec/economic/invoice_spec.rb +49 -7
  79. data/spec/economic/order_spec.rb +4 -4
  80. data/spec/economic/product_spec.rb +72 -0
  81. data/spec/economic/proxies/account_proxy_spec.rb +74 -0
  82. data/spec/economic/proxies/actions/debtor_contact/all_spec.rb +26 -0
  83. data/spec/economic/proxies/actions/find_by_name_spec.rb +6 -7
  84. data/spec/economic/proxies/cash_book_entry_proxy_spec.rb +27 -29
  85. data/spec/economic/proxies/cash_book_proxy_spec.rb +14 -22
  86. data/spec/economic/proxies/company_proxy_spec.rb +47 -0
  87. data/spec/economic/proxies/creditor_contact_proxy_spec.rb +11 -5
  88. data/spec/economic/proxies/creditor_entry_proxy_spec.rb +12 -12
  89. data/spec/economic/proxies/creditor_proxy_spec.rb +15 -15
  90. data/spec/economic/proxies/current_invoice_line_proxy_spec.rb +10 -4
  91. data/spec/economic/proxies/current_invoice_proxy_spec.rb +37 -19
  92. data/spec/economic/proxies/debtor_contact_proxy_spec.rb +8 -4
  93. data/spec/economic/proxies/debtor_entry_proxy_spec.rb +21 -11
  94. data/spec/economic/proxies/debtor_proxy_spec.rb +81 -40
  95. data/spec/economic/proxies/entry_proxy_spec.rb +17 -14
  96. data/spec/economic/proxies/invoice_proxy_spec.rb +24 -10
  97. data/spec/economic/proxies/order_proxy_spec.rb +20 -10
  98. data/spec/economic/proxies/product_proxy_spec.rb +86 -0
  99. data/spec/economic/session_spec.rb +74 -35
  100. data/spec/fixtures/account_get_all/multiple.xml +15 -0
  101. data/spec/fixtures/account_get_all/none.xml +8 -0
  102. data/spec/fixtures/account_get_all/single.xml +12 -0
  103. data/spec/fixtures/account_get_data_array/multiple.xml +69 -0
  104. data/spec/fixtures/company_get/success.xml +10 -0
  105. data/spec/fixtures/company_get_data/success.xml +32 -0
  106. data/spec/fixtures/current_invoice_line_create_from_data/success.xml +6 -37
  107. data/spec/fixtures/debtor_create_from_data/success.xml +5 -52
  108. data/spec/fixtures/debtor_get_orders/none.xml +9 -0
  109. data/spec/fixtures/product_create_from_data/success.xml +37 -0
  110. data/spec/fixtures/product_find_by_number/found.xml +10 -0
  111. data/spec/fixtures/product_find_by_number/not_found.xml +6 -0
  112. data/spec/fixtures/product_get_all/multiple.xml +15 -0
  113. data/spec/fixtures/product_get_all/single.xml +12 -0
  114. data/spec/fixtures/product_get_data/success.xml +37 -0
  115. data/spec/fixtures/product_get_data_array/multiple.xml +69 -0
  116. data/spec/spec_helper.rb +6 -9
  117. data/spec/support/factories.rb +14 -14
  118. metadata +54 -9
@@ -1,7 +1,6 @@
1
- require './spec/spec_helper'
1
+ require "./spec/spec_helper"
2
2
 
3
3
  describe Economic::InvoiceProxy do
4
-
5
4
  let(:session) { make_session }
6
5
  subject { Economic::InvoiceProxy.new(session) }
7
6
 
@@ -27,12 +26,16 @@ describe Economic::InvoiceProxy do
27
26
 
28
27
  describe ".find" do
29
28
  it "gets invoice data from API" do
30
- mock_request('Invoice_GetData', {'entityHandle' => {'Number' => 42}}, :success)
29
+ mock_request(
30
+ "Invoice_GetData",
31
+ {"entityHandle" => {"Number" => 42}},
32
+ :success
33
+ )
31
34
  subject.find(42)
32
35
  end
33
36
 
34
37
  it "returns Invoice object" do
35
- stub_request('Invoice_GetData', nil, :success)
38
+ stub_request("Invoice_GetData", nil, :success)
36
39
  expect(subject.find(42)).to be_instance_of(Economic::Invoice)
37
40
  end
38
41
  end
@@ -42,26 +45,37 @@ describe Economic::InvoiceProxy do
42
45
  let(:unto) { Time.now }
43
46
 
44
47
  it "should be able to return a single current invoice" do
45
- mock_request('Invoice_FindByDateInterval', {'first' => from.iso8601, 'last' => unto.iso8601}, :single)
46
- mock_request('Invoice_GetDataArray', :any, :single)
48
+ mock_request(
49
+ "Invoice_FindByDateInterval",
50
+ {"first" => from.iso8601, "last" => unto.iso8601},
51
+ :single
52
+ )
53
+ mock_request("Invoice_GetDataArray", :any, :single)
47
54
  results = subject.find_by_date_interval(from, unto)
48
55
  expect(results.size).to eq(1)
49
56
  expect(results.first).to be_instance_of(Economic::Invoice)
50
57
  end
51
58
 
52
59
  it "should be able to return multiple invoices" do
53
- mock_request('Invoice_FindByDateInterval', {'first' => from.iso8601, 'last' => unto.iso8601}, :many)
54
- mock_request('Invoice_GetDataArray', :any, :multiple)
60
+ mock_request(
61
+ "Invoice_FindByDateInterval",
62
+ {"first" => from.iso8601, "last" => unto.iso8601},
63
+ :many
64
+ )
65
+ mock_request("Invoice_GetDataArray", :any, :multiple)
55
66
  results = subject.find_by_date_interval(from, unto)
56
67
  expect(results.size).to eq(2)
57
68
  expect(results.first).to be_instance_of(Economic::Invoice)
58
69
  end
59
70
 
60
71
  it "should be able to return nothing" do
61
- mock_request('Invoice_FindByDateInterval', {'first' => from.iso8601, 'last' => unto.iso8601}, :none)
72
+ mock_request(
73
+ "Invoice_FindByDateInterval",
74
+ {"first" => from.iso8601, "last" => unto.iso8601},
75
+ :none
76
+ )
62
77
  results = subject.find_by_date_interval(from, unto)
63
78
  expect(results.size).to eq(0)
64
79
  end
65
-
66
80
  end
67
81
  end
@@ -1,7 +1,6 @@
1
- require './spec/spec_helper'
1
+ require "./spec/spec_helper"
2
2
 
3
3
  describe Economic::OrderProxy do
4
-
5
4
  let(:session) { make_session }
6
5
  subject { Economic::OrderProxy.new(session) }
7
6
 
@@ -27,12 +26,12 @@ describe Economic::OrderProxy do
27
26
 
28
27
  describe ".find" do
29
28
  it "gets order data from API" do
30
- mock_request('Order_GetData', {'entityHandle' => {'Id' => 42}}, :success)
29
+ mock_request("Order_GetData", {"entityHandle" => {"Id" => 42}}, :success)
31
30
  subject.find(42)
32
31
  end
33
32
 
34
33
  it "returns Order object" do
35
- stub_request('Order_GetData', nil, :success)
34
+ stub_request("Order_GetData", nil, :success)
36
35
  expect(subject.find(42)).to be_instance_of(Economic::Order)
37
36
  end
38
37
  end
@@ -42,26 +41,37 @@ describe Economic::OrderProxy do
42
41
  let(:unto) { Time.now }
43
42
 
44
43
  it "should be able to return a single current order" do
45
- mock_request('Order_FindByDateInterval', {'first' => from.iso8601, 'last' => unto.iso8601}, :single)
46
- mock_request('Order_GetDataArray', :any, :single)
44
+ mock_request(
45
+ "Order_FindByDateInterval",
46
+ {"first" => from.iso8601, "last" => unto.iso8601},
47
+ :single
48
+ )
49
+ mock_request("Order_GetDataArray", :any, :single)
47
50
  results = subject.find_by_date_interval(from, unto)
48
51
  expect(results.size).to eq(1)
49
52
  expect(results.first).to be_instance_of(Economic::Order)
50
53
  end
51
54
 
52
55
  it "should be able to return multiple orders" do
53
- mock_request('Order_FindByDateInterval', {'first' => from.iso8601, 'last' => unto.iso8601}, :many)
54
- mock_request('Order_GetDataArray', :any, :multiple)
56
+ mock_request(
57
+ "Order_FindByDateInterval",
58
+ {"first" => from.iso8601, "last" => unto.iso8601},
59
+ :many
60
+ )
61
+ mock_request("Order_GetDataArray", :any, :multiple)
55
62
  results = subject.find_by_date_interval(from, unto)
56
63
  expect(results.size).to eq(2)
57
64
  expect(results.first).to be_instance_of(Economic::Order)
58
65
  end
59
66
 
60
67
  it "should be able to return nothing" do
61
- mock_request('Order_FindByDateInterval', {'first' => from.iso8601, 'last' => unto.iso8601}, :none)
68
+ mock_request(
69
+ "Order_FindByDateInterval",
70
+ {"first" => from.iso8601, "last" => unto.iso8601},
71
+ :none
72
+ )
62
73
  results = subject.find_by_date_interval(from, unto)
63
74
  expect(results.size).to eq(0)
64
75
  end
65
-
66
76
  end
67
77
  end
@@ -0,0 +1,86 @@
1
+ require "./spec/spec_helper"
2
+
3
+ describe Economic::ProductProxy do
4
+ let(:session) { make_session }
5
+ subject { Economic::ProductProxy.new(session) }
6
+
7
+ describe "new" do
8
+ it "stores session" do
9
+ expect(subject.session).to equal(session)
10
+ end
11
+ end
12
+
13
+ describe "find" do
14
+ it "gets product data from API" do
15
+ mock_request(
16
+ "Product_GetData",
17
+ {"entityHandle" => {"Number" => 42}},
18
+ :success
19
+ )
20
+ subject.find(42)
21
+ end
22
+
23
+ it "returns Product object" do
24
+ stub_request("Product_GetData", nil, :success)
25
+ expect(subject.find(42)).to be_instance_of(Economic::Product)
26
+ end
27
+ end
28
+
29
+ describe "find_by_number" do
30
+ it "can find a product" do
31
+ mock_request("Product_FindByNumber", {"number" => "1"}, :found)
32
+ result = subject.find_by_number("1")
33
+ expect(result).to be_instance_of(Economic::Product)
34
+ expect(result.number).to eq("1")
35
+ expect(result.partial).to be_truthy
36
+ expect(result.persisted).to be_truthy
37
+ expect(result.handle).to eq(Economic::Entity::Handle.new(:number => "1"))
38
+ end
39
+
40
+ it "returns nil when there is no product" do
41
+ mock_request("Product_FindByNumber", {"number" => "1"}, :not_found)
42
+ result = subject.find_by_number("1")
43
+ expect(result).to be_nil
44
+ end
45
+ end
46
+
47
+ describe "build" do
48
+ subject { session.products.build }
49
+
50
+ it "instantiates a new Product" do
51
+ expect(subject).to be_instance_of(Economic::Product)
52
+ end
53
+
54
+ it "assigns the session to the Product" do
55
+ expect(subject.session).to equal(session)
56
+ end
57
+ end
58
+
59
+ describe "#entity_class" do
60
+ it "should return Economic::Product" do
61
+ expect(Economic::ProductProxy.entity_class).to eq(Economic::Product)
62
+ end
63
+ end
64
+
65
+ describe ".all" do
66
+ it "returns a single product" do
67
+ stub_request("Product_GetAll", nil, :single)
68
+ mock_request(
69
+ "Product_GetData",
70
+ {"entityHandle" => {"Number" => "1"}},
71
+ :success
72
+ )
73
+ all = subject.all
74
+ expect(all.size).to eq(1)
75
+ expect(all.first).to be_instance_of(Economic::Product)
76
+ end
77
+
78
+ it "returns multiple products" do
79
+ mock_request("Product_GetAll", nil, :multiple)
80
+ stub_request("Product_GetDataArray", nil, :multiple)
81
+ all = subject.all
82
+ expect(all.size).to eq(2)
83
+ expect(all.first).to be_instance_of(Economic::Product)
84
+ end
85
+ end
86
+ end
@@ -1,32 +1,43 @@
1
- require './spec/spec_helper'
1
+ require "./spec/spec_helper"
2
2
 
3
3
  describe Economic::Session do
4
- let(:credentials) { [123456, 'api', 'passw0rd'] }
4
+ let(:credentials) { [123_456, "api", "passw0rd"] }
5
5
  subject { Economic::Session.new }
6
6
 
7
7
  let(:endpoint) { subject.endpoint }
8
8
 
9
9
  describe "new" do
10
10
  describe "legacy connect" do
11
- subject { Economic::Session.new *credentials }
11
+ subject { Economic::Session.new(*credentials) }
12
12
  it "should store authentication details" do
13
- expect(subject.agreement_number).to eq(123456)
14
- expect(subject.user_name).to eq('api')
15
- expect(subject.password).to eq('passw0rd')
13
+ expect(subject.agreement_number).to eq(123_456)
14
+ expect(subject.user_name).to eq("api")
15
+ expect(subject.password).to eq("passw0rd")
16
+ end
17
+
18
+ it "can also store an app_id" do
19
+ session = Economic::Session.new(*credentials, "app_id")
20
+ expect(session.app_identifier).to eq("app_id")
16
21
  end
17
22
  end
18
23
 
19
24
  it "yields the endpoint if a block is given" do
20
25
  endpoint_mock = double("Endpoint")
21
- Economic::Endpoint.stub(:new).and_return(endpoint_mock)
22
- expect{|b|
23
- Economic::Session.new(123456, 'api', 'passw0rd', &b)
26
+ allow(Economic::Endpoint).to receive(:new).and_return(endpoint_mock)
27
+ expect {|b|
28
+ Economic::Session.new(123_456, "api", "passw0rd", &b)
24
29
  }.to yield_with_args(endpoint_mock)
25
30
  end
26
31
  end
27
32
 
28
33
  describe "connect" do
29
- let(:authentication_details) { {:agreementNumber => 123456, :userName => 'api', :password => 'passw0rd'} }
34
+ let(:authentication_details) {
35
+ {
36
+ :agreementNumber => 123_456,
37
+ :userName => "api",
38
+ :password => "passw0rd"
39
+ }
40
+ }
30
41
 
31
42
  it "can connect old-style" do
32
43
  mock_request(:connect, authentication_details, :success)
@@ -41,30 +52,38 @@ describe Economic::Session do
41
52
 
42
53
  it "stores the authentication token for later requests" do
43
54
  response = {
44
- :headers => {'Set-Cookie' => 'cookie value from e-conomic'},
55
+ :headers => {"Set-Cookie" => "cookie value from e-conomic"},
45
56
  :body => fixture(:connect, :success)
46
57
  }
47
- stub_request('Connect', authentication_details, response)
58
+ stub_request("Connect", authentication_details, response)
48
59
 
49
60
  subject.connect_with_credentials(*credentials)
50
61
 
51
- expect(subject.authentication_token.collect { |cookie|
62
+ expect(subject.authentication_cookies.collect { |cookie|
52
63
  cookie.name_and_value.split("=").last
53
64
  }).to eq(["cookie value from e-conomic"])
54
65
  end
55
66
 
56
67
  it "updates the authentication token for new sessions" do
57
- stub_request("Connect", nil, {:headers => {"Set-Cookie" => "authentication token"}})
68
+ stub_request(
69
+ "Connect",
70
+ nil,
71
+ :headers => {"Set-Cookie" => "authentication token"}
72
+ )
58
73
  subject.connect_with_credentials(*credentials)
59
74
 
60
- stub_request('Connect', nil, {:headers => {"Set-Cookie" => "another token"}})
75
+ stub_request(
76
+ "Connect",
77
+ nil,
78
+ :headers => {"Set-Cookie" => "another token"}
79
+ )
61
80
  other_session = Economic::Session.new
62
- other_session.connect_with_credentials(123456, 'api', 'passw0rd')
81
+ other_session.connect_with_credentials(123_456, "api", "passw0rd")
63
82
 
64
- expect(subject.authentication_token.collect { |cookie|
83
+ expect(subject.authentication_cookies.collect { |cookie|
65
84
  cookie.name_and_value.split("=").last
66
85
  }).to eq(["authentication token"])
67
- expect(other_session.authentication_token.collect { |cookie|
86
+ expect(other_session.authentication_cookies.collect { |cookie|
68
87
  cookie.name_and_value.split("=").last
69
88
  }).to eq(["another token"])
70
89
  end
@@ -77,7 +96,12 @@ describe Economic::Session do
77
96
 
78
97
  describe "connecting with access ID" do
79
98
  # As per http://www.e-conomic.com/developer/tutorials
80
- let(:authentication_details) { {:appToken => 'the_private_app_id', :token => 'the_access_id_you_got_from_the_grant'} }
99
+ let(:authentication_details) {
100
+ {
101
+ :appToken => "the_private_app_id",
102
+ :token => "the_access_id_you_got_from_the_grant"
103
+ }
104
+ }
81
105
  let(:private_app_id) { authentication_details[:appToken] }
82
106
  let(:access_id) { authentication_details[:token] }
83
107
  subject { Economic::Session.new }
@@ -88,36 +112,47 @@ describe Economic::Session do
88
112
 
89
113
  it "stores the authentication token for later requests" do
90
114
  response = {
91
- :headers => {'Set-Cookie' => 'cookie value from e-conomic'},
115
+ :headers => {"Set-Cookie" => "cookie value from e-conomic"},
92
116
  :body => fixture(:connect_with_token, :success)
93
117
  }
94
- stub_request('ConnectWithToken', authentication_details, response)
118
+ stub_request("ConnectWithToken", authentication_details, response)
95
119
 
96
120
  subject.connect_with_token private_app_id, access_id
97
121
 
98
- expect(subject.authentication_token.collect { |cookie|
122
+ expect(subject.authentication_cookies.collect { |cookie|
99
123
  cookie.name_and_value.split("=").last
100
124
  }).to eq(["cookie value from e-conomic"])
101
125
  end
102
126
 
103
127
  it "updates the authentication token for new sessions" do
104
- stub_request("ConnectWithToken", nil, {:headers => {"Set-Cookie" => "authentication token"}})
128
+ stub_request(
129
+ "ConnectWithToken",
130
+ nil,
131
+ :headers => {"Set-Cookie" => "authentication token"}
132
+ )
105
133
  subject.connect_with_token private_app_id, access_id
106
134
 
107
- stub_request('Connect', nil, {:headers => {"Set-Cookie" => "another token"}})
135
+ stub_request(
136
+ "Connect",
137
+ nil,
138
+ :headers => {"Set-Cookie" => "another token"}
139
+ )
108
140
  other_session = Economic::Session.new
109
- other_session.connect_with_credentials(123456, 'api', 'passw0rd')
141
+ other_session.connect_with_credentials(123_456, "api", "passw0rd")
110
142
 
111
- expect(subject.authentication_token.collect { |cookie|
143
+ expect(subject.authentication_cookies.collect { |cookie|
112
144
  cookie.name_and_value.split("=").last
113
145
  }).to eq(["authentication token"])
114
- expect(other_session.authentication_token.collect { |cookie|
146
+ expect(other_session.authentication_cookies.collect { |cookie|
115
147
  cookie.name_and_value.split("=").last
116
148
  }).to eq(["another token"])
117
149
  end
118
150
 
119
151
  it "doesn't use existing authentication details when connecting" do
120
- expect(endpoint).to receive(:call).with(:connect_with_token, instance_of(Hash))
152
+ expect(endpoint).to receive(:call).with(
153
+ :connect_with_token,
154
+ instance_of(Hash)
155
+ )
121
156
  subject.connect_with_token private_app_id, access_id
122
157
  end
123
158
  end
@@ -146,7 +181,9 @@ describe Economic::Session do
146
181
 
147
182
  describe "current_invoices" do
148
183
  it "returns an CurrentInvoiceProxy" do
149
- expect(subject.current_invoices).to be_instance_of(Economic::CurrentInvoiceProxy)
184
+ expect(subject.current_invoices).to be_instance_of(
185
+ Economic::CurrentInvoiceProxy
186
+ )
150
187
  end
151
188
 
152
189
  it "memoizes the proxy" do
@@ -186,12 +223,14 @@ describe Economic::Session do
186
223
 
187
224
  it "sends data if given" do
188
225
  mock_request(:current_invoice_get_all, {:bar => :baz}, :none)
189
- subject.request(:current_invoice_get_all, {:bar => :baz})
226
+ subject.request(:current_invoice_get_all, :bar => :baz)
190
227
  end
191
228
 
192
229
  it "returns a hash with data" do
193
230
  stub_request(:current_invoice_get_all, nil, :single)
194
- expect(subject.request(:current_invoice_get_all)).to eq({:current_invoice_handle => {:id => "1"}})
231
+ expect(subject.request(:current_invoice_get_all)).to eq(
232
+ :current_invoice_handle => {:id => "1"}
233
+ )
195
234
  end
196
235
 
197
236
  it "returns an empty hash if no data returned" do
@@ -204,22 +243,22 @@ describe Economic::Session do
204
243
  let(:endpoint) { double("Endpoint") }
205
244
 
206
245
  before :each do
207
- Economic::Endpoint.stub(:new).and_return(endpoint)
246
+ allow(Economic::Endpoint).to receive(:new).and_return(endpoint)
208
247
  end
209
248
 
210
249
  it "sets the log_level option of the endpoint" do
211
- endpoint.should_receive(:log_level=).with(:info)
250
+ expect(endpoint).to receive(:log_level=).with(:info)
212
251
  subject.log_level = :info
213
252
  end
214
253
 
215
254
  it "sets the log option of the endpoint" do
216
- endpoint.should_receive(:log=).with(true)
255
+ expect(endpoint).to receive(:log=).with(true)
217
256
  subject.log = true
218
257
  end
219
258
 
220
259
  it "sets the logger option of the boolean" do
221
260
  logger = double("MyLogger")
222
- endpoint.should_receive(:logger=).with(logger)
261
+ expect(endpoint).to receive(:logger=).with(logger)
223
262
  subject.logger = logger
224
263
  end
225
264
  end
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
3
+ <soap:Body>
4
+ <Account_GetAllResponse xmlns="http://e-conomic.com">
5
+ <Account_GetAllResult>
6
+ <AccountHandle>
7
+ <Number>37</Number>
8
+ </AccountHandle>
9
+ <AccountHandle>
10
+ <Number>42</Number>
11
+ </AccountHandle>
12
+ </Account_GetAllResult>
13
+ </Account_GetAllResponse>
14
+ </soap:Body>
15
+ </soap:Envelope>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
3
+ <soap:Body>
4
+ <Account_GetAllResponse xmlns="http://e-conomic.com">
5
+ <Account_GetAllResult />
6
+ </Account_GetAllResponse>
7
+ </soap:Body>
8
+ </soap:Envelope>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
3
+ <soap:Body>
4
+ <Account_GetAllResponse xmlns="http://e-conomic.com">
5
+ <Account_GetAllResult>
6
+ <AccountHandle>
7
+ <Number>1</Number>
8
+ </AccountHandle>
9
+ </Account_GetAllResult>
10
+ </Account_GetAllResponse>
11
+ </soap:Body>
12
+ </soap:Envelope>
@@ -0,0 +1,69 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
3
+ <soap:Body>
4
+ <Account_GetDataArrayResponse xmlns="http://e-conomic.com">
5
+ <Account_GetDataArrayResult>
6
+ <AccountData>
7
+ <Handle>
8
+ <Number>37</Number>
9
+ </Handle>
10
+ <Number>37</Number>
11
+ <Name>Some account</Name>
12
+ <Type>ProfitAndLoss or Status or TotalFrom or Heading or HeadingStart or SumInterval or SumAlpha</Type>
13
+ <DebitCredit>Debit or Credit</DebitCredit>
14
+ <IsAccessible>boolean</IsAccessible>
15
+ <BlockDirectEntries>boolean</BlockDirectEntries>
16
+ <VatAccountHandle>
17
+ <VatCode>string</VatCode>
18
+ </VatAccountHandle>
19
+ <ContraAccountHandle>
20
+ <Number>int</Number>
21
+ </ContraAccountHandle>
22
+ <OpeningAccountHandle>
23
+ <Number>int</Number>
24
+ </OpeningAccountHandle>
25
+ <TotalFromHandle>
26
+ <Number>int</Number>
27
+ </TotalFromHandle>
28
+ <Balance>decimal</Balance>
29
+ <DepartmentHandle>
30
+ <Number>int</Number>
31
+ </DepartmentHandle>
32
+ <DistributionKeyHandle>
33
+ <Number>int</Number>
34
+ </DistributionKeyHandle>
35
+ </AccountData>
36
+ <AccountData>
37
+ <Handle>
38
+ <Number>42</Number>
39
+ </Handle>
40
+ <Number>42</Number>
41
+ <Name>Another account</Name>
42
+ <Type>ProfitAndLoss or Status or TotalFrom or Heading or HeadingStart or SumInterval or SumAlpha</Type>
43
+ <DebitCredit>Debit or Credit</DebitCredit>
44
+ <IsAccessible>boolean</IsAccessible>
45
+ <BlockDirectEntries>boolean</BlockDirectEntries>
46
+ <VatAccountHandle>
47
+ <VatCode>string</VatCode>
48
+ </VatAccountHandle>
49
+ <ContraAccountHandle>
50
+ <Number>int</Number>
51
+ </ContraAccountHandle>
52
+ <OpeningAccountHandle>
53
+ <Number>int</Number>
54
+ </OpeningAccountHandle>
55
+ <TotalFromHandle>
56
+ <Number>int</Number>
57
+ </TotalFromHandle>
58
+ <Balance>decimal</Balance>
59
+ <DepartmentHandle>
60
+ <Number>int</Number>
61
+ </DepartmentHandle>
62
+ <DistributionKeyHandle>
63
+ <Number>int</Number>
64
+ </DistributionKeyHandle>
65
+ </AccountData>
66
+ </Account_GetDataArrayResult>
67
+ </Account_GetDataArrayResponse>
68
+ </soap:Body>
69
+ </soap:Envelope>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
3
+ <soap12:Body>
4
+ <Company_GetResponse xmlns="http://e-conomic.com">
5
+ <Company_GetResult>
6
+ <Number>string</Number>
7
+ </Company_GetResult>
8
+ </Company_GetResponse>
9
+ </soap12:Body>
10
+ </soap12:Envelope>
@@ -0,0 +1,32 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
3
+ <soap12:Body>
4
+ <Company_GetDataResponse xmlns="http://e-conomic.com">
5
+ <Company_GetDataResult>
6
+ <Handle>
7
+ <Number>string</Number>
8
+ </Handle>
9
+ <Number>string</Number>
10
+ <BaseCurrencyHandle>
11
+ <Code>string</Code>
12
+ </BaseCurrencyHandle>
13
+ <Name>string</Name>
14
+ <Address1>string</Address1>
15
+ <Address2>string</Address2>
16
+ <PostalCode>string</PostalCode>
17
+ <City>string</City>
18
+ <County>string</County>
19
+ <Country>string</Country>
20
+ <TelephoneNumber>string</TelephoneNumber>
21
+ <FaxNumber>string</FaxNumber>
22
+ <MobileNumber>string</MobileNumber>
23
+ <Contact>string</Contact>
24
+ <WebSite>string</WebSite>
25
+ <Email>string</Email>
26
+ <CINumber>string</CINumber>
27
+ <VatNumber>string</VatNumber>
28
+ <SignUpDate>dateTime</SignUpDate>
29
+ </Company_GetDataResult>
30
+ </Company_GetDataResponse>
31
+ </soap12:Body>
32
+ </soap12:Envelope>
@@ -1,42 +1,11 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
2
  <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
3
3
  <soap:Body>
4
- <CurrentInvoiceLine_CreateFromData xmlns="http://e-conomic.com">
5
- <data>
6
- <Handle>
7
- <Id>int</Id>
8
- <Number>int</Number>
9
- </Handle>
10
- <Id>int</Id>
11
- <Number>int</Number>
12
- <InvoiceHandle>
13
- <Id>int</Id>
14
- </InvoiceHandle>
15
- <Description>string</Description>
16
- <DeliveryDate>dateTime</DeliveryDate>
17
- <UnitHandle>
18
- <Number>int</Number>
19
- </UnitHandle>
20
- <ProductHandle>
21
- <Number>string</Number>
22
- </ProductHandle>
23
- <Quantity>decimal</Quantity>
24
- <UnitNetPrice>decimal</UnitNetPrice>
25
- <DiscountAsPercent>decimal</DiscountAsPercent>
26
- <UnitCostPrice>decimal</UnitCostPrice>
27
- <TotalNetAmount>decimal</TotalNetAmount>
28
- <TotalMargin>decimal</TotalMargin>
29
- <MarginAsPercent>decimal</MarginAsPercent>
30
- <DepartmentHandle>
31
- <Number>int</Number>
32
- </DepartmentHandle>
33
- <DistributionKeyHandle>
34
- <Number>int</Number>
35
- </DistributionKeyHandle>
36
- <InventoryLocationHandle>
37
- <Number>int</Number>
38
- </InventoryLocationHandle>
39
- </data>
40
- </CurrentInvoiceLine_CreateFromData>
4
+ <CurrentInvoiceLine_CreateFromDataResponse xmlns="http://e-conomic.com">
5
+ <CurrentInvoiceLine_CreateFromDataResult>
6
+ <Id>42</Id>
7
+ <Number>42</Number>
8
+ </CurrentInvoiceLine_CreateFromDataResult>
9
+ </CurrentInvoiceLine_CreateFromDataResponse>
41
10
  </soap:Body>
42
11
  </soap:Envelope>