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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 456b57c8045ed2d489b7f7ae8a186a2f9cd3f53f
4
- data.tar.gz: 57bec0af7af2be26f333cccadb5b00e2d3700cef
3
+ metadata.gz: d7abe6d649e8d8b5dc33256c09efed0ec254a7ed
4
+ data.tar.gz: fd6a444810878d20fe7851432922ccfbe5511739
5
5
  SHA512:
6
- metadata.gz: 97fdce4e8294152c8808e445feaff35de6ec224cf02ebf2c26884d25f0978ae31c671a37f5ebb8266c8b50aa89d644c4202549bd1e6de0c560250dd0ed06af46
7
- data.tar.gz: 00df7bd4e1027f042e9b3969635f2898968e8d8a72b422cb88b021e7cd930b8c28231ed2f268a28d65056a3c69e501b6008abc3431f7285add19155141517554
6
+ metadata.gz: 38781e4a1737ca2c7e51621d0fc4d8ae3bf19f82d7e41bcac06064740f609fcff2e8dc1a98ee7f91c98483fbc1743be0d2aa57c7cc7b60fe3ac887a9e9a915ba
7
+ data.tar.gz: 5c24ff3f1990e419950103089edb655e3b4fec6d6ff133a3916a6adb03e22d54dd5f0b700585c968b5206586dfa3b77700118db37a5079bd929392d5c36e868a
@@ -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)
@@ -1,4 +1,4 @@
1
1
  module WhiplashApi
2
- VERSION = "1.2.4"
2
+ VERSION = "1.2.5"
3
3
  DEFAULT_API_VERSION = 1
4
4
  end
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
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-25 00:00:00.000000000 Z
12
+ date: 2016-04-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler