sellsy 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef519fd21149bc969b461c0de7935d1dd151340a
4
- data.tar.gz: ceda0918491d324d765baaa2b41ea0a12ff00253
3
+ metadata.gz: 095bcabf03137c3022fc3ebd1049b0c82a746cb5
4
+ data.tar.gz: 8a37425fbf6b3ff8287bb1713e7312c752adf392
5
5
  SHA512:
6
- metadata.gz: 84f2c7dd33b1491a5551871d2478ddc41dd08ecffeabf7155b0a3dce8bae5b2bbbced3fcbbb1f3ca98454c776d1b7770fcbd0008624b55cc05e320f390cd0368
7
- data.tar.gz: fbbec0817ac5b68a87c1b92826686a6e19d4f9025b78a330a2a3c319e5ece516a39f0c3ed34218d49c2a46fea1cb9c0b417e25400646bcc7270381ee107e9514
6
+ metadata.gz: 1e14b6ac636d346369e07c9c8fe15804ef71a15447b7a9dff118754b0059deaecabe6fa6becae887ec82da180fb4d7509327f370f1dd0a5b2071ae71fc62bbd3
7
+ data.tar.gz: 59b37db62c2ca82f42e4000fe5267e96a6368ebb4aa73f3f2b7968001982b092dbd1721a221110920044a997f590fedcf652916b188b3a2696e0054db07f3002
data/Gemfile CHANGED
@@ -12,11 +12,11 @@ group :development do
12
12
  gem "shoulda", ">= 0"
13
13
  gem "rdoc", "~> 3.12"
14
14
  gem "bundler", "~> 1.0"
15
- gem "jeweler", "~> 2.0.1"
15
+ gem "jeweler", "~> 2.0"
16
16
  gem "simplecov", ">= 0"
17
17
  end
18
18
 
19
19
  group :test do
20
- gem "awesome_print", "~> 1.6.0"
21
- gem "minitest", "~> 5.5.0"
20
+ gem "awesome_print", "~> 1.6"
21
+ gem "minitest", "~> 5.5"
22
22
  end
data/Gemfile.lock CHANGED
@@ -79,10 +79,10 @@ PLATFORMS
79
79
  ruby
80
80
 
81
81
  DEPENDENCIES
82
- awesome_print (~> 1.6.0)
82
+ awesome_print (~> 1.6)
83
83
  bundler (~> 1.0)
84
- jeweler (~> 2.0.1)
85
- minitest (~> 5.5.0)
84
+ jeweler (~> 2.0)
85
+ minitest (~> 5.5)
86
86
  multi_json (~> 1.10.0)
87
87
  rdoc (~> 3.12)
