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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1e746c925b01513d8ec47e8466fba481351cc91
4
- data.tar.gz: 97dced818be59076f1fc430ab2787ee16ef301cb
3
+ metadata.gz: ba095070e93b0af664dfa673f64520719dab1ed3
4
+ data.tar.gz: bf86e08c0f16f0149bcfd539eb2e98b7d731fa54
5
5
  SHA512:
6
- metadata.gz: 23e8fc863a28cf5a1835f7df04321c3738effb93adc47bd26ac47a0f06e74cfe64f0ecde9d23d8daf1b50f4e675f4ac6ab9126fc7c0d51d402f01fc0b8696ab0
7
- data.tar.gz: 9b5d95ae3cb21cf51c306f66de78986b788618c7398db214e0f3e710f1601b9a50524cf962af5d21abd1c5a511b726759a719020a9a5a8d18aa34a0695e23ff8
6
+ metadata.gz: b4ab3f7588bb889ffaa3263f5887bcb69f662ccf26ed35fcb4db3007fa2ccd1be3ab3e03b52eeff0abda6a66dc2e9384822089c63f27588da60c0802214d3521
7
+ data.tar.gz: a318f5ca6af2b7efba9af43f67c3e63145b91c7016c7fd2ddc0b9ccddfa839dd6d63e27d272dbfc435c11a825aad04e10ee087cf5accfc17aba5c9e4d3157b81
@@ -1,3 +1,3 @@
1
1
  module Sheepla
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.deliveryOptions do
116
- xml.cod order['delivery_options'].delete('cod')
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: 'PLN',
12
- external_delivery_type_id: '07',
13
- external_delivery_type_name: 'DHL AH',
14
- external_payment_type_id: 'pp',
15
- external_payment_type_name: 'PayPal',
16
- external_carrier_id: 'dhl02',
17
- external_carrier_name: 'DHL Poland',
18
- external_country_id: 'PL',
19
- external_buyer_id: 'b123',
20
- external_order_id: 'ah-200-abc',
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: 'Some info about delivery',
18
+ comments: "Some info about delivery",
23
19
  created_on: DateTime.now,
24
20
  delivery_price: 12,
25
- delivery_price_currency: 'PLN',
21
+ delivery_price_currency: "PLN",
26
22
  delivery_address: {
27
- street: 'Orba 1 Street',
28
- zip_code: '01-234',
29
- city: 'Hel',
23
+ street: "Orba 1 Street",
24
+ zip_code: "01-234",
25
+ city: "Hel",
30
26
  country_alpha2_code: 1045,
31
- first_name: 'Jean',
32
- last_name: 'Kowalski',
33
- company_name: 'LTD JK',
34
- phone: '963852741',
35
- email: 'jean.kowalski@orba.pl'
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.1
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-07 00:00:00.000000000 Z
11
+ date: 2014-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri