omniorder 0.0.4 → 0.0.5

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: 08acaaeabef190021f9adb0423a59faec3783c73
4
- data.tar.gz: 8e77e461b790a6bb3ecbe8e133551eb5e3075c07
3
+ metadata.gz: 837ddd9e90efb1c7157a6a34f3b80bb5236663c0
4
+ data.tar.gz: 5148357797c7481c41fd34fabd50d7a1e058d279
5
5
  SHA512:
6
- metadata.gz: a2ee79b57210e4fedc5966a7ffd2b7d5cb3cde9db21bd37c456dadcdbca22c83ef93d7ed7650b9fb1cc9d4810f1f5831e4660c0110e2e805544ce3fa03c7367d
7
- data.tar.gz: b8d070076a5600e7f03a9ea79737644c9e7808e7e0c3d79c53e617502b86aad411e232a1087e015f4997549bed21ef76c34957ba0574c8dd30da18c143a59dcc
6
+ metadata.gz: 3ec7245e462717e5e089527d3903f2b26eae78c2325554c633ec5b0d6d4a4197bfe642588cfcd9187a74f2a3da4cfece44541bc613478b3c0d87c0b5d4d66e23
7
+ data.tar.gz: bf179cb35db7ca0683bb8068b3a1d84ce80d03784041d65934680b06a0f5db11a168140300d54f8b20a265b7059a9d2b164321937c1c81c5a1a31cda1e7457bc
@@ -42,8 +42,8 @@ module Omniorder
42
42
  raise "Cannot send tracking info for Groupon order ##{order.order_number} since it has no external_carrier_reference"
43
43
  end
44
44
 
45
- if order.order_products.any? { |op| op.external_reference.to_i == 0 }
46
- raise "Cannot send tracking info for Groupon order ##{order.order_number} since a line item has no external_reference"
45
+ if order.external_data.nil? || order.external_data[:line_item_ids].nil? || order.external_data[:line_item_ids].empty?
46
+ raise "Cannot send tracking info for Groupon order ##{order.order_number} since there is no line item external data"
47
47
  end
48
48
 
49
49
  true
@@ -75,10 +75,10 @@ module Omniorder
75
75
 
76
76
  def tracking_notification_url(orders)
77
77
  tracking_info = orders.map do |order|
78
- order.order_products.map do |line_item|
78
+ order.external_data[:line_item_ids].map do |line_item_id|
79
79
  {
80
80
  "carrier" => order.external_carrier_reference,
81
- "ci_lineitem_id" => line_item.external_reference.to_i,
81
+ "ci_lineitem_id" => line_item_id,
82
82
  "tracking" => order.shipping_reference
83
83
  }
84
84
  end
@@ -93,7 +93,8 @@ module Omniorder
93
93
  order = import.generate_order(
94
94
  :order_number => order_info['orderid'],
95
95
  :total_price => order_info['amount']['total'].to_f,
96
- :date => DateTime.strptime(order_info['date'], '%m/%d/%Y %I:%M%p UTC')
96
+ :date => DateTime.strptime(order_info['date'], '%m/%d/%Y %I:%M%p UTC'),
97
+ :external_data => { :line_item_ids => order_info['line_items'].map { |li| li['ci_lineitemid'] } }
97
98
  )
98
99
 
99
100
  order.customer = create_customer(order, order_info['customer'])
@@ -3,7 +3,7 @@ module Omniorder
3
3
  include Orderable
4
4
 
5
5
  attributes :customer, :order_products, :order_number, :total_price, :date, :shipping_reference,
6
- :external_carrier_reference
6
+ :external_carrier_reference, :external_data
7
7
 
8
8
  def initialize(attributes = {})
9
9
  super
@@ -1,3 +1,3 @@
1
1
  module Omniorder
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -108,12 +108,12 @@ describe Omniorder::ImportStrategy::Groupon do
108
108
  Omniorder::Order.new(
109
109
  :shipping_reference => 'SR123451',
110
110
  :external_carrier_reference => '4SL',
111
- :order_products => [Omniorder::OrderProduct.new(:external_reference => '54553918')]
111
+ :external_data => { :line_item_ids => [54553918] }
112
112
  ),
113
113
  Omniorder::Order.new(
114
114
  :shipping_reference => 'SR123452',
115
115
  :external_carrier_reference => 'DHL',
116
- :order_products => [Omniorder::OrderProduct.new(:external_reference => '54553920')]
116
+ :external_data => { :line_item_ids => [54553920] }
117
117
  )
118
118
  ]
119
119
 
@@ -137,12 +137,12 @@ describe Omniorder::ImportStrategy::Groupon do
137
137
  Omniorder::Order.new(
138
138
  :order_number => 'ORD1',
139
139
  :shipping_reference => 'SR123451',
140
- :order_products => [Omniorder::OrderProduct.new(:external_reference => '54553918')]
140
+ :external_data => { :line_item_ids => [54553918] }
141
141
  ),
142
142
  Omniorder::Order.new(
143
143
  :shipping_reference => 'SR123452',
144
144
  :external_carrier_reference => 'DHL',
145
- :order_products => [Omniorder::OrderProduct.new(:external_reference => '54553920')]
145
+ :external_data => { :line_item_ids => [54553920] }
146
146
  )
147
147
  ]
148
148
 
@@ -150,23 +150,22 @@ describe Omniorder::ImportStrategy::Groupon do
150
150
  to raise_exception "Cannot send tracking info for Groupon order #ORD1 since it has no external_carrier_reference"
151
151
  end
152
152
 
153
- it 'raises an exception when and order line item has no external_reference' do
153
+ it 'raises an exception when an order does not have appropriate external data' do
154
154
  orders = [
155
155
  Omniorder::Order.new(
156
156
  :order_number => 'ORD1',
157
157
  :shipping_reference => 'SR123451',
158
- :external_carrier_reference => '4SL',
159
- :order_products => [Omniorder::OrderProduct.new]
158
+ :external_carrier_reference => '4SL'
160
159
  ),
161
160
  Omniorder::Order.new(
162
161
  :shipping_reference => 'SR123452',
163
162
  :external_carrier_reference => 'DHL',
164
- :order_products => [Omniorder::OrderProduct.new(:external_reference => '54553920')]
163
+ :external_data => { :line_item_ids => [54553920] }
165
164
  )
166
165
  ]
167
166
 
168
167
  expect { strategy.update_order_tracking!(orders) }.
169
- to raise_exception "Cannot send tracking info for Groupon order #ORD1 since a line item has no external_reference"
168
+ to raise_exception "Cannot send tracking info for Groupon order #ORD1 since there is no line item external data"
170
169
  end
171
170
  end
172
171
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniorder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Howard Wilson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-15 00:00:00.000000000 Z
11
+ date: 2015-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: crack