talon_one 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/integration/event.rb +5 -0
- data/lib/integration/meta_data.rb +18 -0
- data/lib/management/client.rb +4 -0
- data/talon_one.gemspec +3 -3
- data/test/test_integration_api_live.rb +17 -9
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be0aa81409b89e297ccc13d905de2740f63107bd
|
4
|
+
data.tar.gz: ec7e40ff88c7a4eebf2fc055069bc00c4acd6212
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 461023a4eecc0b42bfbebc2c9b6eb0c3bbeee1507c0e9665972b3b73612dd931b5225b1fee538e84d67cd63c3de5e23c5cc17dd765cccff24ccb4aa36e6abac3
|
7
|
+
data.tar.gz: 8bc770ef1d1c05a38120e7b5d178100824c8ecfb811c3280b39ae2a11faefe29e790ebe748bf969b0d693b51458be5bcc92ea0711b37b10ff2b430f073dfe6c5
|
data/CHANGELOG.md
CHANGED
data/lib/integration/event.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative './effect'
|
2
|
+
require_relative "./meta_data"
|
2
3
|
|
3
4
|
module TalonOne
|
4
5
|
module Integration
|
@@ -25,6 +26,10 @@ module TalonOne
|
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
29
|
+
def meta
|
30
|
+
@meta ||= TalonOne::Integration::MetaData.new @raw["meta"]
|
31
|
+
end
|
32
|
+
|
28
33
|
def accepted_coupon?
|
29
34
|
effects.any? {|e| e.function == "acceptCoupon"}
|
30
35
|
end
|
data/lib/management/client.rb
CHANGED
@@ -106,6 +106,10 @@ module TalonOne
|
|
106
106
|
def delete_attribute(attribute_id)
|
107
107
|
delete "/v1/attributes/#{attribute_id}"
|
108
108
|
end
|
109
|
+
|
110
|
+
def create_coupon(application_id, campaign_id, params)
|
111
|
+
post "/v1/applications/#{application_id}/campaigns/#{campaign_id}/coupons", params
|
112
|
+
end
|
109
113
|
|
110
114
|
end
|
111
115
|
end
|
data/talon_one.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'talon_one'
|
3
|
-
s.version = '0.1.
|
4
|
-
s.date = '2018-
|
3
|
+
s.version = '0.1.2'
|
4
|
+
s.date = '2018-04-27'
|
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']
|
8
|
-
s.email = ['
|
8
|
+
s.email = ['support@talon.one']
|
9
9
|
s.required_ruby_version = '>= 2.2.0'
|
10
10
|
s.files = `git ls-files`.split("\n")
|
11
11
|
s.require_paths = ['lib']
|
@@ -9,7 +9,7 @@ class TestIntegrationApiLive < LiveApiTest
|
|
9
9
|
@campaign = management_client.create_campaign @app["id"], { name: "Test Campaign", state: 'disabled', tags: [], limits: [], features: [] }
|
10
10
|
@ruleset = management_client.update_ruleset_for_campaign @app["id"], @campaign["id"], rules: [{
|
11
11
|
title: "Free money for all!",
|
12
|
-
condition: ["and",
|
12
|
+
condition: ["and", ["couponValid"]],
|
13
13
|
effects: [
|
14
14
|
["setDiscount", "Free money", 45.55]
|
15
15
|
]
|
@@ -19,11 +19,17 @@ class TestIntegrationApiLive < LiveApiTest
|
|
19
19
|
|
20
20
|
@event_type ||= "Viewed Page#{rand(36**3).to_s(36)}"
|
21
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 })
|
22
|
+
|
23
|
+
@coupon_code = "mycode"
|
24
|
+
@attribute_name = "Description#{rand(36**3).to_s(36)}"
|
25
|
+
@coupon_attribute ||= management_client.create_attribute({ entity: "Coupon", name: @attribute_name, title: "#{rand(36**3).to_s(36)}", type: "string", description: "Description for this coupon", tags: [], editable: true })
|
26
|
+
@coupon ||= management_client.create_coupon(@app["id"], @campaign["id"], { validCharacters: [], couponPattern: @coupon_code, usageLimit: 0, numberOfCoupons: 1, attributes: { @attribute_name.to_sym => "some text" } })
|
22
27
|
end
|
23
28
|
|
24
29
|
def teardown
|
25
30
|
management_client.delete_application @app["id"]
|
26
31
|
management_client.delete_attribute @attribute["id"]
|
32
|
+
management_client.delete_attribute @coupon_attribute["id"]
|
27
33
|
end
|
28
34
|
|
29
35
|
def integration_config
|
@@ -37,21 +43,23 @@ class TestIntegrationApiLive < LiveApiTest
|
|
37
43
|
assert_instance_of TalonOne::Integration::Event, res.event
|
38
44
|
assert !res.event.rejected_coupon?, "No coupon -> no rejectCoupon effect"
|
39
45
|
assert !res.event.accepted_coupon?, "No coupon -> no acceptCoupon effect"
|
40
|
-
assert_equal 1, res.event.effects.length
|
41
|
-
assert_equal @campaign["id"], res.event.effects[0].campaign_id
|
42
|
-
assert_equal "setDiscount", res.event.effects[0].function
|
43
|
-
assert_equal @event_type, res.event.type
|
44
46
|
assert_equal "a-session", res.event.session_id, "a-session"
|
45
47
|
assert_equal({ "URL" => "http://example.com" }, res.event.attributes)
|
46
|
-
assert_instance_of BigDecimal, res.session["discounts"]["Free money"]
|
47
48
|
end
|
48
49
|
|
49
50
|
def test_update_customer_session
|
50
|
-
res = integration_client.update_customer_session "new-session", {
|
51
|
-
coupon:
|
51
|
+
res = integration_client.update_customer_session "new-session#{rand(36**3).to_s(36)}", {
|
52
|
+
coupon: @coupon_code,
|
52
53
|
total: BigDecimal.new("45.55"),
|
53
54
|
}
|
54
|
-
assert res.event.
|
55
|
+
assert res.event.accepted_coupon?, "coupon code was accepted"
|
56
|
+
assert_equal 2, res.event.effects.length
|
57
|
+
assert_equal @campaign["id"], res.event.effects[0].campaign_id
|
58
|
+
assert_equal "acceptCoupon", res.event.effects[0].function
|
59
|
+
assert_equal "setDiscount", res.event.effects[1].function
|
60
|
+
assert_equal "talon_session_created", res.event.type
|
61
|
+
assert_instance_of BigDecimal, res.session["discounts"]["Free money"]
|
62
|
+
assert_equal "some text", res.event.meta.coupon_data[@coupon_code][@attribute_name]
|
55
63
|
end
|
56
64
|
|
57
65
|
def test_oj_calls_as_json
|
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.1.
|
4
|
+
version: 0.1.2
|
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: 2018-
|
11
|
+
date: 2018-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -54,8 +54,7 @@ dependencies:
|
|
54
54
|
version: 5.10.1
|
55
55
|
description: A simple client for using the Talon.One API
|
56
56
|
email:
|
57
|
-
-
|
58
|
-
- vanwiele@talon.one
|
57
|
+
- support@talon.one
|
59
58
|
executables: []
|
60
59
|
extensions: []
|
61
60
|
extra_rdoc_files: []
|
@@ -71,6 +70,7 @@ files:
|
|
71
70
|
- lib/integration/customer_profile.rb
|
72
71
|
- lib/integration/effect.rb
|
73
72
|
- lib/integration/event.rb
|
73
|
+
- lib/integration/meta_data.rb
|
74
74
|
- lib/integration/referral_code.rb
|
75
75
|
- lib/integration/rule_engine_result.rb
|
76
76
|
- lib/integration/search_profiles_result.rb
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.6.14
|
103
|
+
rubygems_version: 2.6.14.1
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: Client for the Talon.One API
|