whiplash_api 1.2.4 → 1.2.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 +4 -4
- data/lib/whiplash_api/base.rb +19 -1
- data/lib/whiplash_api/version.rb +1 -1
- 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: d7abe6d649e8d8b5dc33256c09efed0ec254a7ed
|
4
|
+
data.tar.gz: fd6a444810878d20fe7851432922ccfbe5511739
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38781e4a1737ca2c7e51621d0fc4d8ae3bf19f82d7e41bcac06064740f609fcff2e8dc1a98ee7f91c98483fbc1743be0d2aa57c7cc7b60fe3ac887a9e9a915ba
|
7
|
+
data.tar.gz: 5c24ff3f1990e419950103089edb655e3b4fec6d6ff133a3916a6adb03e22d54dd5f0b700585c968b5206586dfa3b77700118db37a5079bd929392d5c36e868a
|
data/lib/whiplash_api/base.rb
CHANGED
@@ -7,7 +7,7 @@ module WhiplashApi
|
|
7
7
|
self.format = :json
|
8
8
|
|
9
9
|
class << self
|
10
|
-
attr_accessor :api_version, :api_key, :customer_id
|
10
|
+
attr_accessor :api_version, :api_key, :customer_id, :shop_id
|
11
11
|
|
12
12
|
def testing!
|
13
13
|
self.site = 'https://testing.whiplashmerch.com/api/'
|
@@ -38,6 +38,17 @@ module WhiplashApi
|
|
38
38
|
def api_version=(v = nil)
|
39
39
|
@api_version = v.to_i > 0 ? v.to_i : WhiplashApi::DEFAULT_API_VERSION
|
40
40
|
headers['X-API-VERSION'] = @api_version.to_s
|
41
|
+
|
42
|
+
# If we change the version, update the headers
|
43
|
+
unless api_key.blank?
|
44
|
+
if @api_version == 1
|
45
|
+
headers.delete('Authorization')
|
46
|
+
headers['X-API-KEY'] = api_key
|
47
|
+
else
|
48
|
+
headers.delete('X-API-KEY')
|
49
|
+
headers['Authorization'] = "Bearer #{api_key}"
|
50
|
+
end
|
51
|
+
end
|
41
52
|
end
|
42
53
|
|
43
54
|
def api_key=(api_key)
|
@@ -45,8 +56,10 @@ module WhiplashApi
|
|
45
56
|
raise Error, "You must set a valid API Key." if @api_key.blank?
|
46
57
|
|
47
58
|
if api_version == 1
|
59
|
+
headers.delete('Authorization')
|
48
60
|
headers['X-API-KEY'] = @api_key
|
49
61
|
else
|
62
|
+
headers.delete('X-API-KEY')
|
50
63
|
headers['Authorization'] = "Bearer #{@api_key}"
|
51
64
|
end
|
52
65
|
end
|
@@ -56,6 +69,11 @@ module WhiplashApi
|
|
56
69
|
headers['X-CUSTOMER-ID'] = customer_id.to_s
|
57
70
|
end
|
58
71
|
|
72
|
+
def shop_id=(shop_id = nil)
|
73
|
+
@shop_id = shop_id
|
74
|
+
headers['X-SHOP-ID'] = shop_id.to_s
|
75
|
+
end
|
76
|
+
|
59
77
|
def reset_headers!
|
60
78
|
%w[X-API-KEY X-API-VERSION Authorization].each do |key|
|
61
79
|
headers.delete(key)
|
data/lib/whiplash_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whiplash_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Dickson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-04-
|
12
|
+
date: 2016-04-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|