balihoo_lpc_client 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/balihoo_lpc_client/request/authentication.rb +4 -4
- data/lib/balihoo_lpc_client/request/base.rb +6 -2
- data/lib/balihoo_lpc_client/request/campaigns.rb +1 -0
- data/lib/balihoo_lpc_client/request/campaigns_with_tactics.rb +1 -0
- data/lib/balihoo_lpc_client/request/metrics.rb +1 -0
- data/lib/balihoo_lpc_client/request/tactics.rb +8 -2
- data/lib/balihoo_lpc_client/request/website_metrics.rb +1 -0
- data/lib/balihoo_lpc_client/version.rb +1 -1
- data/lib/balihoo_lpc_client.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 591af8860b95e6f9fba8075f1a24049457aa1e74
|
4
|
+
data.tar.gz: 6b933abb027d4439683b06fc7239844bcf3fc265
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f934bee38ddb572e0dc06d012a56d0313bfbc0f9b52dd0c8f32dbd9ab01bdd0852173cf80fd28451cb94a4e35bf57bb358f14f69f0ad71da25b2c1a738f986c4
|
7
|
+
data.tar.gz: 722fccbfed104e79bcf88459dde8f0d6f56bba88dd993362d007217bcc31385c94556a49eab522cfeb672b38dc791b1919547107b0cc467db3af28c0ed6aea31
|
@@ -2,9 +2,9 @@ module BalihooLpcClient
|
|
2
2
|
module Request
|
3
3
|
class Authentication < Base
|
4
4
|
def authenticate!
|
5
|
-
response = self.class.post('/genClientAPIKey', opts)
|
5
|
+
response = self.class.post('/genClientAPIKey', opts).parsed_response
|
6
6
|
handle_errors_with(klass: AuthenticationError, response: response)
|
7
|
-
handle_success(response
|
7
|
+
handle_success(response: response)
|
8
8
|
end
|
9
9
|
|
10
10
|
private
|
@@ -21,8 +21,8 @@ module BalihooLpcClient
|
|
21
21
|
}
|
22
22
|
end
|
23
23
|
|
24
|
-
def handle_success(
|
25
|
-
auth = Response::Authentication.new(
|
24
|
+
def handle_success(response:)
|
25
|
+
auth = Response::Authentication.new(response)
|
26
26
|
config.client_id = auth.client_id
|
27
27
|
config.client_api_key = auth.client_api_key
|
28
28
|
auth
|
@@ -17,8 +17,12 @@ module BalihooLpcClient
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def handle_errors_with(klass:, response:)
|
20
|
-
|
21
|
-
|
20
|
+
if response.is_a?(String)
|
21
|
+
if response =~ /session has expired/
|
22
|
+
raise ApiSessionExpiredError, response
|
23
|
+
else
|
24
|
+
raise klass, response
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
@@ -3,6 +3,7 @@ module BalihooLpcClient
|
|
3
3
|
class Campaigns < ApiBase
|
4
4
|
def fetch
|
5
5
|
response = self.class.get('/campaigns', opts).parsed_response
|
6
|
+
handle_errors_with(klass: ApiResponseError, response: response)
|
6
7
|
handle_response(response: response, klass: Response::Campaign)
|
7
8
|
end
|
8
9
|
end
|
@@ -3,6 +3,7 @@ module BalihooLpcClient
|
|
3
3
|
class CampaignsWithTactics < ApiBase
|
4
4
|
def fetch
|
5
5
|
response = self.class.get('/campaignswithtactics', opts).parsed_response
|
6
|
+
handle_errors_with(klass: ApiResponseError, response: response)
|
6
7
|
handle_response(response: response, klass: Response::Campaign)
|
7
8
|
end
|
8
9
|
end
|
@@ -10,6 +10,7 @@ module BalihooLpcClient
|
|
10
10
|
|
11
11
|
def fetch
|
12
12
|
response = self.class.get("/tactic/#{tactic_id}/metrics", opts).parsed_response
|
13
|
+
handle_errors_with(klass: ApiResponseError, response: response)
|
13
14
|
handle_response(response: response, klass: Response::Metric, mappable: false)
|
14
15
|
end
|
15
16
|
end
|
@@ -10,11 +10,17 @@ module BalihooLpcClient
|
|
10
10
|
|
11
11
|
def fetch
|
12
12
|
response = self.class.get("/campaign/#{campaign_id}/tactics", opts).parsed_response
|
13
|
+
handle_errors_with(klass: ApiResponseError, response: response)
|
14
|
+
handle_response(response: response, klass: Response::Tactic)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
13
18
|
|
19
|
+
def handle_response(response:, klass:, mappable: true)
|
14
20
|
if multiple_locations?
|
15
|
-
multiple_locations(response: response, klass:
|
21
|
+
multiple_locations(response: response, klass: klass, mappable: mappable)
|
16
22
|
else
|
17
|
-
single_location(response: response['tactics'], klass:
|
23
|
+
single_location(response: response['tactics'], klass: klass, mappable: mappable)
|
18
24
|
end
|
19
25
|
end
|
20
26
|
end
|
@@ -3,6 +3,7 @@ module BalihooLpcClient
|
|
3
3
|
class WebsiteMetrics < ApiBase
|
4
4
|
def fetch
|
5
5
|
response = self.class.get("/websitemetrics", opts).parsed_response
|
6
|
+
handle_errors_with(klass: ApiResponseError, response: response)
|
6
7
|
handle_response(response: response, klass: Response::WebsiteMetric, mappable: false)
|
7
8
|
end
|
8
9
|
end
|
data/lib/balihoo_lpc_client.rb
CHANGED
@@ -25,4 +25,6 @@ module BalihooLpcClient
|
|
25
25
|
class AuthenticationError < BalihooLpcError; end
|
26
26
|
class ApiOptionError < BalihooLpcError; end
|
27
27
|
class NotAuthenticatedError < BalihooLpcError; end
|
28
|
+
class ApiSessionExpiredError < BalihooLpcError; end
|
29
|
+
class ApiResponseError < BalihooLpcError; end
|
28
30
|
end
|