sheepla 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sheepla/version.rb +1 -1
- data/lib/sheepla.rb +28 -11
- data/test/sheepla_test.rb +52 -25
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba095070e93b0af664dfa673f64520719dab1ed3
|
4
|
+
data.tar.gz: bf86e08c0f16f0149bcfd539eb2e98b7d731fa54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4ab3f7588bb889ffaa3263f5887bcb69f662ccf26ed35fcb4db3007fa2ccd1be3ab3e03b52eeff0abda6a66dc2e9384822089c63f27588da60c0802214d3521
|
7
|
+
data.tar.gz: a318f5ca6af2b7efba9af43f67c3e63145b91c7016c7fd2ddc0b9ccddfa839dd6d63e27d272dbfc435c11a825aad04e10ee087cf5accfc17aba5c9e4d3157b81
|
data/lib/sheepla/version.rb
CHANGED
data/lib/sheepla.rb
CHANGED
@@ -112,22 +112,39 @@ module Sheepla
|
|
112
112
|
xml.phone order['delivery_address']['phone']
|
113
113
|
xml.email order['delivery_address']['email']
|
114
114
|
end
|
115
|
-
xml
|
116
|
-
|
117
|
-
xml.insurance order['delivery_options'].delete('insurance')
|
118
|
-
order['delivery_options'].each do |delivery_partner, delivery_partner_data|
|
119
|
-
xml.send(delivery_partner) do
|
120
|
-
delivery_partner_data.each do |k,v|
|
121
|
-
xml.send(k, v)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end if order['delivery_options']
|
115
|
+
add_order_items(xml, order['order_items'])
|
116
|
+
add_delivery_options(xml, order['delivery_options']) if order['delivery_options']
|
126
117
|
end
|
127
118
|
end
|
128
119
|
end
|
129
120
|
end
|
130
121
|
|
122
|
+
def add_order_items(xml, order_items)
|
123
|
+
xml.orderItems do
|
124
|
+
order_items.each do |order_item|
|
125
|
+
xml.orderItem do
|
126
|
+
order_item.each do |k, v|
|
127
|
+
xml.send(k, v)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def add_delivery_options(xml, delivery_options)
|
135
|
+
xml.deliveryOptions do
|
136
|
+
xml.cod delivery_options.delete('cod')
|
137
|
+
xml.insurance delivery_options.delete('insurance')
|
138
|
+
delivery_options.each do |delivery_partner, delivery_partner_data|
|
139
|
+
xml.send(delivery_partner) do
|
140
|
+
delivery_partner_data.each do |k,v|
|
141
|
+
xml.send(k, v)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
131
148
|
def validate_order(params)
|
132
149
|
params['order_value'] &&
|
133
150
|
params['order_currency'] &&
|
data/test/sheepla_test.rb
CHANGED
@@ -1,39 +1,66 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class SheeplaTest < ActiveSupport::TestCase
|
4
|
-
test "truth" do
|
5
|
-
assert_kind_of Module, Sheepla
|
6
|
-
end
|
7
|
-
|
8
4
|
test "data" do
|
9
5
|
sample_data = {
|
10
6
|
order_value: 299,
|
11
|
-
order_currency:
|
12
|
-
external_delivery_type_id:
|
13
|
-
external_delivery_type_name:
|
14
|
-
external_payment_type_id:
|
15
|
-
external_payment_type_name:
|
16
|
-
external_carrier_id:
|
17
|
-
external_carrier_name:
|
18
|
-
external_country_id:
|
19
|
-
external_buyer_id:
|
20
|
-
external_order_id:
|
7
|
+
order_currency: "PLN",
|
8
|
+
external_delivery_type_id: "07",
|
9
|
+
external_delivery_type_name: "DHL AH",
|
10
|
+
external_payment_type_id: "pp",
|
11
|
+
external_payment_type_name: "PayPal",
|
12
|
+
external_carrier_id: "dhl02",
|
13
|
+
external_carrier_name: "DHL Poland",
|
14
|
+
external_country_id: "PL",
|
15
|
+
external_buyer_id: "b123",
|
16
|
+
external_order_id: "ah-200-abc",
|
21
17
|
shipment_template: 122,
|
22
|
-
comments:
|
18
|
+
comments: "Some info about delivery",
|
23
19
|
created_on: DateTime.now,
|
24
20
|
delivery_price: 12,
|
25
|
-
delivery_price_currency:
|
21
|
+
delivery_price_currency: "PLN",
|
26
22
|
delivery_address: {
|
27
|
-
street:
|
28
|
-
zip_code:
|
29
|
-
city:
|
23
|
+
street: "Orba 1 Street",
|
24
|
+
zip_code: "01-234",
|
25
|
+
city: "Hel",
|
30
26
|
country_alpha2_code: 1045,
|
31
|
-
first_name:
|
32
|
-
last_name:
|
33
|
-
company_name:
|
34
|
-
phone:
|
35
|
-
email:
|
36
|
-
}
|
27
|
+
first_name: "Jean",
|
28
|
+
last_name: "Kowalski",
|
29
|
+
company_name: "LTD JK",
|
30
|
+
phone: "963852741",
|
31
|
+
email: "jean.kowalski@orba.pl"
|
32
|
+
},
|
33
|
+
order_items: [
|
34
|
+
{
|
35
|
+
name: "IPad",
|
36
|
+
sku: "sku1",
|
37
|
+
qty: "1",
|
38
|
+
unit: "szt.",
|
39
|
+
weight: "2",
|
40
|
+
width: "1",
|
41
|
+
height: "35",
|
42
|
+
length: "20",
|
43
|
+
volume: "0.001",
|
44
|
+
priceGross: "2000",
|
45
|
+
ean13: "1647984612122",
|
46
|
+
issn: "9223372036854775807"
|
47
|
+
}, {
|
48
|
+
name: "Nokia L4",
|
49
|
+
sku: "sku2",
|
50
|
+
qty: "1",
|
51
|
+
unit: "szt.",
|
52
|
+
weight: "1.6",
|
53
|
+
width: "1",
|
54
|
+
height: "15",
|
55
|
+
length: "10",
|
56
|
+
volume: "0.001",
|
57
|
+
priceGross: "1000",
|
58
|
+
orderItemDiscountType: "orderItemDiscountType2",
|
59
|
+
orderItemDiscountValue: "-79228162514264337593543950335",
|
60
|
+
ean13: "7647984612122",
|
61
|
+
issn: "9223372036854775807"
|
62
|
+
}
|
63
|
+
]
|
37
64
|
}
|
38
65
|
end
|
39
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sheepla
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Jan Adamczyk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|