moesif_api 1.0.2 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 94b53b43527aa718a3eba5aadaa7821c47c7674d
4
- data.tar.gz: 15463d07a86b7c7517155b05dee9d08c7b957af4
3
+ metadata.gz: dcbab0bc81c8ad69b16f525ca72045f26bdba195
4
+ data.tar.gz: a179486d119680e111d1854fb9156efe73e10a07
5
5
  SHA512:
6
- metadata.gz: 2ce13182b9b6d1b4b640ea8ab7012b5481789fd018cf565c2c63611e06b80279794943f6445dfaca9a961e10c9a796ad7b46901015f9b8f2b3dfe906e1bdaea4
7
- data.tar.gz: c9b692f819279dc73d5a2503300403abbf7c7fcba4d6659c68d03644dc6be72d872623f7b563180d29732f13e2e5f0448cbd4ce59d98d5776b01ed495fa2e1e8
6
+ metadata.gz: 24e67161dfec3f3a4348a68442b0586182be0a7dfe0e3197d0d5e7a71841ff6e8c2952059270852fdc059660085f4ecde2f1fe10efece28073a09cee4882d57d
7
+ data.tar.gz: ecd2171364c8b401dbf0731626b14c6e4cb884af650c843d9a0d5b0070c64ddd445748aff03e5b661b93fea6a1912bd22864606f0764c12e60c2e874067a3efe
data/README.md CHANGED
@@ -51,6 +51,67 @@ After having installed the gem, you can easily use the SDK following these steps
51
51
  require 'moesif_api'
52
52
 
53
53
  api_client = MoesifApi::MoesifAPIClient.new(my_application_id)
