lce 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +1 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +6 -0
  7. data/LICENSE +21 -0
  8. data/README.md +98 -0
  9. data/Rakefile +5 -0
  10. data/lce.gemspec +30 -0
  11. data/lib/lce.rb +72 -0
  12. data/lib/lce/client.rb +34 -0
  13. data/lib/lce/client/connection.rb +23 -0
  14. data/lib/lce/client/errors.rb +25 -0
  15. data/lib/lce/client/request.rb +80 -0
  16. data/lib/lce/offer.rb +25 -0
  17. data/lib/lce/order.rb +51 -0
  18. data/lib/lce/quote.rb +34 -0
  19. data/lib/lce/version.rb +4 -0
  20. data/lib/paginated_array.rb +25 -0
  21. data/spec/fixtures/access_denied +20 -0
  22. data/spec/fixtures/account_disabled +20 -0
  23. data/spec/fixtures/check +464 -0
  24. data/spec/fixtures/offers/available_delivery_locations/found +785 -0
  25. data/spec/fixtures/offers/find/found +66 -0
  26. data/spec/fixtures/offers/find/not_found +15 -0
  27. data/spec/fixtures/order_params +23 -0
  28. data/spec/fixtures/orders/all/page_1 +111 -0
  29. data/spec/fixtures/orders/find/found +106 -0
  30. data/spec/fixtures/orders/find/not_found +15 -0
  31. data/spec/fixtures/orders/labels/labels.pdf +0 -0
  32. data/spec/fixtures/orders/labels/response +0 -0
  33. data/spec/fixtures/orders/place/created +106 -0
  34. data/spec/fixtures/orders/place/empty_params +15 -0
  35. data/spec/fixtures/orders/place/missing_params +15 -0
  36. data/spec/fixtures/orders/tracking +30 -0
  37. data/spec/fixtures/quote_params +25 -0
  38. data/spec/fixtures/quotes/all/page_1 +11594 -0
  39. data/spec/fixtures/quotes/all/page_2 +1665 -0
  40. data/spec/fixtures/quotes/find/found +492 -0
  41. data/spec/fixtures/quotes/find/not_found +15 -0
  42. data/spec/fixtures/quotes/request/created +492 -0
  43. data/spec/fixtures/quotes/request/empty_quote +15 -0
  44. data/spec/fixtures/quotes/request/missing_params +15 -0
  45. data/spec/lce/client_spec.rb +41 -0
  46. data/spec/lce/offer_spec.rb +85 -0
  47. data/spec/lce/order_spec.rb +136 -0
  48. data/spec/lce/quote_spec.rb +111 -0
  49. data/spec/lce_spec.rb +109 -0
  50. data/spec/paginated_array_spec.rb +55 -0
  51. data/spec/spec_helper.rb +17 -0
  52. data/tasks/rspec.rake +3 -0
  53. metadata +239 -0