88
88
  rest-client (~> 1.7.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/lib/sellsy/api.rb CHANGED
@@ -28,148 +28,6 @@ module Sellsy
28
28
  return 'OAuth ' + oauth_params.map { |k, v| k + '="' + v + '"' }.join(', ')
29
29
  end
30
30
 
31
- def self.client=(client)
32
- payload = {
33
- 'method' => 'Client.create',
34
- 'params' => {
35
- 'third' => {
36
- 'name' => client.client_company.name,
37
- 'email' => client.client_company.email,
38
- 'tel' => client.client_company.landline,
39
- 'fax' => client.client_company.fax,
40
- 'siret' => client.client_company.billing_information.company_registration,
41
- 'vat' => client.client_company.billing_information.vat_registration
42
- },
43
- 'contact' => {
44
- 'name' => client.last_name,
45
- 'forename' => client.first_name,
46
- 'email' => client.email,
47
- 'tel' => client.landline,
48
- 'fax' => client.fax,
49
- 'mobile' => client.mobile
50
- },
51
- 'address' => {
52
- 'name' => client.address.name,
53
- 'part1' => client.address.street,
54
- 'part2' => client.address.addition,
55
- 'zip' => client.address.postal_code,
56
- 'town' => client.address.city,
57
- 'countrycode' => "FR"
58
- }
59
- }
60
- }
61
-
62
- self.request payload
63
- end
64
-
65
- def self.clients
66
- payload = {
67
- 'method' => 'Client.getList',
68
- 'params' => {}
69
- }
70
-
71
- self.request payload
72
- end
73
-
74
- def self.invoices=(invoice)
75
- payload = {
76
- 'method' => 'Document.create',
77
- 'params' => {
78
- 'document' => {
79
- 'doctype' => 'doctype',
80
- 'parentId' => 'parentId',
81
- 'thirdid' => 'clientid',
82
- 'displayedDate' => 'displayedDate',
83
- 'subject' => 'document_subject',
84
- 'notes' => 'document_notes',
85
- 'tags' => 'document_tags',
86
- 'displayShipAddress' => 'displayshippaddress_enum',
87
- 'rateCategory' => 'rateCategory',
88
- 'globalDiscount' => 'globalDiscount',
89
- 'globalDiscountUnit' => 'globalDiscountUnit',
90
- 'hasDoubleVat' => 'hasDoubleVat',
91
- 'currency' => 'currency',
92
- 'doclayout' => 'doclayout',
93
- 'payMediums' => 'payMediums',
94
-
95
- },
96
- 'paydate' => {
97
- 'id' => 'paydate_id',
98
- 'xdays' => 'paydate_xdays',
99
- 'endmonth' => 'paydate_endmonth',
100
- 'scaledDetails' => 'paydate_scaledDetails',
101
- 'custom' => 'paydate_custom'
102
-
103
- },
104
- 'thirdaddress' => {
105
- 'id' => 'thirdaddress_id'
106
- },
107
- 'shipaddress' => {
108
- 'id' => 'shipaddress_id'
109
- },
110
- 'row' => {
111
- '1' => {
112
- 'row_type' => 'packaging',
113
- 'row_packaging' => 'packagin_name',
114
- 'row_name' => 'row_name',
115
- 'row_unitAmount' => 'row_unit_amount',
116
- 'row_tax' => 'row_taxrate',
117
- 'row_taxid' => 'row_taxid',
118
- 'row_tax2id' => 'row_tax2id',
119
- 'row_qt' => 'row_quantity',
120
- 'row_isOption' => 'row_option',
121
- 'row_discount' => 'row_discount',
122
- 'row_discountUnit' => 'row_discountUnit'
123
- },
124
- '2' => {
125
- 'row_type' => 'shipping',
126
- 'row_shipping' => 'shipping_name',
127
- 'row_name' => 'row_name',
128
- 'row_unitAmount' => 'row_unit_amount',
129
- 'row_tax' => 'row_taxrate',
130
- 'row_taxid' => 'row_taxid',
131
- 'row_tax2id' => 'row_tax2id',
132
- 'row_qt' => 'row_quantity',
133
- 'row_isOption' => 'row_option',
134
- 'row_discount' => 'row_discount',
135
- 'row_discountUnit' => 'row_discountUnit'
136
- },
137
- '3' => {
138
- 'row_type' => 'item',
139
- 'row_linkedid' => 'catalogue_id_link',
140
- 'row_declid' => 'catalogue_declid_link',
141
- 'row_name' => 'row_name',
142
- 'row_notes' => 'row_notes',
143
- 'row_unit' => 'row_unit',
144
- 'row_unitAmount' => 'row_unit_amount',
145
- 'row_tax' => 'row_taxrate',
146
- 'row_taxid' => 'row_taxid',
147
- 'row_tax2id' => 'row_tax2id',
148
- 'row_qt' => 'row_quantity',
149
- 'row_isOption' => 'row_option',
150
- 'row_purchaseAmount' => 'row_purchaseAmount',
151
- 'row_discount' => 'row_discount',
152
- 'row_discountUnit' => 'row_discountUnit'
153
- },
154
- '4' => {
155
- 'row_type' => 'once',
156
- 'row_name' => 'row_name',
157
- 'row_notes' => 'row_notes',
158
- 'row_unit' => 'row_unit',
159
- 'row_unitAmount' => 'row_unit_amount',
160
- 'row_tax' => 'row_taxrate',
161
- 'row_taxid' => 'row_taxid',
162
- 'row_tax2id' => 'row_tax2id',
163
- 'row_qt' => 'row_quantity',
164
- 'row_isOption' => 'row_option',
165
- 'row_discount' => 'row_discount',
166
- 'row_discountUnit' => 'row_discountUnit'
167
- }
168
- }
169
- }
170
- }
171
- end
172
-
173
31
  def self.info
174
32
  payload = {
175
33
  :method => 'Infos.getInfos',
@@ -188,7 +46,7 @@ module Sellsy
188
46
 
189
47
  puts params.to_json
190
48
 
191
- RestClient.log = 'stdout'
49
+ # RestClient.log = 'stdout'
192
50
  RestClient.post 'https://apifeed.sellsy.com/0/', {:request => 1, :io_mode => 'json', 'do_in' => payload.to_json, :multipart => true}, {:authorization => self.authentication_header}
193
51
  end
194
52
 
@@ -202,121 +60,4 @@ module Sellsy
202
60
  end
203
61
  end
204
62
  end
205
-
206
- class Invoice
207
- attr_accessor :client_id
208
- attr_accessor :packaging_name
209
- attr_accessor :shipping_name
210
- attr_accessor :unit_amount
211
- attr_accessor :tax_rate
212
- end
213
-
214
- class Invoices
215
- attr_accessor :client
216
- attr_accessor :estimates
217
- attr_accessor :invoices
218
-
219
- def initialize(client)
220
- @client = client
221
- end
222
-
223
- def <<(invoice)
224
- payload = {
225
- 'method' => 'Document.create',
226
- 'params' => {
227
- 'document' => {
228
- 'doctype' => 'invoice',
229
- # 'parentId' => 'parentId',
230
- 'thirdid' => invoice.client_id
231
- # 'displayedDate' => 'displayedDate',
232
- # 'subject' => 'document_subject',
233
- # 'notes' => 'document_notes',
234
- # 'tags' => 'document_tags',
235
- # 'displayShipAddress' => 'displayshippaddress_enum',
236
- # 'rateCategory' => 'rateCategory',
237
- # 'globalDiscount' => 'globalDiscount',
238
- # 'globalDiscountUnit' => 'globalDiscountUnit',
239
- # 'hasDoubleVat' => 'hasDoubleVat',
240
- # 'currency' => 'currency',
241
- # 'doclayout' => 'doclayout',
242
- # 'payMediums' => 'payMediums'
243
- },
244
- # 'paydate' => {
245
- # 'id' => 'paydate_id',
246
- # 'xdays' => 'paydate_xdays',
247
- # 'endmonth' => 'paydate_endmonth',
248
- # 'scaledDetails' => 'paydate_scaledDetails',
249
- # 'custom' => 'paydate_custom'
250
- # },
251
- # 'thirdaddress' => {
252
- # 'id' => 'thirdaddress_id'
253
- # },
254
- # 'shipaddress' => {
255
- # 'id' => 'shipaddress_id'
256
- # },
257
- 'row' => {
258
- '1' => {
259
- 'row_type' => 'packaging',
260
- 'row_packaging' => invoice.packaging_name,
261
- 'row_name' => 'row_name',
262
- 'row_unitAmount' => invoice.unit_amount,
263
- 'row_tax' => invoice.tax_rate
264
- # 'row_taxid' => 'row_taxid',
265
- # 'row_tax2id' => 'row_tax2id',
266
- # 'row_qt' => 'row_quantity',
267
- # 'row_isOption' => 'row_option',
268
- # 'row_discount' => 'row_discount',
269
- # 'row_discountUnit' => 'row_discountUnit'
270
- },
271
- '2' => {
272
- 'row_type' => 'shipping',
273
- 'row_shipping' => invoice.shipping_name,
274
- # 'row_name' => 'row_name',
275
- 'row_unitAmount' => invoice.unit_amount,
276
- 'row_tax' => invoice.tax_rate,
277
- # 'row_taxid' => 'row_taxid',
278
- 'row_tax2id' => invoice.quantity
279
- # 'row_qt' => 'row_quantity',
280
- # 'row_isOption' => 'row_option',
281
- # 'row_discount' => 'row_discount',
282
- # 'row_discountUnit' => 'row_discountUnit'
283
- }
284
- # '3' => {
285
- # 'row_type' => 'item',
286
- # 'row_linkedid' => 'catalogue_id_link',
287
- # 'row_declid' => 'catalogue_declid_link',
288
- # 'row_name' => 'row_name',
289
- # 'row_notes' => 'row_notes',
290
- # 'row_unit' => 'row_unit',
291
- # 'row_unitAmount' => 'row_unit_amount',
292
- # 'row_tax' => 'row_taxrate',
293
- # 'row_taxid' => 'row_taxid',
294
- # 'row_tax2id' => 'row_tax2id',
295
- # 'row_qt' => 'row_quantity',
296
- # 'row_isOption' => 'row_option',
297
- # 'row_purchaseAmount' => 'row_purchaseAmount',
298
- # 'row_discount' => 'row_discount',
299
- # 'row_discountUnit' => 'row_discountUnit'
300
- # },
301
- # '4' => {
302
- # 'row_type' => 'once',
303
- # 'row_name' => 'row_name',
304
- # 'row_notes' => 'row_notes',
305
- # 'row_unit' => 'row_unit',
306
- # 'row_unitAmount' => 'row_unit_amount',
307
- # 'row_tax' => 'row_taxrate',
308
- # 'row_taxid' => 'row_taxid',
309
- # 'row_tax2id' => 'row_tax2id',
310
- # 'row_qt' => 'row_quantity',
311
- # 'row_isOption' => 'row_option',
312
- # 'row_discount' => 'row_discount',
313
- # 'row_discountUnit' => 'row_discountUnit'
314
- # }
315
- }
316
- }
317
- }
318
-
319
- @client.request payload
320
- end
321
- end
322
63
  end
@@ -5,13 +5,71 @@ module Sellsy
5
5
  attr_accessor :id
6
6
  attr_accessor :name
7
7
 
8
- def initialize(id, name)
9
- @id = id
10
- @name = name
8
+ def create
9
+ command = {
10
+ 'method' => 'Client.create',
11
+ 'params' => {
12
+ 'third' => {
13
+ 'name' => @name
14
+ }
15
+ }
16
+ }
17
+
18
+ response = MultiJson.load(Sellsy::Api.request command)
19
+
20
+ @id = response['response']['client_id']
21
+
22
+ return response['status'] == 'success'
23
+ end
24
+
25
+ def update
26
+
11
27
  end
12
28
  end
13
29
 
14
30
  class Clients
31
+ def self.find(id)
32
+ command = {
33
+ 'method' => 'Client.getOne',
34
+ 'params' => {
35
+ 'clientid' => id
36
+ }
37
+ }
38
+
39
+ response = MultiJson.load(Sellsy::Api.request command)
40
+
41
+ value = response['response']['client']
42
+
43
+ client = Client.new
44
+ client.id = value['id']
45
+ client.name = value['name']
46
+
47
+ return client
48
+ end
49
+
50
+ def self.search(query)
51
+ command = {
52
+ 'method' => 'Client.getList',
53
+ 'params' => {
54
+ 'search' => {
55
+ 'contains' => query
56
+ }
57
+ }
58
+ }
59
+
60
+ response = MultiJson.load(Sellsy::Api.request command)
61
+
62
+ clients = []
63
+ response['response']['result'].each do |key, value|
64
+ client = Client.new
65
+ client.id = key
66
+ client.name = value['fullName']
67
+ clients << client
68
+ end
69
+
70
+ return clients
71
+ end
72
+
15
73
  def self.all
16
74
  command = {
17
75
  'method' => 'Client.getList',
@@ -22,7 +80,10 @@ module Sellsy
22
80
 
23
81
  clients = []
24
82
  response['response']['result'].each do |key, value|
25
- clients << Client.new(key, value['name'])
83
+ client = Client.new
84
+ client.id = key
85
+ client.name = value['fullName']
86
+ clients << client
26
87
  end
27
88
 
28
89
  return clients
@@ -9,38 +9,8 @@ module Sellsy
9
9
  attr_accessor :amount
10
10
  attr_accessor :unit_amount
11
11
  attr_accessor :tax_rate
12
- end
13
-
14
- class Invoices
15
- attr_accessor :estimates
16
- attr_accessor :invoices
17
-
18
- def initialize
19
- end
20
12
 
21
- def self.all
22
- command = {
23
- 'method' => 'Document.getList',
24
- 'params' => {
25
- 'doctype' => 'invoice'
26
- }
27
- }
28
-
29
- response = MultiJson.load(Sellsy::Api.request command)
30
-
31
- invoices = []
32
- # ap response
33
- response['response']['result'].each do |key, value|
34
- invoice = Invoice.new
35
- invoice.id = value['id']
36
- invoice.amount = value['rowsAmount']
37
- invoices << invoice
38
- end
39
-
40
- return invoices
41
- end
42
-
43
- def <<(invoice)
13
+ def create(invoice)
44
14
  command = {
45
15
  'method' => 'Document.create',
46
16
  'params' => {
@@ -138,5 +108,36 @@ module Sellsy
138
108
 
139
109
  Sellsy::Api.request command
140
110
  end
111
+
112
+ def update
113
+
114
+ end
115
+ end
116
+
117
+ class Invoices
118
+ attr_accessor :estimates
119
+ attr_accessor :invoices
120
+
121
+ def self.all
122
+ command = {
123
+ 'method' => 'Document.getList',
124
+ 'params' => {
125
+ 'doctype' => 'invoice'
126
+ }
127
+ }
128
+
129
+ response = MultiJson.load(Sellsy::Api.request command)
130
+
131
+ invoices = []
132
+
133
+ response['response']['result'].each do |key, value|
134
+ invoice = Invoice.new
135
+ invoice.id = value['id']
136
+ invoice.amount = value['rowsAmount']
137
+ invoices << invoice
138
+ end
139
+
140
+ return invoices
141
+ end
141
142
  end
142
143
  end
data/sellsy.gemspec ADDED
@@ -0,0 +1,76 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: sellsy 0.2.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "sellsy"
9
+ s.version = "0.2.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Jens Stamm"]
14
+ s.date = "2015-03-01"
15
+ s.description = "Ruby Gem for Sellsy"
16
+ s.email = "jens@lacazoo.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "LICENSE.txt",
20
+ "README.md",
21
+ "README.rdoc"
22
+ ]
23
+ s.files = [
24
+ ".document",
25
+ "Gemfile",
26
+ "Gemfile.lock",
27
+ "LICENSE",
28
+ "LICENSE.txt",
29
+ "README.md",
30
+ "README.rdoc",
31
+ "Rakefile",
32
+ "VERSION",
33
+ "lib/sellsy.rb",
34
+ "lib/sellsy/api.rb",
35
+ "lib/sellsy/clients.rb",
36
+ "lib/sellsy/invoices.rb",
37
+ "sellsy.gemspec",
38
+ "test/helper.rb",
39
+ "test/test_sellsy.rb"
40
+ ]
41
+ s.homepage = "http://github.com/faustus7/sellsy"
42
+ s.licenses = ["MIT"]
43
+ s.rubygems_version = "2.4.3"
44
+ s.summary = "Sellsy Client API"
45
+
46
+ if s.respond_to? :specification_version then
47
+ s.specification_version = 4
48
+
49
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
+ s.add_runtime_dependency(%q<multi_json>, ["~> 1.10.0"])
51
+ s.add_runtime_dependency(%q<rest-client>, ["~> 1.7.0"])
52
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
53
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
54
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
55
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
56
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
57
+ else
58
+ s.add_dependency(%q<multi_json>, ["~> 1.10.0"])
59
+ s.add_dependency(%q<rest-client>, ["~> 1.7.0"])
60
+ s.add_dependency(%q<shoulda>, [">= 0"])
61
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
62
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
63
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
64
+ s.add_dependency(%q<simplecov>, [">= 0"])
65
+ end
66
+ else
67
+ s.add_dependency(%q<multi_json>, ["~> 1.10.0"])
68
+ s.add_dependency(%q<rest-client>, ["~> 1.7.0"])
69
+ s.add_dependency(%q<shoulda>, [">= 0"])
70
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
71
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
72
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
73
+ s.add_dependency(%q<simplecov>, [">= 0"])
74
+ end
75
+ end
76
+
data/test/test_sellsy.rb CHANGED
@@ -8,11 +8,9 @@ class TestSellsy < Minitest::Test
8
8
  config.user_token = ENV['SELLSY_USER_TOKEN']
9
9
  config.user_secret = ENV['SELLSY_USER_SECRET']
10
10
  end
11
-
12
- @invoices = Sellsy
13
11
  end
14
12
 
15
- def test_that_all_clients
13
+ def test_that_all_clients_are_listed
16
14
  @clients = Sellsy::Clients.all
17
15
 
18
16
  ap @clients
@@ -20,7 +18,22 @@ class TestSellsy < Minitest::Test
20
18
  refute_equal 0, @clients.length
21
19
  end
22
20
 
23
- def test_that_all_invocies
21
+ def test_that_client_is_created_and_found
22
+ @client = Sellsy::Client.new
23
+ @client.name = "Test Company #{Random.new_seed}"
24
+
25
+ ap @client
26
+
27
+ assert @client.create
28
+
29
+ @client2 = Sellsy::Clients.find(@client.id)
30
+
31
+ ap @client2
32
+
33
+ assert_kind_of Sellsy::Client, @client2
34
+ end
35
+
36
+ def test_that_all_invoices_are_listed
24
37
  @invoices = Sellsy::Invoices.all
25
38
 
26
39
  ap @invoices
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sellsy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Stamm
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 2.0.1
89
+ version: '2.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 2.0.1
96
+ version: '2.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: simplecov
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -131,6 +131,7 @@ files:
131
131
  - lib/sellsy/api.rb
132
132
  - lib/sellsy/clients.rb
133
133
  - lib/sellsy/invoices.rb
134
+ - sellsy.gemspec
134
135
  - test/helper.rb
135
136
  - test/test_sellsy.rb
136
137
  homepage: http://github.com/faustus7/sellsy