54
- controller = api_client.api_controller
55
- response = controller.create_event(<required parameters if any>)
54
+ api_controller = api_client.api_controller
55
+
56
+ req_headers = JSON.parse('{'\
57
+ '"Host": "api.acmeinc.com",'\
58
+ '"Accept": "*/*",'\
59
+ '"Connection": "Keep-Alive",'\
60
+ '"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)",'\
61
+ '"Content-Type": "application/json",'\
62
+ '"Content-Length": "126",'\
63
+ '"Accept-Encoding": "gzip"'\
64
+ '}')
65
+
66
+ req_body = JSON.parse( '{'\
67
+ '"items": ['\
68
+ '{'\
69
+ '"type": 1,'\
70
+ '"id": "fwfrf"'\
71
+ '},'\
72
+ '{'\
73
+ '"type": 2,'\
74
+ '"id": "d43d3f"'\
75
+ '}'\
76
+ ']'\
77
+ '}')
78
+
79
+ rsp_headers = JSON.parse('{'\
80
+ '"Date": "Tue, 23 Aug 2016 23:46:49 GMT",'\
81
+ '"Vary": "Accept-Encoding",'\
82
+ '"Pragma": "no-cache",'\
83
+ '"Expires": "-1",'\
84
+ '"Content-Type": "application/json; charset=utf-8",'\
85
+ '"Cache-Control": "no-cache"'\
86
+ '}')
87
+
88
+ rsp_body = JSON.parse('{'\
89
+ '"Error": "InvalidArgumentException",'\
90
+ '"Message": "Missing field field_a"'\
91
+ '}')
92
+
93
+
94
+ event_req = EventRequestModel.new()
95
+ event_req.time = "2016-09-09T04:45:42.914"
96
+ event_req.uri = "https://api.acmeinc.com/items/reviews/"
97
+ event_req.verb = "PATCH"
98
+ event_req.api_version = "1.1.0"
99
+ event_req.ip_address = "61.48.220.123"
100
+ event_req.headers = req_headers
101
+ event_req.body = req_body
102
+
103
+ event_rsp = EventResponseModel.new()
104
+ event_rsp.time = "2016-09-09T04:45:42.914"
105
+ event_rsp.status = 500
106
+ event_rsp.headers = rsp_headers
107
+ event_rsp.body = rsp_body
108
+
109
+ event_model = EventModel.new()
110
+ event_model.request = event_req
111
+ event_model.response = event_rsp
112
+ event_model.user_id ="my_user_id"
113
+ event_model.session_token = "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f"
114
+
115
+ # Perform the API call through the SDK function
116
+ response = api_controller.create_event(event_model)
56
117
  ```
@@ -7,7 +7,7 @@ module MoesifApi
7
7
  attr_accessor :request
8
8
 
9
9
  # API response Object
10
- # @return [ResponseModel]
10
+ # @return [EventResponseModel]
11
11
  attr_accessor :response
12
12
 
13
13
  # End user's auth/session token
@@ -54,7 +54,7 @@ module MoesifApi
54
54
  else
55
55
  # Extract variables from the hash
56
56
  request = EventRequestModel.from_hash(hash["request"]) if hash["request"]
57
- response = ResponseModel.from_hash(hash["response"]) if hash["response"]
57
+ response = EventResponseModel.from_hash(hash["response"]) if hash["response"]
58
58
  session_token = hash["session_token"]
59
59
  tags = hash["tags"]
60
60
  user_id = hash["user_id"]
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'date'
4
4
  module MoesifApi
5
- class ResponseModel < BaseModel
5
+ class EventResponseModel < BaseModel
6
6
  # Time when response received
7
7
  # @return [DateTime]
8
8
  attr_accessor :time
@@ -61,11 +61,11 @@ module MoesifApi
61
61
  ip_address = hash["ip_address"]
62
62
 
63
63
  # Create object from extracted values
64
- ResponseModel.new(time,
65
- status,
66
- headers,
67
- body,
68
- ip_address)
64
+ EventResponseModel.new(time,
65
+ status,
66
+ headers,
67
+ body,
68
+ ip_address)
69
69
  end
70
70
  end
71
71
  end
@@ -11,10 +11,68 @@ class ApiControllerTests < ControllerTestBase
11
11
  # Add Single Event via Injestion API
12
12
  def test_add_event()
13
13
  # Parameters for the API call
14
- body = EventModel.from_hash(JSON.parse('{ "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" }'))
14
+
15
+ req_headers = JSON.parse('{'\
16
+ '"Host": "api.acmeinc.com",'\
17
+ '"Accept": "*/*",'\
18
+ '"Connection": "Keep-Alive",'\
19
+ '"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)",'\
20
+ '"Content-Type": "application/json",'\
21
+ '"Content-Length": "126",'\
22
+ '"Accept-Encoding": "gzip"'\
23
+ '}')
24
+
25
+ req_body = JSON.parse( '{'\
26
+ '"items": ['\
27
+ '{'\
28
+ '"type": 1,'\
29
+ '"id": "fwfrf"'\
30
+ '},'\
31
+ '{'\
32
+ '"type": 2,'\
33
+ '"id": "d43d3f"'\
34
+ '}'\
35
+ ']'\
36
+ '}')
37
+
38
+ rsp_headers = JSON.parse('{'\
39
+ '"Date": "Tue, 23 Aug 2016 23:46:49 GMT",'\
40
+ '"Vary": "Accept-Encoding",'\
41
+ '"Pragma": "no-cache",'\
42
+ '"Expires": "-1",'\
43
+ '"Content-Type": "application/json; charset=utf-8",'\
44
+ '"Cache-Control": "no-cache"'\
45
+ '}')
46
+
47
+ rsp_body = JSON.parse('{'\
48
+ '"Error": "InvalidArgumentException",'\
49
+ '"Message": "Missing field field_a"'\
50
+ '}')
51
+
52
+
53
+ event_req = EventRequestModel.new()
54
+ event_req.time = "2016-09-09T04:45:42.914"
55
+ event_req.uri = "https://api.acmeinc.com/items/reviews/"
56
+ event_req.verb = "PATCH"
57
+ event_req.api_version = "1.1.0"
58
+ event_req.ip_address = "61.48.220.123"
59
+ event_req.headers = req_headers
60
+ event_req.body = req_body
61
+
62
+ event_rsp = EventResponseModel.new()
63
+ event_rsp.time = "2016-09-09T04:45:42.914"
64
+ event_rsp.status = 500
65
+ event_rsp.headers = rsp_headers
66
+ event_rsp.body = rsp_body
67
+
68
+ event_model = EventModel.new()
69
+ event_model.request = event_req
70
+ event_model.response = event_rsp
71
+ event_model.user_id ="my_user_id"
72
+ event_model.session_token = "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f"
15
73
 
16
74
  # Perform the API call through the SDK function
17
- self.class.controller.create_event(body)
75
+ self.class.controller.create_event(event_model)
18
76
 
19
77
  # Test response code
20
78
  assert_equal(@response_catcher.response.status_code, 201)
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.0.2
4
+ version: 1.0.3
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: 2016-09-11 00:00:00.000000000 Z
12
+ date: 2016-10-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit