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,66 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/1.6.0
3
+ Date: Thu, 14 Aug 2014 12:35:13 GMT
4
+ Content-Type: application/json
5
+ Content-Length: 2080
6
+ Connection: keep-alive
7
+ Lce-Env: staging
8
+
9
+ {
10
+ "status":"success",
11
+ "self":"https://test.lce.io/v1/offers/ff75b691-a2e0-46b0-9909-d529b2dbb90c",
12
+ "data":{
13
+ "id":"ff75b691-a2e0-46b0-9909-d529b2dbb90c",
14
+ "quote_id":"cd8d1a03-bfec-4115-87ef-8f8ba91a7199",
15
+ "product_id":"371ce146-1e6c-4a44-9a43-e0f124818f99",
16
+ "orderable?":true,
17
+ "product":{
18
+ "delay":"24",
19
+ "collection_informations":{
20
+ "en":"Post Office Drop Off \r\n",
21
+ "es":"Depósito en oficina de correos en Francia.",
22
+ "fr":"Dépôt en bureau de poste \r\n"
23
+ },
24
+ "delivery_informations":{
25
+ "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",
26
+ "es":"Entrega en 24h antes de 13:00 (hora local)",
27
+ "fr":"J+1 \r\nLivraison le lendemain avant 13H"
28
+ },
29
+ "details":{
30
+ "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",
31
+ "es":"Servicio Chronopost \r\nIMPORTANTE: peso máximo por paquete : 30 kg",
32
+ "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"
33
+ },
34
+ "export_from":[
35
+ "FR",
36
+ "MC"
37
+ ],
38
+ "id":"371ce146-1e6c-4a44-9a43-e0f124818f99",
39
+ "logo":"lce_yellow",
40
+ "code":"lce_yellow_express_13",
41
+ "name":"Lce Yellow Express 13",
42
+ "pick_up":false,
43
+ "drop_off":true,
44
+ "preset_delivery_location":false
45
+ },
46
+ "price":{
47
+ "formatted":"€6.25",
48
+ "currency":"EUR",
49
+ "amount":"6.25",
50
+ "amount_in_cents":625
51
+ },
52
+ "price_vat":{
53
+ "formatted":"€1.25",
54
+ "currency":"EUR",
55
+ "amount":"1.25",
56
+ "amount_in_cents":125
57
+ },
58
+ "total_price":{
59
+ "formatted":"€7.50",
60
+ "currency":"EUR",
61
+ "amount":"7.5",
62
+ "amount_in_cents":750
63
+ },
64
+ "collection_dates":null
65
+ }
66
+ }
@@ -0,0 +1,15 @@
1
+ HTTP/1.1 404 Not Found
2
+ Server: nginx/1.6.0
3
+ Date: Thu, 14 Aug 2014 12:35:24 GMT
4
+ Content-Type: application/json
5
+ Content-Length: 185
6
+ Connection: keep-alive
7
+
8
+ {
9
+ "status":"failure",
10
+ "error":{
11
+ "type":"resource_not_found",
12
+ "message":"Offer not found"
13
+ },
14
+ "self":"https://test.lce.io/v1/offers/ff75b691-a2e0-46b0-9909-d529b2dbb90d"
15
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "order":{
3
+ "offer_id": "ff75b691-a2e0-46b0-9909-d529b2dbb90c",
4
+ "shipper":{
5
+ "name": "Firstname Lastname",
6
+ "street": "street",
7
+ "phone": "+33699999999",
8
+ "email": "support@lce.io"
9
+
10
+ },
11
+ "recipient":{
12
+ "name": "Firstname Lastname",
13
+ "street": "street",
14
+ "phone": "+33699999999",
15
+ "email": "support@lce.io"
16
+ },
17
+ "parcels":[
18
+ {
19
+ }
20
+ ]
21
+ }
22
+ }
23
+
@@ -0,0 +1,111 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/1.6.0
3
+ Date: Tue, 19 Aug 2014 16:56:01 GMT
4
+ Content-Type: application/json
5
+ Content-Length: 3360
6
+ Connection: keep-alive
7
+ Lce-Env: staging
8
+
9
+ {
10
+ "status":"success",
11
+ "self":"https://test.lce.io/v1/orders",
12
+ "count":1,
13
+ "page":1,
14
+ "per_page":25,
15
+ "data":[
16
+ {
17
+ "id":"8c43a2e1-a7ff-49fd-807e-3877d6dadc28",
18
+ "offer_id":"ff75b691-a2e0-46b0-9909-d529b2dbb90c",
19
+ "product_id":"371ce146-1e6c-4a44-9a43-e0f124818f99",
20
+ "created_at":"2014-08-19T18:41:48+02:00",
21
+ "shipper":{
22
+ "company":null,
23
+ "name":"Firstname Lastname",
24
+ "street":"street",
25
+ "postal_code":"31300",
26
+ "country":"FR",
27
+ "phone":"+33699999999",
28
+ "email":"support@lce.io",
29
+ "city":"Toulouse",
30
+ "state":null
31
+ },
32
+ "recipient":{
33
+ "company":null,
34
+ "name":"Firstname Lastname",
35
+ "street":"street",
36
+ "postal_code":"06000",
37
+ "country":"FR",
38
+ "phone":"+33699999999",
39
+ "email":"support@lce.io",
40
+ "is_a_company":"true",
41
+ "city":"Nice",
42
+ "state":null
43
+ },
44
+ "parcels":[
45
+ {
46
+ "width":15.0,
47
+ "length":15.0,
48
+ "height":15.0,
49
+ "weight":2.0,
50
+ "description":null,
51
+ "value":null,
52
+ "currency":null
53
+ }
54
+ ],
55
+ "offer":{
56
+ "id":"ff75b691-a2e0-46b0-9909-d529b2dbb90c",
57
+ "quote_id":"cd8d1a03-bfec-4115-87ef-8f8ba91a7199",
58
+ "product_id":"371ce146-1e6c-4a44-9a43-e0f124818f99",
59
+ "product":{
60
+ "delay":"24",
61
+ "collection_informations":{
62
+ "en":"Post Office Drop Off \r\n",
63
+ "es":"Depósito en oficina de correos en Francia.",
64
+ "fr":"Dépôt en bureau de poste \r\n"
65
+ },
66
+ "delivery_informations":{
67
+ "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",
68
+ "es":"Entrega en 24h antes de 13:00 (hora local)",
69
+ "fr":"J+1 \r\nLivraison le lendemain avant 13H"
70
+ },
71
+ "details":{
72
+ "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",
73
+ "es":"Servicio Chronopost \r\nIMPORTANTE: peso máximo por paquete : 30 kg",
74
+ "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"
75
+ },
76
+ "export_from":[
77
+ "FR",
78
+ "MC"
79
+ ],
80
+ "id":"371ce146-1e6c-4a44-9a43-e0f124818f99",
81
+ "logo":"lce_yellow",
82
+ "code":"lce_yellow_express_13",
83
+ "name":"Lce Yellow Express 13",
84
+ "pick_up":false,
85
+ "drop_off":true,
86
+ "preset_delivery_location":false
87
+ },
88
+ "price":{
89
+ "formatted":"€6.25",
90
+ "currency":"EUR",
91
+ "amount":"6.25",
92
+ "amount_in_cents":625
93
+ },
94
+ "price_vat":{
95
+ "formatted":"€1.25",
96
+ "currency":"EUR",
97
+ "amount":"1.25",
98
+ "amount_in_cents":125
99
+ },
100
+ "total_price":{
101
+ "formatted":"€7.50",
102
+ "currency":"EUR",
103
+ "amount":"7.5",
104
+ "amount_in_cents":750
105
+ },
106
+ "collection_dates":null
107
+ },
108
+ "origin":null
109
+ }
110
+ ]
111
+ }
@@ -0,0 +1,106 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/1.6.0
3
+ Date: Tue, 19 Aug 2014 16:53:59 GMT
4
+ Content-Type: application/json
5
+ Content-Length: 3159
6
+ Connection: keep-alive
7
+ Lce-Env: staging
8
+
9
+ {
10
+ "status":"success",
11
+ "self":"https://test.lce.io/v1/orders/8c43a2e1-a7ff-49fd-807e-3877d6dadc28",
12
+ "data":{
13
+ "id":"8c43a2e1-a7ff-49fd-807e-3877d6dadc28",
14
+ "offer_id":"ff75b691-a2e0-46b0-9909-d529b2dbb90c",
15
+ "product_id":"371ce146-1e6c-4a44-9a43-e0f124818f99",
16
+ "created_at":"2014-08-19T18:41:48+02:00",
17
+ "shipper":{
18
+ "company":null,
19
+ "name":"Firstname Lastname",
20
+ "street":"street",
21
+ "postal_code":"31300",
22
+ "country":"FR",
23
+ "phone":"+33699999999",
24
+ "email":"support@lce.io",
25
+ "city":"Toulouse",
26
+ "state":null
27
+ },
28
+ "recipient":{
29
+ "company":null,
30
+ "name":"Firstname Lastname",
31
+ "street":"street",
32
+ "postal_code":"06000",
33
+ "country":"FR",
34
+ "phone":"+33699999999",
35
+ "email":"support@lce.io",
36
+ "is_a_company":"true",
37
+ "city":"Nice",
38
+ "state":null
39
+ },
40
+ "parcels":[
41
+ {
42
+ "width":15.0,
43
+ "length":15.0,
44
+ "height":15.0,
45
+ "weight":2.0,
46
+ "description":null,
47
+ "value":null,
48
+ "currency":null
49
+ }
50
+ ],
51
+ "offer":{
52
+ "id":"ff75b691-a2e0-46b0-9909-d529b2dbb90c",
53
+ "quote_id":"cd8d1a03-bfec-4115-87ef-8f8ba91a7199",
54
+ "product_id":"371ce146-1e6c-4a44-9a43-e0f124818f99",
55
+ "product":{
56
+ "delay":"24",
57
+ "collection_informations":{
58
+ "en":"Post Office Drop Off \r\n",
59
+ "es":"Depósito en oficina de correos en Francia.",
60
+ "fr":"Dépôt en bureau de poste \r\n"
61
+ },
62
+ "delivery_informations":{
63
+ "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",
64
+ "es":"Entrega en 24h antes de 13:00 (hora local)",
65
+ "fr":"J+1 \r\nLivraison le lendemain avant 13H"
66
+ },
67
+ "details":{
68
+ "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",
69
+ "es":"Servicio Chronopost \r\nIMPORTANTE: peso máximo por paquete : 30 kg",
70
+ "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"
71
+ },
72
+ "export_from":[
73
+ "FR",
74
+ "MC"
75
+ ],
76
+ "id":"371ce146-1e6c-4a44-9a43-e0f124818f99",
77
+ "logo":"lce_yellow",
78
+ "code":"lce_yellow_express_13",
79
+ "name":"Lce Yellow Express 13",
80
+ "pick_up":false,
81
+ "drop_off":true,
82
+ "preset_delivery_location":false
83
+ },
84
+ "price":{
85
+ "formatted":"€6.25",
86
+ "currency":"EUR",
87
+ "amount":"6.25",
88
+ "amount_in_cents":625
89
+ },
90
+ "price_vat":{
91
+ "formatted":"€1.25",
92
+ "currency":"EUR",
93
+ "amount":"1.25",
94
+ "amount_in_cents":125
95
+ },
96
+ "total_price":{
97
+ "formatted":"€7.50",
98
+ "currency":"EUR",
99
+ "amount":"7.5",
100
+ "amount_in_cents":750
101
+ },
102
+ "collection_dates":null
103
+ },
104
+ "origin":null
105
+ }
106
+ }
@@ -0,0 +1,15 @@
1
+ HTTP/1.1 404 Not Found
2
+ Server: nginx/1.6.0
3
+ Date: Tue, 19 Aug 2014 16:54:11 GMT
4
+ Content-Type: application/json
5
+ Content-Length: 185
6
+ Connection: keep-alive
7
+
8
+ {
9
+ "status":"failure",
10
+ "error":{
11
+ "type":"resource_not_found",
12
+ "message":"Order not found"
13
+ },
14
+ "self":"https://test.lce.io/v1/orders/8c43a2e1-a7ff-49fd-807e-3877d6dadc29"
15
+ }
@@ -0,0 +1,106 @@
1
+ HTTP/1.1 201 Created
2
+ Server: nginx/1.6.0
3
+ Date: Tue, 19 Aug 2014 16:41:49 GMT
4
+ Content-Type: application/json
5
+ Content-Length: 3122
6
+ Connection: keep-alive
7
+ Lce-Env: staging
8
+
9
+ {
10
+ "status":"success",
11
+ "self":"https://test.lce.io/v1/orders",
12
+ "data":{
13
+ "id":"8c43a2e1-a7ff-49fd-807e-3877d6dadc28",
14
+ "offer_id":"ff75b691-a2e0-46b0-9909-d529b2dbb90c",
15
+ "product_id":"371ce146-1e6c-4a44-9a43-e0f124818f99",
16
+ "created_at":"2014-08-19T18:41:48+02:00",
17
+ "shipper":{
18
+ "company":null,
19
+ "name":"Firstname Lastname",
20
+ "street":"street",
21
+ "postal_code":"31300",
22
+ "country":"FR",
23
+ "phone":"+33699999999",
24
+ "email":"support@lce.io",
25
+ "city":"Toulouse",
26
+ "state":null
27
+ },
28
+ "recipient":{
29
+ "company":null,
30
+ "name":"Firstname Lastname",
31
+ "street":"street",
32
+ "postal_code":"06000",
33
+ "country":"FR",
34
+ "phone":"+33699999999",
35
+ "email":"support@lce.io",
36
+ "is_a_company":"true",
37
+ "city":"Nice",
38
+ "state":null
39
+ },
40
+ "parcels":[
41
+ {
42
+ "width":15.0,
43
+ "length":15.0,
44
+ "height":15.0,
45
+ "weight":2.0,
46
+ "description":null,
47
+ "value":null,
48
+ "currency":null
49
+ }
50
+ ],
51
+ "offer":{
52
+ "id":"ff75b691-a2e0-46b0-9909-d529b2dbb90c",
53
+ "quote_id":"cd8d1a03-bfec-4115-87ef-8f8ba91a7199",
54
+ "product_id":"371ce146-1e6c-4a44-9a43-e0f124818f99",
55
+ "product":{
56
+ "delay":"24",
57
+ "collection_informations":{
58
+ "en":"Post Office Drop Off \r\n",
59
+ "es":"Depósito en oficina de correos en Francia.",
60
+ "fr":"Dépôt en bureau de poste \r\n"
61
+ },
62
+ "delivery_informations":{
63
+ "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",
64
+ "es":"Entrega en 24h antes de 13:00 (hora local)",
65
+ "fr":"J+1 \r\nLivraison le lendemain avant 13H"
66
+ },
67
+ "details":{
68
+ "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",
69
+ "es":"Servicio Chronopost \r\nIMPORTANTE: peso máximo por paquete : 30 kg",
70
+ "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"
71
+ },
72
+ "export_from":[
73
+ "FR",
74
+ "MC"
75
+ ],
76
+ "id":"371ce146-1e6c-4a44-9a43-e0f124818f99",
77
+ "logo":"lce_yellow",
78
+ "code":"lce_yellow_express_13",
79
+ "name":"Lce Yellow Express 13",
80
+ "pick_up":false,
81
+ "drop_off":true,
82
+ "preset_delivery_location":false
83
+ },
84
+ "price":{
85
+ "formatted":"€6.25",
86
+ "currency":"EUR",
87
+ "amount":"6.25",
88
+ "amount_in_cents":625
89
+ },
90
+ "price_vat":{
91
+ "formatted":"€1.25",
92
+ "currency":"EUR",
93
+ "amount":"1.25",
94
+ "amount_in_cents":125
95
+ },
96
+ "total_price":{
97
+ "formatted":"€7.50",
98
+ "currency":"EUR",
99
+ "amount":"7.5",
100
+ "amount_in_cents":750
101
+ },
102
+ "collection_dates":null
103
+ },
104
+ "origin":null
105
+ }
106
+ }