ruconomic 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +100 -0
  6. data/Rakefile +2 -0
  7. data/lib/ruconomic/api/account.rb +520 -0
  8. data/lib/ruconomic/api/accounting_period.rb +113 -0
  9. data/lib/ruconomic/api/accounting_year.rb +161 -0
  10. data/lib/ruconomic/api/activity.rb +90 -0
  11. data/lib/ruconomic/api/bank_payment_type.rb +103 -0
  12. data/lib/ruconomic/api/budget_figure.rb +343 -0
  13. data/lib/ruconomic/api/cash_book.rb +232 -0
  14. data/lib/ruconomic/api/cash_book_entry.rb +716 -0
  15. data/lib/ruconomic/api/company.rb +294 -0
  16. data/lib/ruconomic/api/cost_type.rb +138 -0
  17. data/lib/ruconomic/api/cost_type_group.rb +115 -0
  18. data/lib/ruconomic/api/creditor.rb +688 -0
  19. data/lib/ruconomic/api/creditor_contact.rb +269 -0
  20. data/lib/ruconomic/api/creditor_entry.rb +235 -0
  21. data/lib/ruconomic/api/creditor_group.rb +208 -0
  22. data/lib/ruconomic/api/currency.rb +67 -0
  23. data/lib/ruconomic/api/current_invoice.rb +1110 -0
  24. data/lib/ruconomic/api/current_invoice_line.rb +440 -0
  25. data/lib/ruconomic/api/current_supplier_invoice.rb +115 -0
  26. data/lib/ruconomic/api/current_supplier_invoice_line.rb +92 -0
  27. data/lib/ruconomic/api/debtor.rb +978 -0
  28. data/lib/ruconomic/api/debtor_contact.rb +328 -0
  29. data/lib/ruconomic/api/debtor_entry.rb +223 -0
  30. data/lib/ruconomic/api/debtor_group.rb +232 -0
  31. data/lib/ruconomic/api/delivery_location.rb +341 -0
  32. data/lib/ruconomic/api/department.rb +197 -0
  33. data/lib/ruconomic/api/distribution_key.rb +187 -0
  34. data/lib/ruconomic/api/document_archive_category.rb +163 -0
  35. data/lib/ruconomic/api/employee.rb +421 -0
  36. data/lib/ruconomic/api/employee_group.rb +199 -0
  37. data/lib/ruconomic/api/entry.rb +318 -0
  38. data/lib/ruconomic/api/extended_vat_zone.rb +79 -0
  39. data/lib/ruconomic/api/inventory_location.rb +91 -0
  40. data/lib/ruconomic/api/invoice.rb +655 -0
  41. data/lib/ruconomic/api/invoice_line.rb +248 -0
  42. data/lib/ruconomic/api/key_figure_code.rb +103 -0
  43. data/lib/ruconomic/api/mileage_entry.rb +319 -0
  44. data/lib/ruconomic/api/order.rb +1169 -0
  45. data/lib/ruconomic/api/order_line.rb +451 -0
  46. data/lib/ruconomic/api/price_group.rb +200 -0
  47. data/lib/ruconomic/api/product.rb +533 -0
  48. data/lib/ruconomic/api/product_group.rb +271 -0
  49. data/lib/ruconomic/api/product_price.rb +164 -0
  50. data/lib/ruconomic/api/project.rb +449 -0
  51. data/lib/ruconomic/api/project_group.rb +113 -0
  52. data/lib/ruconomic/api/quotation.rb +1145 -0
  53. data/lib/ruconomic/api/quotation_line.rb +451 -0
  54. data/lib/ruconomic/api/report_code.rb +78 -0
  55. data/lib/ruconomic/api/report_code_set.rb +89 -0
  56. data/lib/ruconomic/api/scanned_document.rb +175 -0
  57. data/lib/ruconomic/api/subscriber.rb +475 -0
  58. data/lib/ruconomic/api/subscription.rb +375 -0
  59. data/lib/ruconomic/api/subscription_line.rb +307 -0
  60. data/lib/ruconomic/api/sum_interval.rb +164 -0
  61. data/lib/ruconomic/api/template_collection.rb +78 -0
  62. data/lib/ruconomic/api/term_of_payment.rb +307 -0
  63. data/lib/ruconomic/api/time_entry.rb +258 -0
  64. data/lib/ruconomic/api/unit.rb +187 -0
  65. data/lib/ruconomic/api/vat_account.rb +151 -0
  66. data/lib/ruconomic/api.rb +79 -0
  67. data/lib/ruconomic/fault.rb +17 -0
  68. data/lib/ruconomic/soap/document.rb +79 -0
  69. data/lib/ruconomic/soap/node.rb +24 -0
  70. data/lib/ruconomic/soap.rb +7 -0
  71. data/lib/ruconomic/version.rb +3 -0
  72. data/lib/ruconomic/web_service.rb +50 -0
  73. data/lib/ruconomic.rb +42 -0
  74. data/ruconomic.gemspec +27 -0
  75. metadata +202 -0
