talon_one 0.0.9 → 0.0.10

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: 9686c435c7623cefc2b775f13ece7ddf2122701c
4
- data.tar.gz: 3bd87ca7fbbb042ea917ccea433125e629c91cf4
3
+ metadata.gz: f18f0015fc47df3940ed680ecea31d131be528b8
4
+ data.tar.gz: 40b19f136345f6b6b9e46ffe3935025c95312a5b
5
5
  SHA512:
6
- metadata.gz: ca9cd7e9bd12fb13e90ea07835c044c33eaedeeec6c8fc3654ea15b6745c97b19687b015d1ca969b8aea1fd06bc3b24fc64abad1158a9c9d84104ca37c8b19e5
7
- data.tar.gz: 248ef713cecac93bee40a77dec6680c1e8ae141a3e732837c7318b6190d6701d7f1ac6940da47950b8cfe26880635df1c41c1ce64112d2daa4cfafe36a214615
6
+ metadata.gz: fb9274252cd2350a2556835aea585903bf6fb90bca74bbdb11f3d69ecb084c22e3609238860c4bcf385c71cefe817d7cb1f5a718df3ad97c8f38dfa340a2196c
7
+ data.tar.gz: 545b4c5400fb59d2c112d8b4cf4633170dea301b15f0e47eb1c08089105d29a6d0f8a47d9fa1b3c4880516352bc3ffdca1652cdf2e714a37fba175ef42a7eba5
@@ -1,3 +1,7 @@
1
+ # 0.0.10 / 2017-06-13
2
+
3
+ * [FEATURE] Throw custom errors in stead of general RunTime errors whenever the API returns a 400
4
+
1
5
  # 0.0.9 / 2017-06-08
2
6
 
3
7
  * [FEATURE] Add support for creating and deleting attributes
@@ -4,6 +4,7 @@ require 'oj'
4
4
  require_relative './search_profiles_result'
5
5
  require_relative './rule_engine_result'
6
6
  require_relative './referral_code'
7
+ require_relative './client_error'
7
8
 
8
9
  module TalonOne
9
10
  module Integration
@@ -34,7 +35,7 @@ module TalonOne
34
35
  if res.code[0] == '2'
35
36
  result.new(Oj.load(res.body, oj_options(:strict)))
36
37
  else
37
- raise "#{method.upcase} #{path} -> #{res.code} #{res.body}"
38
+ raise TalonOne::Integration::ClientError.new("#{method.upcase} #{path} -> #{res.code} #{res.body}")
38
39
  end
39
40
  end
40
41
 
@@ -0,0 +1,9 @@
1
+ module TalonOne
2
+ module Integration
3
+ class ClientError < StandardError
4
+ def initialize(msg)
5
+ super
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'talon_one'
3
- s.version = '0.0.9'
4
- s.date = '2017-06-08'
3
+ s.version = '0.0.10'
4
+ s.date = '2017-06-13'
5
5
  s.summary = 'Client for the Talon.One API'
6
6
  s.description = 'A simple client for using the Talon.One API'
7
7
  s.authors = ['Talon.One GmbH']
@@ -17,7 +17,8 @@ class TestIntegrationApiLive < LiveApiTest
17
17
 
18
18
  management_client.update_campaign_status @app["id"], @campaign["id"], "enabled"
19
19
 
20
- @attribute ||= management_client.create_attribute({ entity: "Event", eventType: "Viewed Page", name: "URL", title: "Page URL", type: "string", description: "The URL of the page that the user has viewed", tags: [], editable: true })
20
+ @event_type ||= "Viewed Page#{rand(36**3).to_s(36)}"
21
+ @attribute ||= management_client.create_attribute({ entity: "Event", eventType: @event_type, name: "URL", title: "Page URL", type: "string", description: "The URL of the page that the user has viewed", tags: [], editable: true })
21
22
  end
22
23
 
23
24
  def teardown
@@ -30,7 +31,7 @@ class TestIntegrationApiLive < LiveApiTest
30
31
  end
31
32
 
32
33
  def test_track_event
33
- res = integration_client.track_event "a-session", "Viewed Page", { URL: "http://example.com" }
34
+ res = integration_client.track_event "a-session", @event_type, { URL: "http://example.com" }
34
35
  assert res.profile
35
36
  assert res.session
36
37
  assert_instance_of TalonOne::Integration::Event, res.event
@@ -38,7 +39,7 @@ class TestIntegrationApiLive < LiveApiTest
38
39
  assert !res.event.accepted_coupon?, "No coupon -> no acceptCoupon effect"
39
40
  assert_equal 1, res.event.effects.length
40
41
  assert_equal "setDiscount", res.event.effects[0].function
41
- assert_equal "Viewed Page", res.event.type
42
+ assert_equal @event_type, res.event.type
42
43
  assert_equal "a-session", res.event.session_id, "a-session"
43
44
  assert_equal({ "URL" => "http://example.com" }, res.event.attributes)
44
45
  assert_instance_of BigDecimal, res.session["discounts"]["Free money"]
@@ -51,4 +52,13 @@ class TestIntegrationApiLive < LiveApiTest
51
52
  }
52
53
  assert res.event.rejected_coupon?, "invalid coupon code was rejected"
53
54
  end
55
+
56
+ def test_raise_error
57
+ err = assert_raises TalonOne::Integration::ClientError do
58
+ integration_client.track_event "a-session", @event_type, { BADURL: "http://example.com" }
59
+ end
60
+
61
+ assert_includes err.message, '400'
62
+ end
63
+
54
64
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: talon_one
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Talon.One GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-08 00:00:00.000000000 Z
11
+ date: 2017-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -67,6 +67,7 @@ files:
67
67
  - README.md
68
68
  - Rakefile
69
69
  - lib/integration/client.rb
70
+ - lib/integration/client_error.rb
70
71
  - lib/integration/customer_profile.rb
71
72
  - lib/integration/effect.rb
72
73
  - lib/integration/event.rb