@@ -0,0 +1,492 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/1.6.0
3
+ Date: Wed, 13 Aug 2014 13:56:16 GMT
4
+ Content-Type: application/json
5
+ Content-Length: 17653
6
+ Connection: keep-alive
7
+ Lce-Env: staging
8
+
9
+ {
10
+ "status":"success",
11
+ "self":"https://test.lce.io/v1/quotes/cd8d1a03-bfec-4115-87ef-8f8ba91a7199",
12
+ "data":{
13
+ "id":"cd8d1a03-bfec-4115-87ef-8f8ba91a7199",
14
+ "created_at":"2014-08-13T14:56:55+02:00",
15
+ "ordered":false,
16
+ "ordered?":false,
17
+ "shipper":{
18
+ "country":"FR",
19
+ "postal_code":"31300",
20
+ "city":"Toulouse"
21
+ },
22
+ "recipient":{
23
+ "country":"FR",
24
+ "postal_code":"06000",
25
+ "is_a_company":"true",
26
+ "city":"Nice"
27
+ },
28
+ "parcels":[
29
+ {
30
+ "width":15.0,
31
+ "length":15.0,
32
+ "height":15.0,
33
+ "weight":2.0
34
+ }
35
+ ],
36
+ "offers":[
37
+ {
38
+ "id":"ff75b691-a2e0-46b0-9909-d529b2dbb90c",
39
+ "quote_id":"cd8d1a03-bfec-4115-87ef-8f8ba91a7199",
40
+ "product_id":"371ce146-1e6c-4a44-9a43-e0f124818f99",
41
+ "orderable?":true,
42
+ "product":{
43
+ "delay":"24",
44
+ "collection_informations":{
45
+ "en":"Post Office Drop Off \r\n",
46
+ "es":"Depósito en oficina de correos en Francia.",
47
+ "fr":"Dépôt en bureau de poste \r\n"
48
+ },
49
+ "delivery_informations":{
50
+ "en":"Drop off at your nearest Post Office \r\nNext day delivery before 13:00 pm\r\nDelivered wih POD\r\nMoney-back guarantee (Terms & conditions)\r\n\r\n",
51
+ "es":"Entrega en 24h antes de 13:00 (hora local)",
52
+ "fr":"J+1 \r\nLivraison le lendemain avant 13H"
53
+ },
54
+ "details":{
55
+ "en":"Drop off at your nearest Post Office \r\nNext day delivery before 13:00 pm\r\nDelivered wih POD\r\nMoney-back guarantee (Terms & conditions)\r\n",
56
+ "es":"Servicio Chronopost \r\nIMPORTANTE: peso máximo por paquete : 30 kg",
57
+ "fr":"Dépôt en bureau de poste. \r\nLivraison le lendemain avant 13H.\r\nPossibilité de collecte sur demande auprès de LCE pour les clients avec des envois réguliers.\r\nDélai garanti sous conditions (voir CGV).\r\n"
58
+ },
59
+ "export_from":[
60
+ "FR",
61
+ "MC"
62
+ ],
63
+ "id":"371ce146-1e6c-4a44-9a43-e0f124818f99",
64
+ "logo":"lce_yellow",
65
+ "code":"lce_yellow_express_13",
66
+ "name":"Lce Yellow Express 13",
67
+ "pick_up":false,
68
+ "drop_off":true,
69
+ "preset_delivery_location":false
70
+ },
71
+ "price":{
72
+ "formatted":"€6.25",
73
+ "currency":"EUR",
74
+ "amount":"6.25",
75
+ "amount_in_cents":625
76
+ },
77
+ "price_vat":{
78
+ "formatted":"€1.25",
79
+ "currency":"EUR",
80
+ "amount":"1.25",
81
+ "amount_in_cents":125
82
+ },
83
+ "total_price":{
84
+ "formatted":"€7.50",
85
+ "currency":"EUR",
86
+ "amount":"7.5",
87
+ "amount_in_cents":750
88
+ },
89
+ "collection_dates":null
90
+ },
91
+ {
92
+ "id":"563aeac0-4a88-4269-b9b7-48964a8678f0",
93
+ "quote_id":"cd8d1a03-bfec-4115-87ef-8f8ba91a7199",
94
+ "product_id":"b8b9a657-2b51-41f5-ab35-ac84bc9864bc",
95
+ "orderable?":true,
96
+ "product":{
97
+ "delay":"24",
98
+ "collection_informations":{
99
+ "en":"Post Office Drop Off \r\n",
100
+ "es":"Depósito en oficina de correos en Francia.",
101
+ "fr":"Dépôt en bureau de poste\r\n"
102
+ },
103
+ "delivery_informations":{
104
+ "en":"Next Day\r\nNext day delivery at pickup location\r\n",
105
+ "es":"Déposito en Punto Pack ",
106
+ "fr":"J+1 \r\nLivraison le lendemain en point relais.\r\n"
107
+ },
108
+ "details":{
109
+ "en":"Drop off at your nearest Post Office \r\nDelivered wih POD\r\nNext day delivery \r\nWeight :30 kg per pkg\r\nMoney-back guarantee (Terms & conditions)\r\n",
110
+ "es":"Servicio Chronopost \r\nIMPORTANTE: peso máximo por paquete : 20 kg",
111
+ "fr":"Dépôt en bureau de poste. \r\nLivraison le lendemain en point relais.\r\nPossibilité de collecte sur demande auprès de LCE pour les clients avec des envois réguliers.\r\nTrouvez votre point relais sur notre menu adresse.\r\nDélai garanti sous conditions (voir CGV).\r\n"
112
+ },
113
+ "export_from":[
114
+ "FR",
115
+ "MC"
116
+ ],
117
+ "id":"b8b9a657-2b51-41f5-ab35-ac84bc9864bc",
118
+ "logo":"lce_yellow",
119
+ "code":"lce_yellow_express_shop",
120
+ "name":"Lce Yellow Express Shop",
121
+ "pick_up":false,
122
+ "drop_off":true,
123
+ "preset_delivery_location":true
124
+ },
125
+ "price":{
126
+ "formatted":"€6.95",
127
+ "currency":"EUR",
128
+ "amount":"6.95",
129
+ "amount_in_cents":695
130
+ },
131
+ "price_vat":{
132
+ "formatted":"€1.39",
133
+ "currency":"EUR",
134
+ "amount":"1.39",
135
+ "amount_in_cents":139
136
+ },
137
+ "total_price":{
138
+ "formatted":"€8.34",
139
+ "currency":"EUR",
140
+ "amount":"8.34",
141
+ "amount_in_cents":834
142
+ },
143
+ "collection_dates":null
144
+ },
145
+ {
146
+ "id":"d4e3b562-3f1b-49c7-9611-fc3befba847a",
147
+ "quote_id":"cd8d1a03-bfec-4115-87ef-8f8ba91a7199",
148
+ "product_id":"2747812c-e725-43c0-a076-65b7b9afa99a",
149
+ "orderable?":true,
150
+ "product":{
151
+ "delay":"48-72",
152
+ "collection_informations":{
153
+ "en":"COLLECTION TODAY* \r\n*If you book before 10 am (local time)",
154
+ "es":"Recogidas : antes de las 13 horas (según población)",
155
+ "fr":"Collecte aujourd'hui*\r\n*Pour toute commande passée avant 10H (heure locale)."
156
+ },
157
+ "delivery_informations":{
158
+ "en":"48/72\r\nDelivery within 2/3 days in Europe.",
159
+ "es":"Nacional : 24/72 según el destino \r\nInternacional: 48/72 según el pais de destino. Aunque hay que tener en cuenta que se tratan de plazos de entrega no garantizados. Puedes consultar el plazo de entrega correspondiente en la página de resultados de búsqueda.",
160
+ "fr":"Livraison en J+2\r\nLivraison en 48/96 h en Europe."
161
+ },
162
+ "details":{
163
+ "en":"Delivery Monday-Friday only \r\nAdditional Service Options see : Terms & conditions. \r\nInternational transit times are estimated and assume no Customs delays. Please always provide a local contact number for the recipient.",
164
+ "es":"Servicio UPS STANDARD con entrega en 24/72 horas en función de la distancia dentro de España. \r\nIMPORTANTE: La suma de todos los lados no puede ser mas de 300cm y el peso máximo admitido por bulto es de 70Kg. ",
165
+ "fr":"Enlèvement sur site le jour même pour toute commande passée avant 10H Livraison sous 48/72h en Europe (hors délai douane)\r\nPour les retours, modifications d'adresses, adresse erronée voir CGV."
166
+ },
167
+ "export_from":[
168
+ "FR"
169
+ ],
170
+ "id":"2747812c-e725-43c0-a076-65b7b9afa99a",
171
+ "logo":"lce_brown",
172
+ "code":"lce_brown_economy",
173
+ "name":"Lce Brown Economy",
174
+ "pick_up":true,
175
+ "drop_off":false,
176
+ "preset_delivery_location":false
177
+ },
178
+ "price":{
179
+ "formatted":"€9.38",
180
+ "currency":"EUR",
181
+ "amount":"9.38",
182
+ "amount_in_cents":938
183
+ },
184
+ "price_vat":{
185
+ "formatted":"€1.88",
186
+ "currency":"EUR",
187
+ "amount":"1.88",
188
+ "amount_in_cents":188
189
+ },
190
+ "total_price":{
191
+ "formatted":"€11.26",
192
+ "currency":"EUR",
193
+ "amount":"11.26",
194
+ "amount_in_cents":1126
195
+ },
196
+ "collection_dates":[
197
+ {
198
+ "date":"2014-08-13",
199
+ "cutoff":""
200
+ },
201
+ {
202
+ "date":"2014-08-14",
203
+ "cutoff":""
204
+ },
205
+ {
206
+ "date":"2014-08-15",
207
+ "cutoff":""
208
+ },
209
+ {
210
+ "date":"2014-08-18",
211
+ "cutoff":""
212
+ },
213
+ {
214
+ "date":"2014-08-19",
215
+ "cutoff":""
216
+ },
217
+ {
218
+ "date":"2014-08-20",
219
+ "cutoff":""
220
+ },
221
+ {
222
+ "date":"2014-08-21",
223
+ "cutoff":""
224
+ },
225
+ {
226
+ "date":"2014-08-22",
227
+ "cutoff":""
228
+ }
229
+ ]
230
+ },
231
+ {
232
+ "id":"f16b6083-a992-4622-9a8d-0a048d088857",
233
+ "quote_id":"cd8d1a03-bfec-4115-87ef-8f8ba91a7199",
234
+ "product_id":"c0c72c82-6bfc-468b-b3a8-5bbd4c7aca5e",
235
+ "orderable?":true,
236
+ "product":{
237
+ "delay":"24",
238
+ "collection_informations":{
239
+ "en":"COLLECTION TODAY* \r\n*If you book before midday (local time)",
240
+ "es":"Recogida hoy si contrata antes de mediodía (hora local).*",
241
+ "fr":"Collecte aujourd'hui* \r\n*Pour toute commande passée avant midi (heure locale)."
242
+ },
243
+ "delivery_informations":{
244
+ "en":"NEXT DAY",
245
+ "es":"Entrega mañana ",
246
+ "fr":"Livraison le lendemain en France"
247
+ },
248
+ "details":{
249
+ "en":"Collection Monday-Friday only \r\nDelivery between 9.00am-6:00pm local time \r\nDelivery Monday-Friday only ",
250
+ "es":"Localidades remotas, pedido de recogida con un día de antelación.\r\nIMPORTANTE: La suma de todos los lados no puede ser mas de 300 cm de largo.\r\nEl número de teléfono del destinatario es obligatorio.\r\nPlazo no garantizado",
251
+ "fr":"Enlèvement entre 13.00 et 18:00 (heure locale)\r\nLes délais sont donnés à titre purement indicatifs. \r\nDélai non garanti;"
252
+ },
253
+ "export_from":[
254
+ "FR"
255
+ ],
256
+ "id":"c0c72c82-6bfc-468b-b3a8-5bbd4c7aca5e",
257
+ "logo":"lce_red",
258
+ "code":"lce_red_express",
259
+ "name":"Lce Red Express",
260
+ "pick_up":true,
261
+ "drop_off":false,
262
+ "preset_delivery_location":false
263
+ },
264
+ "price":{
265
+ "formatted":"€9.65",
266
+ "currency":"EUR",
267
+ "amount":"9.65",
268
+ "amount_in_cents":965
269
+ },
270
+ "price_vat":{
271
+ "formatted":"€1.93",
272
+ "currency":"EUR",
273
+ "amount":"1.93",
274
+ "amount_in_cents":193
275
+ },
276
+ "total_price":{
277
+ "formatted":"€11.58",
278
+ "currency":"EUR",
279
+ "amount":"11.58",
280
+ "amount_in_cents":1158
281
+ },
282
+ "collection_dates":[
283
+ {
284
+ "date":"2014-08-13",
285
+ "cutoff":""
286
+ },
287
+ {
288
+ "date":"2014-08-14",
289
+ "cutoff":""
290
+ },
291
+ {
292
+ "date":"2014-08-15",
293
+ "cutoff":""
294
+ },
295
+ {
296
+ "date":"2014-08-18",
297
+ "cutoff":""
298
+ },
299
+ {
300
+ "date":"2014-08-19",
301
+ "cutoff":""
302
+ },
303
+ {
304
+ "date":"2014-08-20",
305
+ "cutoff":""
306
+ },
307
+ {
308
+ "date":"2014-08-21",
309
+ "cutoff":""
310
+ },
311
+ {
312
+ "date":"2014-08-22",
313
+ "cutoff":""
314
+ }
315
+ ]
316
+ },
317
+ {
318
+ "id":"8d4e2fad-1c8f-4a39-81ff-d761bd8858ba",
319
+ "quote_id":"cd8d1a03-bfec-4115-87ef-8f8ba91a7199",
320
+ "product_id":"e975259c-8c99-4f14-9f4d-e2428d4baf75",
321
+ "orderable?":true,
322
+ "product":{
323
+ "delay":"24",
324
+ "collection_informations":{
325
+ "en":"COLLECTION TODAY*\r\n*If you book before midday (local time).",
326
+ "es":"Recogida hoy si contrata antes de la 12:00",
327
+ "fr":"Collecte aujourd'hui*\r\n*Pour toute commande passée avant 12H (heure locale)."
328
+ },
329
+ "delivery_informations":{
330
+ "en":"NEXT DAY \r\nNext business day delivery",
331
+ "es":"Tiempo de transito: 24 Horas",
332
+ "fr":"Livraison en J+1 avant midi\r\nLivraison en 24h en Europe et de 48 à 96h dans le reste du monde selon pays de destination."
333
+ },
334
+ "details":{
335
+ "en":"Collection between 2:00 Pm-5.30pm\r\nCollection Monday-Friday only \r\nDelivery between 2.00pm-5.30pm local time\r\nDelivery Monday-Friday only\r\nNo courier service can be guaranteed; international transit times are estimated and assume no Customs delays. Please always provide a local contact number for the recipient.",
336
+ "es":"Recogidas en poblaciones remotas deberán activarse, como mínimo, con un día hábil de antelación (de lunes a viernes), antes de las 17 horas.\r\nEl precio del servicio incluye 3 intentos de recogida y entrega. Es muy importante que no los agotes.\r\nIMPORTANTE: La suma de todos los lados no puede ser mas de 300cm y el peso máximo admitido por bulto es de 70Kg. ",
337
+ "fr":"Enlèvement sur site le jour même pour toute commande passée avant 10H Livraison sous 48/72h en Europe (hors délai douane)\r\nPour les retours, modifications d'adresses, adresse erronée voir CGV."
338
+ },
339
+ "export_from":[
340
+ "FR"
341
+ ],
342
+ "id":"e975259c-8c99-4f14-9f4d-e2428d4baf75",
343
+ "logo":"lce_brown",
344
+ "code":"lce_brown_express",
345
+ "name":"Lce Brown Express",
346
+ "pick_up":true,
347
+ "drop_off":false,
348
+ "preset_delivery_location":false
349
+ },
350
+ "price":{
351
+ "formatted":"€14.78",
352
+ "currency":"EUR",
353
+ "amount":"14.78",
354
+ "amount_in_cents":1478
355
+ },
356
+ "price_vat":{
357
+ "formatted":"€2.96",
358
+ "currency":"EUR",
359
+ "amount":"2.96",
360
+ "amount_in_cents":296
361
+ },
362
+ "total_price":{
363
+ "formatted":"€17.74",
364
+ "currency":"EUR",
365
+ "amount":"17.74",
366
+ "amount_in_cents":1774
367
+ },
368
+ "collection_dates":[
369
+ {
370
+ "date":"2014-08-13",
371
+ "cutoff":""
372
+ },
373
+ {
374
+ "date":"2014-08-14",
375
+ "cutoff":""
376
+ },
377
+ {
378
+ "date":"2014-08-15",
379
+ "cutoff":""
380
+ },
381
+ {
382
+ "date":"2014-08-18",
383
+ "cutoff":""
384
+ },
385
+ {
386
+ "date":"2014-08-19",
387
+ "cutoff":""
388
+ },
389
+ {
390
+ "date":"2014-08-20",
391
+ "cutoff":""
392
+ },
393
+ {
394
+ "date":"2014-08-21",
395
+ "cutoff":""
396
+ },
397
+ {
398
+ "date":"2014-08-22",
399
+ "cutoff":""
400
+ }
401
+ ]
402
+ },
403
+ {
404
+ "id":"b03d11ac-2d6e-4025-96c4-70b497be87d6",
405
+ "quote_id":"cd8d1a03-bfec-4115-87ef-8f8ba91a7199",
406
+ "product_id":"ff2e3f0b-c29f-46d7-9485-a252f4116a5a",
407
+ "orderable?":true,
408
+ "product":{
409
+ "delay":"24-48",
410
+ "collection_informations":{
411
+ "en":"COLLECTION TODAY* \r\n*If you book before midday (local time)",
412
+ "es":"Recogida hoy si contrata antes de la 12:00",
413
+ "fr":"Collecte aujourd'hui* \r\n*Pour toute commande passée avant midi (heure locale). "
414
+ },
415
+ "delivery_informations":{
416
+ "en":"NEXT DAY \r\nDelivery the next working day in Europe.\r\n2/6 days delivery in the rest of the world.",
417
+ "es":"Tiempo de transito: 24/48 Horas",
418
+ "fr":"J+1 \r\nLivraison le lendemain dans la journée en Europe.\r\nLivraison sous 2 à 6 jours ouvrés pour le reste du monde. "
419
+ },
420
+ "details":{
421
+ "en":"Delivery Monday-Friday only \r\nAdditional Service Options see : Terms & conditions. \r\nInternational transit times are estimated and assume no Customs delays. Please always provide a local contact number for the recipient.",
422
+ "es":"Recogidas en poblaciones remotas deberán activarse, como mínimo, con un día hábil de antelación (de lunes a viernes).\r\nEl precio del servicio incluye 3 intentos de recogida y entrega. Es muy importante que no los agotes.\r\nIMPORTANTE: La suma de todos los lados no puede ser mas de 300cm y el peso máximo admitido por bulto es de 68Kg. ",
423
+ "fr":"Enlèvement sur site le jour même pour toute commande passée avant 12:00. Livraison le jour ouvré suivant dans la journée.\r\nPour les retours, modifications d'adresses, adresse erronée voir CGV."
424
+ },
425
+ "export_from":[
426
+ "FR"
427
+ ],
428
+ "id":"ff2e3f0b-c29f-46d7-9485-a252f4116a5a",
429
+ "logo":"lce_purple",
430
+ "code":"lce_purple_express",
431
+ "name":"Lce Purple Express",
432
+ "pick_up":true,
433
+ "drop_off":false,
434
+ "preset_delivery_location":false
435
+ },
436
+ "price":{
437
+ "formatted":"€23.14",
438
+ "currency":"EUR",
439
+ "amount":"23.14",
440
+ "amount_in_cents":2314
441
+ },
442
+ "price_vat":{
443
+ "formatted":"€4.63",
444
+ "currency":"EUR",
445
+ "amount":"4.63",
446
+ "amount_in_cents":463
447
+ },
448
+ "total_price":{
449
+ "formatted":"€27.77",
450
+ "currency":"EUR",
451
+ "amount":"27.77",
452
+ "amount_in_cents":2777
453
+ },
454
+ "collection_dates":[
455
+ {
456
+ "date":"2014-08-13",
457
+ "cutoff":""
458
+ },
459
+ {
460
+ "date":"2014-08-14",
461
+ "cutoff":""
462
+ },
463
+ {
464
+ "date":"2014-08-15",
465
+ "cutoff":""
466
+ },
467
+ {
468
+ "date":"2014-08-18",
469
+ "cutoff":""
470
+ },
471
+ {
472
+ "date":"2014-08-19",
473
+ "cutoff":""
474
+ },
475
+ {
476
+ "date":"2014-08-20",
477
+ "cutoff":""
478
+ },
479
+ {
480
+ "date":"2014-08-21",
481
+ "cutoff":""
482
+ },
483
+ {
484
+ "date":"2014-08-22",
485
+ "cutoff":""
486
+ }
487
+ ]
488
+ }
489
+ ],
490
+ "origin":null
491
+ }
492
+ }