invoicexpress 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/CHANGELOG.md +0 -0
  2. data/README.md +322 -0
  3. data/Rakefile +19 -0
  4. data/invoicexpress.gemspec +26 -0
  5. data/lib/faraday/response/parse_xml.rb +23 -0
  6. data/lib/faraday/response/raise_invoicexpress_errors.rb +20 -0
  7. data/lib/invoicexpress.rb +26 -0
  8. data/lib/invoicexpress/authentication.rb +15 -0
  9. data/lib/invoicexpress/client.rb +56 -0
  10. data/lib/invoicexpress/client/cash_invoices.rb +110 -0
  11. data/lib/invoicexpress/client/charts.rb +57 -0
  12. data/lib/invoicexpress/client/clients.rb +215 -0
  13. data/lib/invoicexpress/client/credit_notes.rb +128 -0
  14. data/lib/invoicexpress/client/debit_notes.rb +129 -0
  15. data/lib/invoicexpress/client/invoices.rb +107 -0
  16. data/lib/invoicexpress/client/items.rb +82 -0
  17. data/lib/invoicexpress/client/purchase_orders.rb +126 -0
  18. data/lib/invoicexpress/client/schedules.rb +110 -0
  19. data/lib/invoicexpress/client/sequences.rb +71 -0
  20. data/lib/invoicexpress/client/simplified_invoices.rb +130 -0
  21. data/lib/invoicexpress/client/taxes.rb +82 -0
  22. data/lib/invoicexpress/client/users.rb +48 -0
  23. data/lib/invoicexpress/configuration.rb +51 -0
  24. data/lib/invoicexpress/connection.rb +40 -0
  25. data/lib/invoicexpress/error.rb +68 -0
  26. data/lib/invoicexpress/models.rb +29 -0
  27. data/lib/invoicexpress/models/chart.rb +41 -0
  28. data/lib/invoicexpress/models/client.rb +24 -0
  29. data/lib/invoicexpress/models/filter.rb +60 -0
  30. data/lib/invoicexpress/models/invoice.rb +235 -0
  31. data/lib/invoicexpress/models/purchase_order.rb +72 -0
  32. data/lib/invoicexpress/models/quarterly_result.rb +45 -0
  33. data/lib/invoicexpress/models/schedule.rb +87 -0
  34. data/lib/invoicexpress/models/sequence.rb +17 -0
  35. data/lib/invoicexpress/models/supplier.rb +17 -0
  36. data/lib/invoicexpress/models/top_client.rb +15 -0
  37. data/lib/invoicexpress/models/top_debtor.rb +14 -0
  38. data/lib/invoicexpress/models/user.rb +31 -0
  39. data/lib/invoicexpress/request.rb +63 -0
  40. data/lib/invoicexpress/version.rb +3 -0
  41. data/spec/fixtures/charts.invoicing.xml +21 -0
  42. data/spec/fixtures/charts.quarterly-results.xml +25 -0
  43. data/spec/fixtures/charts.top-clients.xml +10 -0
  44. data/spec/fixtures/charts.top-debtors.xml +10 -0
  45. data/spec/fixtures/charts.treasury.xml +49 -0
  46. data/spec/fixtures/clients.create.xml +6 -0
  47. data/spec/fixtures/clients.get.xml +21 -0
  48. data/spec/fixtures/clients.invoices.xml +11 -0
  49. data/spec/fixtures/clients.list.xml +18 -0
  50. data/spec/fixtures/clients.update.xml +1 -0
  51. data/spec/fixtures/credit_notes.create.xml +53 -0
  52. data/spec/fixtures/credit_notes.email_document.xml +9 -0
  53. data/spec/fixtures/credit_notes.list.xml +114 -0
  54. data/spec/fixtures/credit_notes.update_state.xml +7 -0
  55. data/spec/fixtures/invoices.create.xml +37 -0
  56. data/spec/fixtures/invoices.get.xml +50 -0
  57. data/spec/fixtures/invoices.list.xml +537 -0
  58. data/spec/fixtures/invoices.update_state.xml +7 -0
  59. data/spec/fixtures/ok.xml +0 -0
  60. data/spec/fixtures/po.create.xml +42 -0
  61. data/spec/fixtures/po.email_document.xml +0 -0
  62. data/spec/fixtures/po.get.xml +42 -0
  63. data/spec/fixtures/po.list.xml +44 -0
  64. data/spec/fixtures/po.update_state.xml +7 -0
  65. data/spec/fixtures/schedules.create.xml +48 -0
  66. data/spec/fixtures/schedules.get.xml +57 -0
  67. data/spec/fixtures/schedules.list.xml +40 -0
  68. data/spec/fixtures/sequences.create.xml +9 -0
  69. data/spec/fixtures/sequences.get.xml +10 -0
  70. data/spec/fixtures/sequences.list.xml +12 -0
  71. data/spec/fixtures/sequences.update.xml +10 -0
  72. data/spec/fixtures/simplified_invoices.create.xml +53 -0
  73. data/spec/fixtures/simplified_invoices.email_document.xml +9 -0
  74. data/spec/fixtures/simplified_invoices.get.xml +74 -0
  75. data/spec/fixtures/simplified_invoices.list.xml +114 -0
  76. data/spec/fixtures/simplified_invoices.update.xml +0 -0
  77. data/spec/fixtures/simplified_invoices.update_state.xml +7 -0
  78. data/spec/fixtures/taxes.create.xml +7 -0
  79. data/spec/fixtures/taxes.list.xml +18 -0
  80. data/spec/fixtures/taxes.update.xml +7 -0
  81. data/spec/fixtures/users.accounts.xml +12 -0
  82. data/spec/fixtures/users.change-account.xml +0 -0
  83. data/spec/fixtures/users.login.xml +11 -0
  84. data/spec/helper.rb +62 -0
  85. data/spec/invoicexpress/client/charts_spec.rb +69 -0
  86. data/spec/invoicexpress/client/clients_spec.rb +108 -0
  87. data/spec/invoicexpress/client/credit_notes_spec.rb +104 -0
  88. data/spec/invoicexpress/client/invoices_spec.rb +110 -0
  89. data/spec/invoicexpress/client/purchase_orders_spec.rb +116 -0
  90. data/spec/invoicexpress/client/schedules_spec.rb +111 -0
  91. data/spec/invoicexpress/client/sequences_spec.rb +68 -0
  92. data/spec/invoicexpress/client/simplified_invoices_spec.rb +116 -0
  93. data/spec/invoicexpress/client/taxes_spec.rb +70 -0
  94. data/spec/invoicexpress/client/users_spec.rb +40 -0
  95. data/spec/invoicexpress/client_spec.rb +24 -0
  96. data/spec/invoicexpress_spec.rb +19 -0
  97. metadata +279 -0
@@ -0,0 +1,70 @@
1
+ require 'helper'
2
+
3
+ describe Invoicexpress::Client::Taxes do
4
+ before do
5
+ @client = Invoicexpress::Client.new(:screen_name => "thinkorangeteste")
6
+ end
7
+
8
+ describe ".taxes" do
9
+ it "Returns all the taxes" do
10
+ stub_get("/taxes.xml").
11
+ to_return(xml_response("taxes.list.xml"))
12
+
13
+ taxes = @client.taxes
14
+ taxes.count.should == 2
15
+ end
16
+ end
17
+
18
+ describe ".create_tax" do
19
+ it "creates a new tax" do
20
+ stub_post("/taxes.xml").
21
+ to_return(xml_response("taxes.create.xml"))
22
+
23
+ model_tax = Invoicexpress::Models::Tax.new({
24
+ :name => "IVA19",
25
+ :value => 19.0,
26
+ :region => "PT",
27
+ :default_tax => 1
28
+ })
29
+
30
+ tax = @client.create_tax(model_tax)
31
+ tax.name.should == "IVA19"
32
+ tax.value.should == 19.0
33
+ tax.region.should == "PT"
34
+ tax.default_tax.should == 1
35
+ end
36
+
37
+ it "raises if no tax is passed" do
38
+ expect {
39
+ @client.create_tax(nil)
40
+ }.to raise_error(ArgumentError)
41
+ end
42
+ end
43
+
44
+ describe ".update_tax" do
45
+ it "updates a tax" do
46
+ stub_put("/taxes/123.xml").
47
+ to_return(xml_response("taxes.update.xml"))
48
+
49
+ model = Invoicexpress::Models::Tax.new({
50
+ :id => 123,
51
+ :name => "IVA23",
52
+ :value => 23.0
53
+ })
54
+
55
+ tax = @client.update_tax(model)
56
+ tax.name.should == "IVA23"
57
+ tax.value.should == 23.0
58
+ tax.region.should == "PT"
59
+ end
60
+ end
61
+
62
+ describe ".delete_tax" do
63
+ it "should delete a tax without errors" do
64
+ stub_delete("/taxes/123.xml").to_return(empty_xml_response)
65
+
66
+ expect { @client.delete_tax(123) }.to_not raise_error
67
+ end
68
+ end
69
+
70
+ end
@@ -0,0 +1,40 @@
1
+ require 'helper'
2
+
3
+ describe Invoicexpress::Client::Clients do
4
+
5
+ before do
6
+ @client = Invoicexpress::Client.new(:screen_name => "thinkorangeteste")
7
+ end
8
+
9
+ describe ".login" do
10
+ it "logins with your account" do
11
+ stub_post("/login.xml").
12
+ to_return(xml_response("users.login.xml"))
13
+
14
+ list= @client.login("info@test.pt", "2xptopxto")
15
+ list.count.should == 1
16
+ list.first.name.should == "thinkorangeteste"
17
+ end
18
+ end
19
+
20
+ describe ".accounts" do
21
+ it "returns all the accounts" do
22
+ stub_get("/users/accounts.xml").
23
+ to_return(xml_response("users.accounts.xml"))
24
+
25
+ list = @client.accounts
26
+ list.count.should == 1
27
+ list.first.name.should == "thinkorangeteste"
28
+ end
29
+ end
30
+
31
+ describe ".change-account" do
32
+ it "changes the current account to the account id submitted" do
33
+ stub_put("/users/change-account.xml").
34
+ to_return(xml_response("users.change-account.xml"))
35
+
36
+ expect { cnote = @client.change_account(13233) }.to_not raise_error
37
+ end
38
+ end
39
+
40
+ end
@@ -0,0 +1,24 @@
1
+ require 'helper'
2
+
3
+ describe Invoicexpress::Client do
4
+ before do
5
+ Invoicexpress.reset
6
+ end
7
+
8
+ describe "api_endpoint" do
9
+ after(:each) do
10
+ Invoicexpress.reset
11
+ end
12
+
13
+ it "defauls to https://%s.invoicexpress.net" do
14
+ client = Invoicexpress::Client.new
15
+ client.api_endpoint.should == "https://%s.invoicexpress.net/"
16
+ end
17
+
18
+ it "is set" do
19
+ Invoicexpress.api_endpoint = "https://thinkorangeteste.invoicexpress.net/"
20
+ client = Invoicexpress::Client.new
21
+ client.api_endpoint.should == "https://thinkorangeteste.invoicexpress.net/"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,19 @@
1
+ require 'helper'
2
+
3
+ describe Invoicexpress do
4
+ after do
5
+ Invoicexpress.reset
6
+ end
7
+
8
+ describe ".new" do
9
+ it "is a Invoicexpress::Client" do
10
+ Invoicexpress.new.should be_a Invoicexpress::Client
11
+ end
12
+ end
13
+
14
+ describe ".responds_to?" do
15
+ it "is true if method exists" do
16
+ Invoicexpress.respond_to?(:new, true).should == true
17
+ end
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,279 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: invoicexpress
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 0
10
+ version: 0.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Think Orange
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2013-09-05 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: bundler
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 1
32
+ - 0
33
+ version: "1.0"
34
+ type: :development
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: faraday
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 27
45
+ segments:
46
+ - 0
47
+ - 8
48
+ version: "0.8"
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: faraday_middleware
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 25
60
+ segments:
61
+ - 0
62
+ - 9
63
+ version: "0.9"
64
+ type: :runtime
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ name: happymapper
68
+ prerelease: false
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ - 4
78
+ version: "0.4"
79
+ type: :runtime
80
+ version_requirements: *id004
81
+ description: Simple wrapper for invoicexpress.com API
82
+ email:
83
+ - info@thinkorange.pt
84
+ executables: []
85
+
86
+ extensions: []
87
+
88
+ extra_rdoc_files: []
89
+
90
+ files:
91
+ - CHANGELOG.md
92
+ - README.md
93
+ - Rakefile
94
+ - invoicexpress.gemspec
95
+ - lib/faraday/response/parse_xml.rb
96
+ - lib/faraday/response/raise_invoicexpress_errors.rb
97
+ - lib/invoicexpress/authentication.rb
98
+ - lib/invoicexpress/client/cash_invoices.rb
99
+ - lib/invoicexpress/client/charts.rb
100
+ - lib/invoicexpress/client/clients.rb
101
+ - lib/invoicexpress/client/credit_notes.rb
102
+ - lib/invoicexpress/client/debit_notes.rb
103
+ - lib/invoicexpress/client/invoices.rb
104
+ - lib/invoicexpress/client/items.rb
105
+ - lib/invoicexpress/client/purchase_orders.rb
106
+ - lib/invoicexpress/client/schedules.rb
107
+ - lib/invoicexpress/client/sequences.rb
108
+ - lib/invoicexpress/client/simplified_invoices.rb
109
+ - lib/invoicexpress/client/taxes.rb
110
+ - lib/invoicexpress/client/users.rb
111
+ - lib/invoicexpress/client.rb
112
+ - lib/invoicexpress/configuration.rb
113
+ - lib/invoicexpress/connection.rb
114
+ - lib/invoicexpress/error.rb
115
+ - lib/invoicexpress/models/chart.rb
116
+ - lib/invoicexpress/models/client.rb
117
+ - lib/invoicexpress/models/filter.rb
118
+ - lib/invoicexpress/models/invoice.rb
119
+ - lib/invoicexpress/models/purchase_order.rb
120
+ - lib/invoicexpress/models/quarterly_result.rb
121
+ - lib/invoicexpress/models/schedule.rb
122
+ - lib/invoicexpress/models/sequence.rb
123
+ - lib/invoicexpress/models/supplier.rb
124
+ - lib/invoicexpress/models/top_client.rb
125
+ - lib/invoicexpress/models/top_debtor.rb
126
+ - lib/invoicexpress/models/user.rb
127
+ - lib/invoicexpress/models.rb
128
+ - lib/invoicexpress/request.rb
129
+ - lib/invoicexpress/version.rb
130
+ - lib/invoicexpress.rb
131
+ - spec/fixtures/charts.invoicing.xml
132
+ - spec/fixtures/charts.quarterly-results.xml
133
+ - spec/fixtures/charts.top-clients.xml
134
+ - spec/fixtures/charts.top-debtors.xml
135
+ - spec/fixtures/charts.treasury.xml
136
+ - spec/fixtures/clients.create.xml
137
+ - spec/fixtures/clients.get.xml
138
+ - spec/fixtures/clients.invoices.xml
139
+ - spec/fixtures/clients.list.xml
140
+ - spec/fixtures/clients.update.xml
141
+ - spec/fixtures/credit_notes.create.xml
142
+ - spec/fixtures/credit_notes.email_document.xml
143
+ - spec/fixtures/credit_notes.list.xml
144
+ - spec/fixtures/credit_notes.update_state.xml
145
+ - spec/fixtures/invoices.create.xml
146
+ - spec/fixtures/invoices.get.xml
147
+ - spec/fixtures/invoices.list.xml
148
+ - spec/fixtures/invoices.update_state.xml
149
+ - spec/fixtures/ok.xml
150
+ - spec/fixtures/po.create.xml
151
+ - spec/fixtures/po.email_document.xml
152
+ - spec/fixtures/po.get.xml
153
+ - spec/fixtures/po.list.xml
154
+ - spec/fixtures/po.update_state.xml
155
+ - spec/fixtures/schedules.create.xml
156
+ - spec/fixtures/schedules.get.xml
157
+ - spec/fixtures/schedules.list.xml
158
+ - spec/fixtures/sequences.create.xml
159
+ - spec/fixtures/sequences.get.xml
160
+ - spec/fixtures/sequences.list.xml
161
+ - spec/fixtures/sequences.update.xml
162
+ - spec/fixtures/simplified_invoices.create.xml
163
+ - spec/fixtures/simplified_invoices.email_document.xml
164
+ - spec/fixtures/simplified_invoices.get.xml
165
+ - spec/fixtures/simplified_invoices.list.xml
166
+ - spec/fixtures/simplified_invoices.update.xml
167
+ - spec/fixtures/simplified_invoices.update_state.xml
168
+ - spec/fixtures/taxes.create.xml
169
+ - spec/fixtures/taxes.list.xml
170
+ - spec/fixtures/taxes.update.xml
171
+ - spec/fixtures/users.accounts.xml
172
+ - spec/fixtures/users.change-account.xml
173
+ - spec/fixtures/users.login.xml
174
+ - spec/helper.rb
175
+ - spec/invoicexpress/client/charts_spec.rb
176
+ - spec/invoicexpress/client/clients_spec.rb
177
+ - spec/invoicexpress/client/credit_notes_spec.rb
178
+ - spec/invoicexpress/client/invoices_spec.rb
179
+ - spec/invoicexpress/client/purchase_orders_spec.rb
180
+ - spec/invoicexpress/client/schedules_spec.rb
181
+ - spec/invoicexpress/client/sequences_spec.rb
182
+ - spec/invoicexpress/client/simplified_invoices_spec.rb
183
+ - spec/invoicexpress/client/taxes_spec.rb
184
+ - spec/invoicexpress/client/users_spec.rb
185
+ - spec/invoicexpress/client_spec.rb
186
+ - spec/invoicexpress_spec.rb
187
+ has_rdoc: true
188
+ homepage: http://invoicexpress.pt
189
+ licenses:
190
+ - MIT
191
+ post_install_message:
192
+ rdoc_options: []
193
+
194
+ require_paths:
195
+ - lib
196
+ required_ruby_version: !ruby/object:Gem::Requirement
197
+ none: false
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ hash: 3
202
+ segments:
203
+ - 0
204
+ version: "0"
205
+ required_rubygems_version: !ruby/object:Gem::Requirement
206
+ none: false
207
+ requirements:
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ hash: 23
211
+ segments:
212
+ - 1
213
+ - 3
214
+ - 6
215
+ version: 1.3.6
216
+ requirements: []
217
+
218
+ rubyforge_project:
219
+ rubygems_version: 1.6.2
220
+ signing_key:
221
+ specification_version: 3
222
+ summary: Simple wrapper for invoicexpress.com API
223
+ test_files:
224
+ - spec/fixtures/charts.invoicing.xml
225
+ - spec/fixtures/charts.quarterly-results.xml
226
+ - spec/fixtures/charts.top-clients.xml
227
+ - spec/fixtures/charts.top-debtors.xml
228
+ - spec/fixtures/charts.treasury.xml
229
+ - spec/fixtures/clients.create.xml
230
+ - spec/fixtures/clients.get.xml
231
+ - spec/fixtures/clients.invoices.xml
232
+ - spec/fixtures/clients.list.xml
233
+ - spec/fixtures/clients.update.xml
234
+ - spec/fixtures/credit_notes.create.xml
235
+ - spec/fixtures/credit_notes.email_document.xml
236
+ - spec/fixtures/credit_notes.list.xml
237
+ - spec/fixtures/credit_notes.update_state.xml
238
+ - spec/fixtures/invoices.create.xml
239
+ - spec/fixtures/invoices.get.xml
240
+ - spec/fixtures/invoices.list.xml
241
+ - spec/fixtures/invoices.update_state.xml
242
+ - spec/fixtures/ok.xml
243
+ - spec/fixtures/po.create.xml
244
+ - spec/fixtures/po.email_document.xml
245
+ - spec/fixtures/po.get.xml
246
+ - spec/fixtures/po.list.xml
247
+ - spec/fixtures/po.update_state.xml
248
+ - spec/fixtures/schedules.create.xml
249
+ - spec/fixtures/schedules.get.xml
250
+ - spec/fixtures/schedules.list.xml
251
+ - spec/fixtures/sequences.create.xml
252
+ - spec/fixtures/sequences.get.xml
253
+ - spec/fixtures/sequences.list.xml
254
+ - spec/fixtures/sequences.update.xml
255
+ - spec/fixtures/simplified_invoices.create.xml
256
+ - spec/fixtures/simplified_invoices.email_document.xml
257
+ - spec/fixtures/simplified_invoices.get.xml
258
+ - spec/fixtures/simplified_invoices.list.xml
259
+ - spec/fixtures/simplified_invoices.update.xml
260
+ - spec/fixtures/simplified_invoices.update_state.xml
261
+ - spec/fixtures/taxes.create.xml
262
+ - spec/fixtures/taxes.list.xml
263
+ - spec/fixtures/taxes.update.xml
264
+ - spec/fixtures/users.accounts.xml
265
+ - spec/fixtures/users.change-account.xml
266
+ - spec/fixtures/users.login.xml
267
+ - spec/helper.rb
268
+ - spec/invoicexpress/client/charts_spec.rb
269
+ - spec/invoicexpress/client/clients_spec.rb
270
+ - spec/invoicexpress/client/credit_notes_spec.rb
271
+ - spec/invoicexpress/client/invoices_spec.rb
272
+ - spec/invoicexpress/client/purchase_orders_spec.rb
273
+ - spec/invoicexpress/client/schedules_spec.rb
274
+ - spec/invoicexpress/client/sequences_spec.rb
275
+ - spec/invoicexpress/client/simplified_invoices_spec.rb
276
+ - spec/invoicexpress/client/taxes_spec.rb
277
+ - spec/invoicexpress/client/users_spec.rb
278
+ - spec/invoicexpress/client_spec.rb
279
+ - spec/invoicexpress_spec.rb