carousel-ruby-api 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82f63c108e9401de9dff15f30fa6715a097977ab
4
- data.tar.gz: d9b3575b088f1949e820000a18bd0a41ca55d1fd
3
+ metadata.gz: a6bf795bff1b870fa2cc49eae42ce1ed876df01b
4
+ data.tar.gz: b5814b60f8d5f8e60cd23559e3d5b2f1e08883d9
5
5
  SHA512:
6
- metadata.gz: 42c8b5fba1a07d41ba8222e697b6fadbbf49de96d4e60b4f47658f423fb9d2349a2ca36691a6dc2a58cd2de418b7cb3236edb0fab4f641acbe81baeb280e22ce
7
- data.tar.gz: bf20ea083338d8c63bdcfadf3b51bed80e5c0b786665155170074b713fc4f3757e95999970151b9cf146ba72136af6b6a47451eb689e6107e4f132594db7950c
6
+ metadata.gz: 2649f15331a1929a84f18c63e2fe2e2f02e756cc5945cda7992fba9ff9459811f112da99c33b5eda3b31fa139b8d3fff1c741474c937abaf5d06bfb3ea4ae751
7
+ data.tar.gz: 9b3fb32eb49945d6fccb24622920b442b05a0b1b0b936d7858175a3361f75f8e4ecebd9a63b98fe2de9f0694dcc402fd3f95f9d75d556825ee2510ca834892dd
@@ -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
- self.class.const_get(carrier.upcase)
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
@@ -1,3 +1,3 @@
1
1
  module Carousel
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
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
@@ -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=BEC01&reference=123456")
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=BEC01&reference=123456")
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
@@ -73,11 +73,7 @@ end
73
73
 
74
74
  def configuration
75
75
  {
76
- supplier_code: 'Supplier1',
77
- supplier_description: 'My Supplier',
78
- supplier_uom: 1,
79
- warehouses: {},
80
- token: 'token123'
76
+ account: 'ABC00'
81
77
  }
82
78
  end
83
79
 
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
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-17 00:00:00.000000000 Z
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.2.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