tiramizoo 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tiramizoo.rb +26 -15
- data/lib/tiramizoo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9753a887d75f034b1fdb4ef4e98b4c21e936300f
|
4
|
+
data.tar.gz: d612e145a37743a2625d9eb8fe01d4c80f82ca8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 467312aec377ba5f3c0ccbafb79fc43e554e7f8f76eccb649697a289d1ecc729a45580f73325a687a72a48160cb71118bab3b3e4d0d4c5395ff2e766b17ab7c0
|
7
|
+
data.tar.gz: e29cc9d274fef01babae1ccc220ce2bac04b2d3ac3aeb4fde56f1f306b26ce7ac3bb4aa24bfc4c88d41fa125704350481203091d493da43ef7aa31acbbba64bf
|
data/lib/tiramizoo.rb
CHANGED
@@ -20,24 +20,35 @@ module Tiramizoo
|
|
20
20
|
sender = sender.slice("address_line", "postal_code", "country_code", "name", "phone_number", "information")
|
21
21
|
recipient = recipient.slice("address_line", "postal_code", "country_code", "name", "phone_number", "information")
|
22
22
|
|
23
|
+
body = {
|
24
|
+
"pickup" => sender.merge({
|
25
|
+
"after" => time_window["pickup_after"]
|
26
|
+
}),
|
27
|
+
"delivery" => recipient.merge({
|
28
|
+
"after" => time_window["delivery_after"],
|
29
|
+
"before" => time_window["delivery_before"]
|
30
|
+
}),
|
31
|
+
"packages" => packages.map do |p|
|
32
|
+
p.slice("width", "height", "length", "description", "quantity")
|
33
|
+
end
|
34
|
+
}
|
35
|
+
|
36
|
+
if options["external_id"].present?
|
37
|
+
body["external_id"] = options["external_id"]
|
38
|
+
end
|
39
|
+
|
40
|
+
if options["web_hook_url"].present?
|
41
|
+
body["web_hook_url"] = options["web_hook_url"]
|
42
|
+
end
|
43
|
+
|
44
|
+
if options["recipient_email"].present?
|
45
|
+
body["recipient_email"] = options["recipient_email"]
|
46
|
+
end
|
47
|
+
|
23
48
|
response = connection.post({
|
24
49
|
:path => "/api/v1/orders",
|
25
50
|
:headers => {"Api-Token" => api_token, "Content-Type" => "application/json"},
|
26
|
-
:body
|
27
|
-
"pickup" => sender.merge({
|
28
|
-
"after" => time_window["pickup_after"]
|
29
|
-
}),
|
30
|
-
"delivery" => recipient.merge({
|
31
|
-
"after" => time_window["delivery_after"],
|
32
|
-
"before" => time_window["delivery_before"]
|
33
|
-
}),
|
34
|
-
"packages" => packages.map do |p|
|
35
|
-
p.slice("width", "height", "length", "description", "quantity")
|
36
|
-
end,
|
37
|
-
"external_id" => options["external_id"],
|
38
|
-
"web_hook_url" => options["web_hook_url"],
|
39
|
-
"recipient_email" => options["recipient_email"]
|
40
|
-
}.to_json
|
51
|
+
:body => body.to_json
|
41
52
|
})
|
42
53
|
|
43
54
|
case response.status
|
data/lib/tiramizoo/version.rb
CHANGED