@@ -0,0 +1,187 @@
1
+ module Ruconomic
2
+ module API
3
+ module Unit
4
+ extend Ruconomic::WebService
5
+
6
+ # Creates a new unit from a data object.
7
+ # Parameters: data: The data object that specifies the properties of the new unit.
8
+ #
9
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
10
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Unit_CreateFromData
11
+ # @return [Hash] The body content of the SOAP response.
12
+ def self.create_from_data
13
+ response = invoke('Unit_CreateFromData') do |message|
14
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
15
+ end
16
+ end
17
+
18
+ # Creates new units from data objects.
19
+ # Parameters: dataArray: The array of data objects that specifies the properties of the new units.
20
+ #
21
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
22
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Unit_CreateFromDataArray
23
+ # @return [Hash] The body content of the SOAP response.
24
+ def self.create_from_data_array
25
+ response = invoke('Unit_CreateFromDataArray') do |message|
26
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
27
+ end
28
+ end
29
+
30
+ # Update units from data objects.
31
+ # Parameters: dataArray: The array of data objects.
32
+ #
33
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
34
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Unit_UpdateFromDataArray
35
+ # @return [Hash] The body content of the SOAP response.
36
+ def self.update_from_data_array
37
+ response = invoke('Unit_UpdateFromDataArray') do |message|
38
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
39
+ end
40
+ end
41
+
42
+ # Updates a unit from a data object.
43
+ # Parameters: data: The data object.
44
+ #
45
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
46
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Unit_UpdateFromData
47
+ # @return [Hash] The body content of the SOAP response.
48
+ def self.update_from_data
49
+ response = invoke('Unit_UpdateFromData') do |message|
50
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
51
+ end
52
+ end
53
+
54
+ # Returns an unit data object for a given unit.
55
+ # Parameters: entityHandle: A handle for the unit.
56
+ #
57
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
58
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Unit_GetData
59
+ # @return [Hash] The body content of the SOAP response.
60
+ def self.get_data
61
+ response = invoke('Unit_GetData') do |message|
62
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
63
+ end
64
+ end
65
+
66
+ # Returns unit data objects for a given set of unit handles.
67
+ # Parameters: entityHandles: An array of the unit handles.
68
+ #
69
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
70
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Unit_GetDataArray
71
+ # @return [Hash] The body content of the SOAP response.
72
+ def self.get_data_array
73
+ response = invoke('Unit_GetDataArray') do |message|
74
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
75
+ end
76
+ end
77
+
78
+ # Creates a new unit.
79
+ # Parameters: name: The name of the new unit.
80
+ #
81
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
82
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Unit_Create
83
+ # @return [Hash] The body content of the SOAP response.
84
+ def self.create
85
+ response = invoke('Unit_Create') do |message|
86
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
87
+ end
88
+ end
89
+
90
+ # Returns handles for all units.
91
+ #
92
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
93
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Unit_GetAll
94
+ # @return [Hash] The body content of the SOAP response.
95
+ def self.get_all
96
+ response = invoke('Unit_GetAll') do |message|
97
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
98
+ end
99
+ end
100
+
101
+ # Returns handles for units with a given name.
102
+ # Parameters: name: The name to search for.
103
+ #
104
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
105
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Unit_FindByName
106
+ # @return [Hash] The body content of the SOAP response.
107
+ def self.find_by_name
108
+ response = invoke('Unit_FindByName') do |message|
109
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
110
+ end
111
+ end
112
+
113
+ # Returns a handle for the unit with a given number.
114
+ # Parameters: number: The number to search for.
115
+ #
116
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
117
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Unit_FindByNumber
118
+ # @return [Hash] The body content of the SOAP response.
119
+ def self.find_by_number
120
+ response = invoke('Unit_FindByNumber') do |message|
121
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
122
+ end
123
+ end
124
+
125
+ # Returns an array with handles for the untis corresponding to the given unit numbers. If a unit with a given number does not exist then the array contains nothing at that index.
126
+ # Parameters: numbers: The numbers to search for.
127
+ #
128
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
129
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Unit_FindByNumberList
130
+ # @return [Hash] The body content of the SOAP response.
131
+ def self.find_by_number_list
132
+ response = invoke('Unit_FindByNumberList') do |message|
133
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
134
+ end
135
+ end
136
+
137
+ # Deletes a unit.
138
+ # Parameters: unitHandle: Handle for the unit.
139
+ #
140
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
141
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Unit_Delete
142
+ # @return [Hash] The body content of the SOAP response.
143
+ def self.delete
144
+ response = invoke('Unit_Delete') do |message|
145
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
146
+ end
147
+ end
148
+
149
+ # Gets the number of a unit.
150
+ # Parameters: unitHandle: Handle for the unit.
151
+ #
152
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
153
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Unit_GetNumber
154
+ # @return [Hash] The body content of the SOAP response.
155
+ def self.get_number
156
+ response = invoke('Unit_GetNumber') do |message|
157
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
158
+ end
159
+ end
160
+
161
+ # Gets the name of a unit.
162
+ # Parameters: unitHandle: Handle for the unit.
163
+ #
164
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
165
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Unit_GetName
166
+ # @return [Hash] The body content of the SOAP response.
167
+ def self.get_name
168
+ response = invoke('Unit_GetName') do |message|
169
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
170
+ end
171
+ end
172
+
173
+ # Sets the name of a unit.
174
+ # Parameters: unitHandle: Handle for the unit. value: The new name of the unit.
175
+ #
176
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
177
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Unit_SetName
178
+ # @return [Hash] The body content of the SOAP response.
179
+ def self.set_name
180
+ response = invoke('Unit_SetName') do |message|
181
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
182
+ end
183
+ end
184
+
185
+ end
186
+ end
187
+ end
@@ -0,0 +1,151 @@
1
+ module Ruconomic
2
+ module API
3
+ module VatAccount
4
+ extend Ruconomic::WebService
5
+
6
+ # Update VAT accounts from data objects.
7
+ # Parameters: dataArray: The array of data objects.
8
+ #
9
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
10
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=VatAccount_UpdateFromDataArray
11
+ # @return [Hash] The body content of the SOAP response.
12
+ def self.update_from_data_array
13
+ response = invoke('VatAccount_UpdateFromDataArray') do |message|
14
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
15
+ end
16
+ end
17
+
18
+ # Updates a VAT account from a data object.
19
+ # Parameters: data: The data object.
20
+ #
21
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
22
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=VatAccount_UpdateFromData
23
+ # @return [Hash] The body content of the SOAP response.
24
+ def self.update_from_data
25
+ response = invoke('VatAccount_UpdateFromData') do |message|
26
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
27
+ end
28
+ end
29
+
30
+ # Returns an VAT account data object for a given VAT account.
31
+ # Parameters: entityHandle: A handle for the VAT account.
32
+ #
33
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
34
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=VatAccount_GetData
35
+ # @return [Hash] The body content of the SOAP response.
36
+ def self.get_data
37
+ response = invoke('VatAccount_GetData') do |message|
38
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
39
+ end
40
+ end
41
+
42
+ # Returns VAT account data objects for a given set of VAT account handles.
43
+ # Parameters: entityHandles: An array of the VAT account handles.
44
+ #
45
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
46
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=VatAccount_GetDataArray
47
+ # @return [Hash] The body content of the SOAP response.
48
+ def self.get_data_array
49
+ response = invoke('VatAccount_GetDataArray') do |message|
50
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
51
+ end
52
+ end
53
+
54
+ # Returns handles for all VAT accounts.
55
+ #
56
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
57
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=VatAccount_GetAll
58
+ # @return [Hash] The body content of the SOAP response.
59
+ def self.get_all
60
+ response = invoke('VatAccount_GetAll') do |message|
61
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
62
+ end
63
+ end
64
+
65
+ # Returns handle for the VAT account with a given VAT code.
66
+ # Parameters: vatCode: The VAT code to search for.
67
+ #
68
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
69
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=VatAccount_FindByVatCode
70
+ # @return [Hash] The body content of the SOAP response.
71
+ def self.find_by_vat_code
72
+ response = invoke('VatAccount_FindByVatCode') do |message|
73
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
74
+ end
75
+ end
76
+
77
+ # Gets the VAT code of a VAT account.
78
+ # Parameters: vatAccountHandle: Handle for the VAT account.
79
+ #
80
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
81
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=VatAccount_GetVatCode
82
+ # @return [Hash] The body content of the SOAP response.
83
+ def self.get_vat_code
84
+ response = invoke('VatAccount_GetVatCode') do |message|
85
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
86
+ end
87
+ end
88
+
89
+ # Gets the name of a VAT account.
90
+ # Parameters: vatAccountHandle: Handle for the VAT account.
91
+ #
92
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
93
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=VatAccount_GetName
94
+ # @return [Hash] The body content of the SOAP response.
95
+ def self.get_name
96
+ response = invoke('VatAccount_GetName') do |message|
97
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
98
+ end
99
+ end
100
+
101
+ # Gets the type of a VAT account.
102
+ # Parameters: vatAccountHandle: Handle for the VAT account.
103
+ #
104
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
105
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=VatAccount_GetType
106
+ # @return [Hash] The body content of the SOAP response.
107
+ def self.get_type
108
+ response = invoke('VatAccount_GetType') do |message|
109
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
110
+ end
111
+ end
112
+
113
+ # Gets the rate of a VAT account.
114
+ # Parameters: vatAccountHandle: Handle for the VAT account.
115
+ #
116
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
117
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=VatAccount_GetRateAsPercent
118
+ # @return [Hash] The body content of the SOAP response.
119
+ def self.get_rate_as_percent
120
+ response = invoke('VatAccount_GetRateAsPercent') do |message|
121
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
122
+ end
123
+ end
124
+
125
+ # Gets the account of a VAT account.
126
+ # Parameters: vatAccountHandle: Handle for the VAT account.
127
+ #
128
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
129
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=VatAccount_GetAccount
130
+ # @return [Hash] The body content of the SOAP response.
131
+ def self.get_account
132
+ response = invoke('VatAccount_GetAccount') do |message|
133
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
134
+ end
135
+ end
136
+
137
+ # Gets the contra account of a VAT account.
138
+ # Parameters: vatAccountHandle: Handle for the VAT account.
139
+ #
140
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
141
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=VatAccount_GetContraAccount
142
+ # @return [Hash] The body content of the SOAP response.
143
+ def self.get_contra_account
144
+ response = invoke('VatAccount_GetContraAccount') do |message|
145
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
146
+ end
147
+ end
148
+
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,79 @@
1
+ module Ruconomic
2
+ module API
3
+ extend Ruconomic::WebService
4
+
5
+ # Connects to the server.
6
+ #
7
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Connect
8
+ # @param agreement [String] The agreement number for the subscription.
9
+ # @param username [String] The user name of the subscription.
10
+ # @param password [String] The password for the user name.
11
+ # @return [String] The token for this connection
12
+ def self.connect(agreement, username, password)
13
+ response = invoke('Connect') do |message|
14
+ message.add 'agreementNumber', agreement
15
+ message.add 'userName', username
16
+ message.add 'password', password
17
+ end
18
+
19
+ response.find('//dns:ConnectResult/text()').first.to_s
20
+ end
21
+
22
+ # Connects to the server.
23
+ # Parameters: agreementNumber: The agreement number for the subscription. userName: The user name of the subscription. password: The password for the user name.
24
+ #
25
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
26
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=ConnectAsAdministrator
27
+ # @return [Hash] The body content of the SOAP response.
28
+ def self.connect_as_administrator
29
+ response = invoke('ConnectAsAdministrator') do |message|
30
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
31
+ end
32
+ end
33
+
34
+ # Connects to the server.
35
+ # Parameters: agreementNumber: The agreement number for the subscription. userName: The user name of the subscription. password: The password for the user name. customerNumber: the internal adminCustomerNumber
36
+ #
37
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
38
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=ConnectAsAdministratorWithCustomerNumber
39
+ # @return [Hash] The body content of the SOAP response.
40
+ def self.connect_as_administrator_with_customer_number
41
+ response = invoke('ConnectAsAdministratorWithCustomerNumber') do |message|
42
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
43
+ end
44
+ end
45
+
46
+ # Connects to the server.
47
+ # Parameters: token: The access token provided.
48
+ #
49
+ # @note TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
50
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=ConnectWithToken
51
+ # @return [Hash] The body content of the SOAP response.
52
+ def self.connect_with_token
53
+ response = invoke('ConnectWithToken') do |message|
54
+ raise "TODO: This method was autogenerated from the WSDL - see https://github.com/ta/e-conomic#contributing"
55
+ end
56
+ end
57
+
58
+ # Disconnects from the server.
59
+ #
60
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Disconnect
61
+ # @return [String] The result of the disconnect operation
62
+ def self.disconnect
63
+ response = invoke('Disconnect')
64
+
65
+ response.find('//dns:DisconnectResult/text()').first.to_s
66
+ end
67
+
68
+ # Gets information about the e-conomic API.
69
+ #
70
+ # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=GetApiInformation
71
+ # @return [String] The API version
72
+ def self.get_api_information
73
+ response = invoke('GetApiInformation')
74
+
75
+ response.find('//dns:GetApiInformationResult/text()').first.to_s
76
+ end
77
+
78
+ end
79
+ end
@@ -0,0 +1,17 @@
1
+ module Ruconomic
2
+ class Fault < StandardError
3
+ attr_reader :code, :reason, :details
4
+
5
+ def initialize(code, reason, details)
6
+ super(reason)
7
+ @code = code
8
+ @reason = reason
9
+ @details = details
10
+ end
11
+
12
+ def to_s
13
+ "Ruconomic::Fault { :code => '#{@code}', :reason => '#{@reason}', :details => '#{@details}' }"
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,79 @@
1
+ require "libxml"
2
+ require "ruconomic/soap/node"
3
+
4
+ module Ruconomic
5
+ module SOAP
6
+ class Document < LibXML::XML::Document
7
+
8
+ def initialize(xml_version = "1.0")
9
+ super(xml_version)
10
+ self.root = envelope = Ruconomic::SOAP::Node.new("Envelope")
11
+ self.root << body = Ruconomic::SOAP::Node.new("Body")
12
+ LibXML::XML::Namespace.new(envelope, "xsd", "http://www.w3.org/2001/XMLSchema")
13
+ LibXML::XML::Namespace.new(envelope, "xsi", "http://www.w3.org/2001/XMLSchema-instance")
14
+ soap = LibXML::XML::Namespace.new(envelope, "soap", "http://schemas.xmlsoap.org/soap/envelope/")
15
+ envelope.namespaces.namespace = soap
16
+ body.namespaces.namespace = soap
17
+ end
18
+
19
+ def << node
20
+ self.root.first << node
21
+ end
22
+
23
+ # As suggested in http://stackoverflow.com/a/1231297 - not pretty, but encapsulated
24
+ def to_hash
25
+ LibXML::XML.default_load_external_dtd = false
26
+ LibXML::XML.default_pedantic_parser = true
27
+ h = { self.root.name.to_s.to_sym => traverse(self.root) }
28
+
29
+ h[:Envelope][:body]
30
+ end
31
+
32
+ # We want #string to return a Ruconomic::SOAP::Document
33
+ def self.string(value, options = {})
34
+ document = Ruconomic::SOAP::Document.new
35
+ document.root = document.import(super(value, options).root)
36
+
37
+ document
38
+ end
39
+
40
+ private
41
+
42
+ def normalize_name(name)
43
+ name.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase.to_sym
44
+ end
45
+
46
+ # As suggested in http://stackoverflow.com/a/1231297 - not pretty, but encapsulated
47
+ def traverse(node)
48
+ if node.element?
49
+ if node.children?
50
+ result_hash = {}
51
+ node.each_child do |child|
52
+ result = traverse(child)
53
+ child_name = normalize_name(child.name)
54
+ if child.name == "text"
55
+ if !child.next? and !child.prev?
56
+ return result
57
+ end
58
+ elsif result_hash[child_name]
59
+ if result_hash[child_name].is_a?(Object::Array)
60
+ result_hash[child_name] << result
61
+ else
62
+ result_hash[child_name] = [result_hash[child_name]] << result
63
+ end
64
+ else
65
+ result_hash[child_name] = result
66
+ end
67
+ end
68
+ return result_hash
69
+ else
70
+ return nil
71
+ end # end if node.children?
72
+ else
73
+ return node.content.to_s
74
+ end # end if node.element?
75
+ end
76
+
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,24 @@
1
+ require "libxml"
2
+
3
+ module Ruconomic
4
+ module SOAP
5
+ class Node < LibXML::XML::Node
6
+
7
+ def initialize(name, value = nil, namespace = nil, prefix = nil)
8
+ # add prefix to node if namespace (and prefix is given)
9
+ name = prefix + ':' + name if namespace != nil && prefix != nil
10
+ super(name, value)
11
+ # Add namespace (and prefix if given)
12
+ LibXML::XML::Namespace.new(self, prefix, namespace) if namespace
13
+ end
14
+
15
+ def add(name, value = nil, namespace = nil, prefix = nil)
16
+ self << node = Ruconomic::SOAP::Node.new(name, value, namespace, prefix)
17
+ yield node if block_given?
18
+
19
+ node
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ require "ruconomic/soap/document"
2
+ require "ruconomic/soap/node"
3
+
4
+ module Ruconomic
5
+ module SOAP
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Ruconomic
2
+ VERSION = "0.9.0"
3
+ end
@@ -0,0 +1,50 @@
1
+ require "curb"
2
+ require "ruconomic/fault"
3
+ require "ruconomic/soap"
4
+
5
+ module Ruconomic
6
+ module WebService
7
+ @@curl = nil
8
+
9
+ private
10
+
11
+ def invoke(action, soapAction = nil, &block)
12
+ node = Ruconomic::SOAP::Node.new(action, nil, "http://e-conomic.com")
13
+ yield node if block_given?
14
+ document = Ruconomic::SOAP::Document.new
15
+ document << node
16
+
17
+ call(document.to_s(:indent => false), action)
18
+ end
19
+
20
+ def call(document, action)
21
+ @@curl ||= Curl::Easy.new(Ruconomic.url) do |c|
22
+ c.headers["Content-Type"] = "text/xml; charset=UTF-8"
23
+ c.timeout = Ruconomic.timeout
24
+ c.enable_cookies = true
25
+ if Ruconomic.follow_redirects
26
+ c.follow_location = true
27
+ c.max_redirects = Ruconomic.max_redirects
28
+ end
29
+ end
30
+
31
+ begin
32
+ @@curl.http_post(document)
33
+ response = Ruconomic::SOAP::Document.string(@@curl.body_str)
34
+ if @@curl.response_code != 200
35
+ h = response.to_hash || {}
36
+ fault = h[:fault]
37
+ raise Ruconomic::Fault.new(fault[:faultcode],fault[:faultstring],fault[:details]) if fault
38
+ end
39
+ LibXML::XML::Namespace.new(response.root, nil, "http://e-conomic.com")
40
+ response.root.namespaces.default_prefix = "dns"
41
+ rescue Curl::Err => e
42
+ @@curl = nil
43
+ raise
44
+ end
45
+
46
+ response
47
+ end
48
+
49
+ end
50
+ end
data/lib/ruconomic.rb ADDED
@@ -0,0 +1,42 @@
1
+ require "ruconomic/version"
2
+ require "ruconomic/fault"
3
+ require "ruconomic/web_service"
4
+ require "ruconomic/api"
5
+
6
+ module Ruconomic
7
+
8
+ URL = "https://www.e-conomic.com/secure/api1/EconomicWebService.asmx"
9
+
10
+ class << self
11
+ attr_accessor :agreement, :username, :password, :timeout, :follow_redirects, :max_redirects, :url
12
+
13
+ def configure &block
14
+ yield self if block_given?
15
+ end
16
+
17
+ def timeout
18
+ @timeout || 30
19
+ end
20
+
21
+ def follow_redirects
22
+ @follow_redirects || true
23
+ end
24
+
25
+ def max_redirects
26
+ @max_redirects || 2
27
+ end
28
+
29
+ def url
30
+ @url || Ruconomic::URL
31
+ end
32
+
33
+ def session(&block)
34
+ raise "Not configured" unless agreement && username && password && url
35
+ Ruconomic::API.connect(Ruconomic.agreement, Ruconomic.username, Ruconomic.password)
36
+ yield self::API if block_given?
37
+ ensure
38
+ Ruconomic::API.disconnect
39
+ end
40
+
41
+ end
42
+ end
data/ruconomic.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ruconomic/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ruconomic"
8
+ spec.version = Ruconomic::VERSION
9
+ spec.authors = ["Tonni Tølbøll Lund Aagesen"]
10
+ spec.email = ["tonni@toelboell-lund.dk"]
11
+ spec.summary = %q{Easy to use ruby wrapper for e-conomic.com's webservice}
12
+ spec.homepage = "https://github.com/ta/ruconomic"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency "curb"
21
+ spec.add_runtime_dependency "libxml-ruby"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "minitest"
26
+ spec.add_development_dependency "yard"
27
+ end