carousel-ruby-api 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 +4 -4
- data/lib/carousel/tracking.rb +13 -4
- data/lib/carousel/version.rb +1 -1
- data/lib/carousel.rb +32 -0
- data/spec/lib/tracking_spec.rb +6 -2
- data/spec/spec_helper.rb +1 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6bf795bff1b870fa2cc49eae42ce1ed876df01b
|
4
|
+
data.tar.gz: b5814b60f8d5f8e60cd23559e3d5b2f1e08883d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2649f15331a1929a84f18c63e2fe2e2f02e756cc5945cda7992fba9ff9459811f112da99c33b5eda3b31fa139b8d3fff1c741474c937abaf5d06bfb3ea4ae751
|
7
|
+
data.tar.gz: 9b3fb32eb49945d6fccb24622920b442b05a0b1b0b936d7858175a3361f75f8e4ecebd9a63b98fe2de9f0694dcc402fd3f95f9d75d556825ee2510ca834892dd
|
data/lib/carousel/tracking.rb
CHANGED
@@ -3,16 +3,25 @@ module Carousel
|
|
3
3
|
|
4
4
|
attr_accessor :carrier
|
5
5
|
|
6
|
-
FEDEX = "http://www.fedexuk.net/accounts/QuickTrack.aspx?consignment=:tracking_number"
|
7
|
-
CAROUSEL = "https://web.carousel.eu/easyweb/default.asp?action=clienttrack&type=Carousel&acct1=BEC01&reference=:tracking_number"
|
8
|
-
|
9
6
|
def initialize(carrier, tracking_number)
|
10
7
|
@carrier = carrier
|
11
8
|
@tracking_number = tracking_number
|
12
9
|
end
|
13
10
|
|
14
11
|
def carrier_destination
|
15
|
-
|
12
|
+
carrier_url(carrier.upcase)
|
13
|
+
end
|
14
|
+
|
15
|
+
def carrier_url(carrier)
|
16
|
+
case carrier
|
17
|
+
when 'FEDEX'
|
18
|
+
"http://www.fedexuk.net/accounts/QuickTrack.aspx?" +
|
19
|
+
"consignment=:tracking_number"
|
20
|
+
when 'CAROUSEL'
|
21
|
+
"https://web.carousel.eu/easyweb/default.asp?" +
|
22
|
+
"action=clienttrack&type=Carousel&" +
|
23
|
+
"acct1=#{Carousel.config[:account]}&reference=:tracking_number"
|
24
|
+
end
|
16
25
|
end
|
17
26
|
|
18
27
|
def url
|
data/lib/carousel/version.rb
CHANGED
data/lib/carousel.rb
CHANGED
@@ -7,3 +7,35 @@ require "carousel/inventory"
|
|
7
7
|
require "carousel/country"
|
8
8
|
require "carousel/shipping"
|
9
9
|
require "carousel/tracking"
|
10
|
+
|
11
|
+
module Carousel
|
12
|
+
|
13
|
+
@config = {
|
14
|
+
account: ''
|
15
|
+
}
|
16
|
+
|
17
|
+
def self.configure(opts = {})
|
18
|
+
opts.each do |k, v|
|
19
|
+
if @config.keys.include? k.to_sym
|
20
|
+
@config[k.to_sym] = v
|
21
|
+
else
|
22
|
+
# unsupported configuration
|
23
|
+
p 'unsupported configuration option for Carousel fulfillment'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
validate_configuration
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.validate_configuration
|
30
|
+
@config.each do |k, v|
|
31
|
+
if k == :account && v.empty?
|
32
|
+
raise 'Carousel account needs to be set'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.config
|
38
|
+
@config
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/spec/lib/tracking_spec.rb
CHANGED
@@ -3,6 +3,10 @@ require 'spec_helper'
|
|
3
3
|
describe Carousel::Tracking do
|
4
4
|
|
5
5
|
let(:tracking) { Carousel::Tracking.new('carousel', '123456')}
|
6
|
+
|
7
|
+
before do
|
8
|
+
Carousel.configure(configuration)
|
9
|
+
end
|
6
10
|
|
7
11
|
describe '#initialize' do
|
8
12
|
it 'sets the carrier and tracking number' do
|
@@ -20,7 +24,7 @@ describe Carousel::Tracking do
|
|
20
24
|
end
|
21
25
|
context 'when carrier is Carousel' do
|
22
26
|
it 'returns the Carousel tracking url' do
|
23
|
-
expect(tracking.url).to eq("https://web.carousel.eu/easyweb/default.asp?action=clienttrack&type=Carousel&acct1=
|
27
|
+
expect(tracking.url).to eq("https://web.carousel.eu/easyweb/default.asp?action=clienttrack&type=Carousel&acct1=ABC00&reference=123456")
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
@@ -33,7 +37,7 @@ describe Carousel::Tracking do
|
|
33
37
|
end
|
34
38
|
context 'when carrier is Carousel' do
|
35
39
|
it 'returns the Carousel tracking url including the tracking number' do
|
36
|
-
expect(tracking.url).to eq("https://web.carousel.eu/easyweb/default.asp?action=clienttrack&type=Carousel&acct1=
|
40
|
+
expect(tracking.url).to eq("https://web.carousel.eu/easyweb/default.asp?action=clienttrack&type=Carousel&acct1=ABC00&reference=123456")
|
37
41
|
end
|
38
42
|
end
|
39
43
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carousel-ruby-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Grubbs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -187,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
187
|
version: '0'
|
188
188
|
requirements: []
|
189
189
|
rubyforge_project:
|
190
|
-
rubygems_version: 2.
|
190
|
+
rubygems_version: 2.0.6
|
191
191
|
signing_key:
|
192
192
|
specification_version: 4
|
193
193
|
summary: This is a library for interfacing with the Carousel Fulfillment API
|