balihoo_lpc_client 0.5.1 → 0.5.2

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: 449cbc54003a199e7fa1d809a3cdd2fec2ff464f
4
- data.tar.gz: 4e00cabd5c9c3533e818900d792dd780c30fb322
3
+ metadata.gz: a419f5a1be223fef3953c4d503c46ca1efc38f7e
4
+ data.tar.gz: 0b8cdec43c0f6c5548824557760e3d4f0b212c54
5
5
  SHA512:
6
- metadata.gz: 2421d99c26f469f280b9ac6ed1ae0aed8af52186e00edc739305b665d4bb1e09775487a6a5e3090be8409ea3c61fb0e25e6d787f1e27c970d853f886836da1e0
7
- data.tar.gz: 36cb2d5b69cbff4eaefabd2048e0876bb1b3a4b199c7b7fd9749e5360876ad492d34155c7be316d67a65028369eff7d90ea02264137923290a847028fa7d7de5
6
+ metadata.gz: 645048672a5b8baa72902b266866787ffe6db5822b478680d3563af2b924fb235426dac7f7bf3933ada5a5df7d36ad9130b6f3f1fcd1cdc1a791b518cd44d8e2
7
+ data.tar.gz: de75e508e3f92fd324d9625f16552aee8c73de5b92a3cf5dc98ccd2f78d7293957a6accc3e71d9db91d0e73bc833fe72cc662c33a06ad41cfda2e554824d34b3
data/README.md CHANGED
@@ -40,8 +40,17 @@ opts = {
40
40
  location_key: 'location_key', # optional more below
41
41
  user_id: 'brand_key', # currently not used, Balihoo suggests setting same as brand_key
42
42
  group_id: 'brand_key' # currently not used, Balihoo suggests setting same as brand_key
43
+ api_base: 'http://baseurl' # defaults to https://bac.dev.balihoo-cloud.com
44
+ api_version: 'v1.0' # defaults to v1.0
43
45
  }
44
46
  config = BalihooLpcClient::Configuration.create(opts)
47
+
48
+ # Blocks are also supported with the create method
49
+
50
+ config = BalihooLpcClient::Configuration.create(some_opts) do |c|
51
+ c.api_base = 'https://bac.dev.balihoo-cloud.com'
52
+ ...
53
+ end
45
54
  ```
46
55
 
47
56
  The `location_key` is an optional parameter. When not given the api will require
@@ -59,7 +68,9 @@ api.authenticate!
59
68
  ```
60
69
 
61
70
  The `authenticate!` method will call out to Balihoo and set the `client_id` and
62
- `client_api_key` on the config object for you.
71
+ `client_api_key` on the config object for you. **If an endpoint method is called
72
+ without calling `authenticate!` first a `BalihooLpcClient::NotAuthenticatedError`
73
+ will be raised.**
63
74
 
64
75
  ```ruby
65
76
  config.client_id # => <client_id from Balihoo>
@@ -34,15 +34,24 @@ module BalihooLpcClient
34
34
  private
35
35
 
36
36
  def validate_params_and_fetch!(**args)
37
- locations = args[:params][:locations]
37
+ validate_locations_key locations: args[:params][:locations]
38
+ authenticated?
38
39
 
40
+ fetch(**args)
41
+ end
42
+
43
+ def validate_locations_key(locations:)
39
44
  if config.location_key.nil? && locations.nil?
40
45
  raise ApiOptionError, 'must give params[:locations] since no location_key given'
41
46
  elsif config.location_key.nil? && !locations.is_a?(Array)
42
47
  raise ApiOptionError, 'locations must be an array'
43
48
  end
49
+ end
44
50
 
45
- fetch(**args)
51
+ def authenticated?
52
+ if config.client_id.nil? || config.client_api_key.nil?
53
+ raise NotAuthenticatedError, 'must call authenticate! before any endpoint'
54
+ end
46
55
  end
47
56
 
48
57
  def fetch(**args)
@@ -25,7 +25,7 @@ module BalihooLpcClient
25
25
  auth = Response::Authentication.new(data)
26
26
  config.client_id = auth.client_id
27
27
  config.client_api_key = auth.client_api_key
28
- data
28
+ auth
29
29
  end
30
30
  end
31
31
  end
@@ -1,3 +1,3 @@
1
1
  module BalihooLpcClient
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
@@ -24,4 +24,5 @@ module BalihooLpcClient
24
24
  class BalihooLpcError < StandardError; end
25
25
  class AuthenticationError < BalihooLpcError; end
26
26
  class ApiOptionError < BalihooLpcError; end
27
+ class NotAuthenticatedError < BalihooLpcError; end
27
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: balihoo_lpc_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - JD Guzman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-03-07 00:00:00.000000000 Z
12
+ date: 2016-03-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty