moesif_api 1.1.1 → 1.2.0
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 +4 -4
- data/README.md +5 -0
- data/lib/moesif_api/models/event_model.rb +11 -2
- data/test/controllers/controller_test_base.rb +1 -1
- data/test/controllers/test_api_controller.rb +23 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a373c298dcd99fe2ea5981ba95e7cfe3b9351f9a
|
4
|
+
data.tar.gz: d16ad43312e03ed04ad747f4c70d205d7acb28ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3d451edb645773b86081d806a7d361b7f213847221ed535ea304d82556a7ce8352a2d25cf2ae11e0632fba54e37a4b989faf810614f5f2259d270d2093b8c9a
|
7
|
+
data.tar.gz: 8232cf209a482705e64a166d54a89d0d6fe4aea23ba9a8ed5da386ea5cd1886202a71b2660800a2c911fe81200483ae0e229bb4a2125066706ad0384f4ca2fdb
|
data/README.md
CHANGED
@@ -72,6 +72,10 @@ rsp_body = JSON.parse('{'\
|
|
72
72
|
'"Message": "Missing field field_a"'\
|
73
73
|
'}')
|
74
74
|
|
75
|
+
metadata = JSON.parse('{'\
|
76
|
+
'"foo": "rubytestmeta",'\
|
77
|
+
'"bar": "rubytestmedat2"'\
|
78
|
+
'}')
|
75
79
|
|
76
80
|
event_req = EventRequestModel.new()
|
77
81
|
event_req.time = "2016-09-09T04:45:42.914"
|
@@ -93,6 +97,7 @@ event_model.request = event_req
|
|
93
97
|
event_model.response = event_rsp
|
94
98
|
event_model.user_id ="my_user_id"
|
95
99
|
event_model.session_token = "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f"
|
100
|
+
event_model.metadata = metadata
|
96
101
|
|
97
102
|
# Perform the API call through the SDK function
|
98
103
|
response = api_controller.create_event(event_model)
|
@@ -22,6 +22,10 @@ module MoesifApi
|
|
22
22
|
# @return [String]
|
23
23
|
attr_accessor :user_id
|
24
24
|
|
25
|
+
# metadata
|
26
|
+
# @return [Object]
|
27
|
+
attr_accessor :metadata
|
28
|
+
|
25
29
|
# A mapping from model property names to API property names
|
26
30
|
def self.names
|
27
31
|
if @hash.nil?
|
@@ -31,6 +35,7 @@ module MoesifApi
|
|
31
35
|
@hash["session_token"] = "session_token"
|
32
36
|
@hash["tags"] = "tags"
|
33
37
|
@hash["user_id"] = "user_id"
|
38
|
+
@hash["metadata"] = "metadata"
|
34
39
|
end
|
35
40
|
@hash
|
36
41
|
end
|
@@ -39,12 +44,14 @@ module MoesifApi
|
|
39
44
|
response = nil,
|
40
45
|
session_token = nil,
|
41
46
|
tags = nil,
|
42
|
-
user_id = nil
|
47
|
+
user_id = nil,
|
48
|
+
metadata = nil)
|
43
49
|
@request = request
|
44
50
|
@response = response
|
45
51
|
@session_token = session_token
|
46
52
|
@tags = tags
|
47
53
|
@user_id = user_id
|
54
|
+
@metadata = metadata
|
48
55
|
end
|
49
56
|
|
50
57
|
# Creates an instance of the object from a hash
|
@@ -58,13 +65,15 @@ module MoesifApi
|
|
58
65
|
session_token = hash["session_token"]
|
59
66
|
tags = hash["tags"]
|
60
67
|
user_id = hash["user_id"]
|
68
|
+
metadata = hash["metadata"]
|
61
69
|
|
62
70
|
# Create object from extracted values
|
63
71
|
EventModel.new(request,
|
64
72
|
response,
|
65
73
|
session_token,
|
66
74
|
tags,
|
67
|
-
user_id
|
75
|
+
user_id,
|
76
|
+
metadata)
|
68
77
|
end
|
69
78
|
end
|
70
79
|
end
|
@@ -15,7 +15,7 @@ class ControllerTestBase < Test::Unit::TestCase
|
|
15
15
|
|
16
16
|
# Called only once for a test class before any test has executed.
|
17
17
|
def self.startup
|
18
|
-
@@api_client = MoesifAPIClient.new("
|
18
|
+
@@api_client = MoesifAPIClient.new("your application id")
|
19
19
|
@@request_timeout = 30
|
20
20
|
@@assert_precision = 0.01
|
21
21
|
end
|
@@ -50,6 +50,10 @@ class ApiControllerTests < ControllerTestBase
|
|
50
50
|
'"Message": "Missing field field_a"'\
|
51
51
|
'}')
|
52
52
|
|
53
|
+
metadata = JSON.parse('{'\
|
54
|
+
'"foo": "rubytestmeta",'\
|
55
|
+
'"bar": "rubytestmedat2"'\
|
56
|
+
'}')
|
53
57
|
|
54
58
|
event_req = EventRequestModel.new()
|
55
59
|
event_req.time = Time.now.utc.iso8601
|
@@ -61,7 +65,7 @@ class ApiControllerTests < ControllerTestBase
|
|
61
65
|
event_req.body = req_body
|
62
66
|
|
63
67
|
event_rsp = EventResponseModel.new()
|
64
|
-
event_rsp.time = Time.now.utc.iso8601
|
68
|
+
event_rsp.time = (Time.now.utc + 2).iso8601
|
65
69
|
event_rsp.status = 500
|
66
70
|
event_rsp.headers = rsp_headers
|
67
71
|
event_rsp.body = rsp_body
|
@@ -69,7 +73,8 @@ class ApiControllerTests < ControllerTestBase
|
|
69
73
|
event_model = EventModel.new()
|
70
74
|
event_model.request = event_req
|
71
75
|
event_model.response = event_rsp
|
72
|
-
event_model.user_id ="my_user_id"
|
76
|
+
event_model.user_id = "my_user_id"
|
77
|
+
event_model.metadata = metadata
|
73
78
|
event_model.session_token = "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f"
|
74
79
|
|
75
80
|
# Perform the API call through the SDK function
|
@@ -79,17 +84,22 @@ class ApiControllerTests < ControllerTestBase
|
|
79
84
|
assert_equal(@response_catcher.response.status_code, 201)
|
80
85
|
end
|
81
86
|
|
82
|
-
#
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
87
|
+
# Add Batched Events via Ingestion API
|
88
|
+
def test_add_batched_events()
|
89
|
+
# Parameters for the API call
|
90
|
+
body = JSON.parse('[{ "metadata" : { "foo" : "ruby" }, "request": { "time": "2016-09-09T04:45:42.914", "uri": "https://api.acmeinc.com/items/reviews/", "verb": "PATCH", "api_version": "1.1.0", "ip_address": "61.48.220.123", "headers": { "Host": "api.acmeinc.com", "Accept": "*/*", "Connection": "Keep-Alive", "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)", "Content-Type": "application/json", "Content-Length": "126", "Accept-Encoding": "gzip" }, "body": { "items": [ { "direction_type": 1, "discovery_id": "fwfrf", "liked": false }, { "direction_type": 2, "discovery_id": "d43d3f", "liked": true } ] } }, "response": { "time": "2016-09-09T04:45:42.914", "status": 500, "headers": { "Date": "Tue, 23 Aug 2016 23:46:49 GMT", "Vary": "Accept-Encoding", "Pragma": "no-cache", "Expires": "-1", "Content-Type": "application/json; charset=utf-8", "X-Powered-By": "ARR/3.0", "Cache-Control": "no-cache", "Arr-Disable-Session-Affinity": "true" }, "body": { "Error": "InvalidArgumentException", "Message": "Missing field field_a" } }, "user_id": "mndug437f43", "session_token": "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f" }, { "request": { "time": "2016-09-09T04:46:42.914", "uri": "https://api.acmeinc.com/items/reviews/", "verb": "PATCH", "api_version": "1.1.0", "ip_address": "61.48.220.123", "headers": { "Host": "api.acmeinc.com", "Accept": "*/*", "Connection": "Keep-Alive", "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)", "Content-Type": "application/json", "Content-Length": "126", "Accept-Encoding": "gzip" }, "body": { "items": [ { "direction_type": 1, "discovery_id": "fwfrf", "liked": false }, { "direction_type": 2, "discovery_id": "d43d3f", "liked": true } ] } }, "response": { "time": "2016-09-09T04:46:42.914", "status": 500, "headers": { "Date": "Tue, 23 Aug 2016 23:46:49 GMT", "Vary": "Accept-Encoding", "Pragma": "no-cache", "Expires": "-1", "Content-Type": "application/json; charset=utf-8", "X-Powered-By": "ARR/3.0", "Cache-Control": "no-cache", "Arr-Disable-Session-Affinity": "true" }, "body": { "Error": "InvalidArgumentException", "Message": "Missing field field_a" } }, "user_id": "mndug437f43", "session_token": "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f" }, { "request": { "time": "2016-09-09T04:47:42.914", "uri": "https://api.acmeinc.com/items/reviews/", "verb": "PATCH", "api_version": "1.1.0", "ip_address": "61.48.220.123", "headers": { "Host": "api.acmeinc.com", "Accept": "*/*", "Connection": "Keep-Alive", "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)", "Content-Type": "application/json", "Content-Length": "126", "Accept-Encoding": "gzip" }, "body": { "items": [ { "direction_type": 1, "discovery_id": "fwfrf", "liked": false }, { "direction_type": 2, "discovery_id": "d43d3f", "liked": true } ] } }, "response": { "time": "2016-09-09T04:47:42.914", "status": 500, "headers": { "Date": "Tue, 23 Aug 2016 23:46:49 GMT", "Vary": "Accept-Encoding", "Pragma": "no-cache", "Expires": "-1", "Content-Type": "application/json; charset=utf-8", "X-Powered-By": "ARR/3.0", "Cache-Control": "no-cache", "Arr-Disable-Session-Affinity": "true" }, "body": { "Error": "InvalidArgumentException", "Message": "Missing field field_a" } }, "user_id": "mndug437f43", "session_token": "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f" }, { "request": { "time": "2016-09-09T04:48:42.914", "uri": "https://api.acmeinc.com/items/reviews/", "verb": "PATCH", "api_version": "1.1.0", "ip_address": "61.48.220.123", "headers": { "Host": "api.acmeinc.com", "Accept": "*/*", "Connection": "Keep-Alive", "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)", "Content-Type": "application/json", "Content-Length": "126", "Accept-Encoding": "gzip" }, "body": { "items": [ { "direction_type": 1, "discovery_id": "fwfrf", "liked": false }, { "direction_type": 2, "discovery_id": "d43d3f", "liked": true } ] } }, "metadata" : { "bar" : "ruby"}, "response": { "time": "2016-09-09T04:48:42.914", "status": 500, "headers": { "Date": "Tue, 23 Aug 2016 23:46:49 GMT", "Vary": "Accept-Encoding", "Pragma": "no-cache", "Expires": "-1", "Content-Type": "application/json; charset=utf-8", "X-Powered-By": "ARR/3.0", "Cache-Control": "no-cache", "Arr-Disable-Session-Affinity": "true" }, "body": { "Error": "InvalidArgumentException", "Message": "Missing field field_a" } }, "user_id": "mndug437f43", "session_token": "exfzweachxjgznvKUYrxFcxv]s98y18cx98q3yhwmnhcfx43f" }, { "request": { "time": "2016-09-09T04:49:42.914", "uri": "https://api.acmeinc.com/items/reviews/", "verb": "PATCH", "api_version": "1.1.0", "ip_address": "61.48.220.123", "headers": { "Host": "api.acmeinc.com", "Accept": "*/*", "Connection": "Keep-Alive", "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)", "Content-Type": "application/json", "Content-Length": "126", "Accept-Encoding": "gzip" }, "body": { "items": [ { "direction_type": 1, "discovery_id": "fwfrf", "liked": false }, { "direction_type": 2, "discovery_id": "d43d3f", "liked": true } ] } }, "response": { "time": "2016-09-09T04:49:42.914", "status": 500, "headers": { "Date": "Tue, 23 Aug 2016 23:46:49 GMT", "Vary": "Accept-Encoding", "Pragma": "no-cache", "Expires": "-1", "Content-Type": "application/json; charset=utf-8", "X-Powered-By": "ARR/3.0", "Cache-Control": "no-cache", "Arr-Disable-Session-Affinity": "true" }, "body": { "Error": "InvalidArgumentException", "Message": "Missing field field_a" } }, "user_id": "mndug437f43", "session_token": "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f" }, { "request": { "time": "2016-09-09T04:50:42.914", "uri": "https://api.acmeinc.com/items/reviews/", "verb": "PATCH", "api_version": "1.1.0", "ip_address": "61.48.220.123", "headers": { "Host": "api.acmeinc.com", "Accept": "*/*", "Connection": "Keep-Alive", "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)", "Content-Type": "application/json", "Content-Length": "126", "Accept-Encoding": "gzip" }, "body": { "items": [ { "direction_type": 1, "discovery_id": "fwfrf", "liked": false }, { "direction_type": 2, "discovery_id": "d43d3f", "liked": true } ] } }, "response": { "time": "2016-09-09T04:50:42.914", "status": 500, "headers": { "Date": "Tue, 23 Aug 2016 23:46:49 GMT", "Vary": "Accept-Encoding", "Pragma": "no-cache", "Expires": "-1", "Content-Type": "application/json; charset=utf-8", "X-Powered-By": "ARR/3.0", "Cache-Control": "no-cache", "Arr-Disable-Session-Affinity": "true" }, "body": { "Error": "InvalidArgumentException", "Message": "Missing field field_a" } }, "user_id": "recvreedfef", "session_token": "xcvkrjmcfghwuignrmcmhxdhaaezse4w]s98y18cx98q3yhwmnhcfx43f" } ]').map{|element|
|
91
|
+
result = EventModel.from_hash(element)
|
92
|
+
result.request.time = Time.now.utc.iso8601
|
93
|
+
result.response.time = (Time.now.utc + 1).iso8601
|
94
|
+
result
|
95
|
+
}
|
96
|
+
|
97
|
+
# Perform the API call through the SDK function
|
98
|
+
self.class.controller.create_events_batch(body)
|
99
|
+
|
100
|
+
# Test response code
|
101
|
+
assert_equal(@response_catcher.response.status_code, 201)
|
102
|
+
end
|
93
103
|
|
94
104
|
|
95
105
|
# Update Single User via API
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moesif_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Moesif, Inc
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-10-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: test-unit
|