moesif_api 1.0.4 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +62 -38
- data/lib/moesif_api/configuration.rb +3 -0
- data/lib/moesif_api/controllers/api_controller.rb +86 -2
- data/lib/moesif_api/controllers/health_controller.rb +2 -1
- data/lib/moesif_api/models/event_request_model.rb +16 -7
- data/lib/moesif_api/models/event_response_model.rb +11 -2
- data/lib/moesif_api/models/user_model.rb +82 -0
- data/lib/moesif_api.rb +1 -0
- data/test/controllers/controller_test_base.rb +1 -1
- data/test/controllers/test_api_controller.rb +30 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 846b5918e27ee9bd25216d757128d00bfdaf1671
|
4
|
+
data.tar.gz: 4bb93a459ee238363aeadcac54493269dcbcd7f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81b7293bda18fb4128bfabbfa1e86216b2714817f28c8b6344077d19ca432bb6ebe37010a6977af7b8cd3f759c02a04dfc971c1f99e70ac2cb8b6ba8bd52219a
|
7
|
+
data.tar.gz: 83e2d8c83908cc0a07bab2bb48683da37654ffd50d85c2a4e6dc722127dca05873ffcb78dde1358b97e8c067b7db33a1b5ce25b4ed7ff241d87873181f1b10d8
|
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
MoesifApi Lib for Ruby
|
2
|
-
|
1
|
+
# MoesifApi Lib for Ruby
|
2
|
+
|
3
3
|
|
4
4
|
[Source Code on GitHub](https://github.com/moesif/moesifapi-ruby)
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
[Ruby Gem](https://github.com/Moesif/moesifapi-ruby)
|
7
|
+
|
8
|
+
__Check out Moesif's [Developer Documentation](https://www.moesif.com/docs) and [Ruby API Reference](https://www.moesif.com/docs/api?ruby) to learn more__
|
8
9
|
|
9
|
-
(Documentation access requires an active account)
|
10
10
|
|
11
|
-
How to configure:
|
12
|
-
|
11
|
+
## How to configure:
|
12
|
+
|
13
13
|
The generated code might need to be configured with your API credentials. To do that,
|
14
14
|
open the file "configuration.rb" and edit it's contents.
|
15
15
|
|
@@ -17,39 +17,14 @@ Alternatively, you can modify the Configuration parameters at run-time through t
|
|
17
17
|
```
|
18
18
|
MoesifApi::Configuration.your_paramater = YOUR_VALUE
|
19
19
|
```
|
20
|
-
Install from RubyGems
|
21
|
-
=====================
|
22
|
-
gem install moesif_api
|
23
|
-
|
24
|
-
How to build and install manually:
|
25
|
-
==================================
|
26
|
-
The generated code depends on a few Ruby gems. The references to these gems are
|
27
|
-
added in the gemspec file. The easiest way to resolve the dependencies,
|
28
|
-
build the gem and install it is through Rake:
|
29
|
-
|
30
|
-
1. Install Rake if not already installed: `gem install rake`
|
31
|
-
2. Install Bundler if not already installed: `gem install bundler`
|
32
|
-
3. From terminal/cmd navigate to the root directory of the SDK.
|
33
|
-
4. Invoke: `rake install`
|
34
|
-
|
35
|
-
Alternatively, you can build and install the gem manually:
|
36
|
-
|
37
|
-
1. From terminal/cmd navigate to the root directory of the SDK.
|
38
|
-
2. Run the build command: `gem build moesif_api.gemspec`
|
39
|
-
3. Run the install command: `gem install ./moesif_api-1.0.0.gem`
|
40
|
-
|
41
|
-
Note: You will need to have internet access for this step.
|
20
|
+
### Install from RubyGems
|
42
21
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
cases as follows:
|
22
|
+
```
|
23
|
+
gem install moesif_api
|
24
|
+
```
|
47
25
|
|
48
|
-
|
49
|
-
2. Invoke: `bundle exec rake`
|
26
|
+
## How to use:
|
50
27
|
|
51
|
-
How to use:
|
52
|
-
===========
|
53
28
|
After having installed the gem, you can easily use the SDK following these steps.
|
54
29
|
|
55
30
|
1. Create a "moesif_api_test.rb" file in the root directory.
|
@@ -58,7 +33,7 @@ After having installed the gem, you can easily use the SDK following these steps
|
|
58
33
|
require 'moesif_api'
|
59
34
|
|
60
35
|
api_client = MoesifApi::MoesifAPIClient.new(my_application_id)
|
61
|
-
api_controller = api_client.
|
36
|
+
api_controller = api_client.api
|
62
37
|
|
63
38
|
req_headers = JSON.parse('{'\
|
64
39
|
'"Host": "api.acmeinc.com",'\
|
@@ -122,3 +97,52 @@ event_model.session_token = "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98
|
|
122
97
|
# Perform the API call through the SDK function
|
123
98
|
response = api_controller.create_event(event_model)
|
124
99
|
```
|
100
|
+
|
101
|
+
### update user
|
102
|
+
|
103
|
+
You can also update the metadata for each user. The only required field is user_id
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
api_client = MoesifApi::MoesifAPIClient.new(my_application_id)
|
107
|
+
api_controller = api_client.api
|
108
|
+
|
109
|
+
metadata = JSON.parse('{'\
|
110
|
+
'"email": "testrubyapi@user.com",'\
|
111
|
+
'"name": "ruby api user",'\
|
112
|
+
'"custom": "testdata"'\
|
113
|
+
'}')
|
114
|
+
|
115
|
+
user_model = UserModel.new()
|
116
|
+
user_model.modified_time = Time.now.utc.iso8601 # option, default now.
|
117
|
+
user_model.user_id = "testrubyapiuser" #only required field.
|
118
|
+
user_model.metadata = metadata
|
119
|
+
|
120
|
+
response = api_controller.update_user(user_model)
|
121
|
+
|
122
|
+
```
|
123
|
+
## How to build and install manually:
|
124
|
+
|
125
|
+
The generated code depends on a few Ruby gems. The references to these gems are
|
126
|
+
added in the gemspec file. The easiest way to resolve the dependencies,
|
127
|
+
build the gem and install it is through Rake:
|
128
|
+
|
129
|
+
1. Install Rake if not already installed: `gem install rake`
|
130
|
+
2. Install Bundler if not already installed: `gem install bundler`
|
131
|
+
3. From terminal/cmd navigate to the root directory of the SDK.
|
132
|
+
4. Invoke: `rake install`
|
133
|
+
|
134
|
+
Alternatively, you can build and install the gem manually:
|
135
|
+
|
136
|
+
1. From terminal/cmd navigate to the root directory of the SDK.
|
137
|
+
2. Run the build command: `gem build moesif_api.gemspec`
|
138
|
+
3. Run the install command: `gem install ./moesif_api-1.0.0.gem`
|
139
|
+
|
140
|
+
Note: You will need to have internet access for this step.
|
141
|
+
|
142
|
+
## How to test:
|
143
|
+
|
144
|
+
You can test the generated SDK and the server with automatically generated test
|
145
|
+
cases as follows:
|
146
|
+
|
147
|
+
1. From terminal/cmd navigate to the root directory of the SDK.
|
148
|
+
2. Invoke: `bundle exec rake`
|
@@ -8,10 +8,13 @@ module MoesifApi
|
|
8
8
|
# Your Application Id for authentication/authorization
|
9
9
|
@application_id = 'TODO: Replace'
|
10
10
|
|
11
|
+
@version = '1.1.0'
|
12
|
+
|
11
13
|
# create the getters and setters
|
12
14
|
class << self
|
13
15
|
attr_accessor :base_uri
|
14
16
|
attr_accessor :application_id
|
17
|
+
attr_accessor :version
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
@@ -24,7 +24,8 @@ module MoesifApi
|
|
24
24
|
# prepare headers
|
25
25
|
_headers = {
|
26
26
|
'content-type' => 'application/json; charset=utf-8',
|
27
|
-
'X-Moesif-Application-Id' => Configuration.application_id
|
27
|
+
'X-Moesif-Application-Id' => Configuration.application_id,
|
28
|
+
'User-Agent' => 'moesifapi-ruby/' + Configuration.version
|
28
29
|
}
|
29
30
|
|
30
31
|
# Create the HttpRequest object for the call
|
@@ -62,7 +63,8 @@ module MoesifApi
|
|
62
63
|
# prepare headers
|
63
64
|
_headers = {
|
64
65
|
'content-type' => 'application/json; charset=utf-8',
|
65
|
-
'X-Moesif-Application-Id' => Configuration.application_id
|
66
|
+
'X-Moesif-Application-Id' => Configuration.application_id,
|
67
|
+
'User-Agent' => 'moesifapi-ruby/' + Configuration.version
|
66
68
|
}
|
67
69
|
|
68
70
|
# Create the HttpRequest object for the call
|
@@ -83,5 +85,87 @@ module MoesifApi
|
|
83
85
|
# Global error handling using HTTP status codes.
|
84
86
|
validate_response(_context)
|
85
87
|
end
|
88
|
+
|
89
|
+
# Update Data for a Single User
|
90
|
+
# @param [UserModel] body Required parameter.
|
91
|
+
# @return void response from the API call
|
92
|
+
def update_user(body)
|
93
|
+
# the base uri for api requests
|
94
|
+
_query_builder = Configuration.base_uri.dup
|
95
|
+
|
96
|
+
# prepare query string for API call
|
97
|
+
_query_builder << '/v1/users'
|
98
|
+
|
99
|
+
# validate and preprocess url
|
100
|
+
_query_url = APIHelper.clean_url _query_builder
|
101
|
+
|
102
|
+
# prepare headers
|
103
|
+
_headers = {
|
104
|
+
'content-type' => 'application/json; charset=utf-8',
|
105
|
+
'X-Moesif-Application-Id' => Configuration.application_id,
|
106
|
+
'User-Agent' => 'moesifapi-ruby/' + Configuration.version
|
107
|
+
}
|
108
|
+
|
109
|
+
# Create the HttpRequest object for the call
|
110
|
+
_request = @http_client.post _query_url, headers: _headers, parameters: body.to_json
|
111
|
+
|
112
|
+
# Call the on_before_request callback
|
113
|
+
@http_call_back.on_before_request(_request) if @http_call_back
|
114
|
+
|
115
|
+
# Invoke the API call and get the response
|
116
|
+
_response = @http_client.execute_as_string(_request)
|
117
|
+
|
118
|
+
# Wrap the request and response in an HttpContext object
|
119
|
+
_context = HttpContext.new(_request, _response)
|
120
|
+
|
121
|
+
# Call the on_after_response callback
|
122
|
+
@http_call_back.on_after_response(_context) if @http_call_back
|
123
|
+
|
124
|
+
# Global error handling using HTTP status codes.
|
125
|
+
validate_response(_context)
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
# Update Data for a Single User
|
130
|
+
# @param [list of UserModel] body Required parameter.
|
131
|
+
# @return void response from the API call
|
132
|
+
def update_users_batch(body)
|
133
|
+
# the base uri for api requests
|
134
|
+
_query_builder = Configuration.base_uri.dup
|
135
|
+
|
136
|
+
# prepare query string for API call
|
137
|
+
_query_builder << '/v1/users/batch'
|
138
|
+
|
139
|
+
# validate and preprocess url
|
140
|
+
_query_url = APIHelper.clean_url _query_builder
|
141
|
+
|
142
|
+
# prepare headers
|
143
|
+
_headers = {
|
144
|
+
'content-type' => 'application/json; charset=utf-8',
|
145
|
+
'X-Moesif-Application-Id' => Configuration.application_id,
|
146
|
+
'User-Agent' => 'moesifapi-ruby/' + Configuration.version
|
147
|
+
}
|
148
|
+
|
149
|
+
# Create the HttpRequest object for the call
|
150
|
+
_request = @http_client.post _query_url, headers: _headers, parameters: body.to_json
|
151
|
+
|
152
|
+
# Call the on_before_request callback
|
153
|
+
@http_call_back.on_before_request(_request) if @http_call_back
|
154
|
+
|
155
|
+
# Invoke the API call and get the response
|
156
|
+
_response = @http_client.execute_as_string(_request)
|
157
|
+
|
158
|
+
# Wrap the request and response in an HttpContext object
|
159
|
+
_context = HttpContext.new(_request, _response)
|
160
|
+
|
161
|
+
# Call the on_after_response callback
|
162
|
+
@http_call_back.on_after_response(_context) if @http_call_back
|
163
|
+
|
164
|
+
# Global error handling using HTTP status codes.
|
165
|
+
validate_response(_context)
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
|
86
170
|
end
|
87
171
|
end
|
@@ -23,7 +23,8 @@ module MoesifApi
|
|
23
23
|
# prepare headers
|
24
24
|
_headers = {
|
25
25
|
'accept' => 'application/json',
|
26
|
-
'X-Moesif-Application-Id' => Configuration.application_id
|
26
|
+
'X-Moesif-Application-Id' => Configuration.application_id,
|
27
|
+
'User-Agent' => 'moesifapi-ruby/' + Configuration.version
|
27
28
|
}
|
28
29
|
|
29
30
|
# Create the HttpRequest object for the call
|
@@ -31,6 +31,10 @@ module MoesifApi
|
|
31
31
|
# @return [Object]
|
32
32
|
attr_accessor :body
|
33
33
|
|
34
|
+
# Transfer Encoding of body if other than JSON
|
35
|
+
# @return [String]
|
36
|
+
attr_accessor :transfer_encoding
|
37
|
+
|
34
38
|
# A mapping from model property names to API property names
|
35
39
|
def self.names
|
36
40
|
if @hash.nil?
|
@@ -42,6 +46,7 @@ module MoesifApi
|
|
42
46
|
@hash["api_version"] = "api_version"
|
43
47
|
@hash["ip_address"] = "ip_address"
|
44
48
|
@hash["body"] = "body"
|
49
|
+
@hash["transfer_encoding"] = "transfer_encoding"
|
45
50
|
end
|
46
51
|
@hash
|
47
52
|
end
|
@@ -52,7 +57,8 @@ module MoesifApi
|
|
52
57
|
headers = nil,
|
53
58
|
api_version = nil,
|
54
59
|
ip_address = nil,
|
55
|
-
body = nil
|
60
|
+
body = nil,
|
61
|
+
transfer_encoding = nil)
|
56
62
|
@time = time
|
57
63
|
@uri = uri
|
58
64
|
@verb = verb
|
@@ -60,6 +66,7 @@ module MoesifApi
|
|
60
66
|
@api_version = api_version
|
61
67
|
@ip_address = ip_address
|
62
68
|
@body = body
|
69
|
+
@transfer_encoding = transfer_encoding
|
63
70
|
end
|
64
71
|
|
65
72
|
# Creates an instance of the object from a hash
|
@@ -75,15 +82,17 @@ module MoesifApi
|
|
75
82
|
api_version = hash["api_version"]
|
76
83
|
ip_address = hash["ip_address"]
|
77
84
|
body = hash["body"]
|
85
|
+
transfer_encoding = hash["transfer_encoding"]
|
78
86
|
|
79
87
|
# Create object from extracted values
|
80
88
|
EventRequestModel.new(time,
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
89
|
+
uri,
|
90
|
+
verb,
|
91
|
+
headers,
|
92
|
+
api_version,
|
93
|
+
ip_address,
|
94
|
+
body,
|
95
|
+
transfer_encoding)
|
87
96
|
end
|
88
97
|
end
|
89
98
|
end
|
@@ -23,6 +23,10 @@ module MoesifApi
|
|
23
23
|
# @return [String]
|
24
24
|
attr_accessor :ip_address
|
25
25
|
|
26
|
+
# Transfer Encoding of body if other than JSON
|
27
|
+
# @return [String]
|
28
|
+
attr_accessor :transfer_encoding
|
29
|
+
|
26
30
|
# A mapping from model property names to API property names
|
27
31
|
def self.names
|
28
32
|
if @hash.nil?
|
@@ -32,6 +36,7 @@ module MoesifApi
|
|
32
36
|
@hash["headers"] = "headers"
|
33
37
|
@hash["body"] = "body"
|
34
38
|
@hash["ip_address"] = "ip_address"
|
39
|
+
@hash["transfer_encoding"] = "transfer_encoding"
|
35
40
|
end
|
36
41
|
@hash
|
37
42
|
end
|
@@ -40,12 +45,14 @@ module MoesifApi
|
|
40
45
|
status = nil,
|
41
46
|
headers = nil,
|
42
47
|
body = nil,
|
43
|
-
ip_address = nil
|
48
|
+
ip_address = nil,
|
49
|
+
transfer_encoding = nil)
|
44
50
|
@time = time
|
45
51
|
@status = status
|
46
52
|
@headers = headers
|
47
53
|
@body = body
|
48
54
|
@ip_address = ip_address
|
55
|
+
@transfer_encoding = transfer_encoding
|
49
56
|
end
|
50
57
|
|
51
58
|
# Creates an instance of the object from a hash
|
@@ -59,13 +66,15 @@ module MoesifApi
|
|
59
66
|
headers = hash["headers"]
|
60
67
|
body = hash["body"]
|
61
68
|
ip_address = hash["ip_address"]
|
69
|
+
transfer_encoding = hash["transfer_encoding"]
|
62
70
|
|
63
71
|
# Create object from extracted values
|
64
72
|
EventResponseModel.new(time,
|
65
73
|
status,
|
66
74
|
headers,
|
67
75
|
body,
|
68
|
-
ip_address
|
76
|
+
ip_address,
|
77
|
+
transfer_encoding)
|
69
78
|
end
|
70
79
|
end
|
71
80
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
module MoesifApi
|
5
|
+
class UserModel < BaseModel
|
6
|
+
|
7
|
+
# user id of the user
|
8
|
+
# @return [String]
|
9
|
+
attr_accessor :user_id
|
10
|
+
|
11
|
+
# Time when modification was made. default to current time on server side.
|
12
|
+
# @return [DateTime]
|
13
|
+
attr_accessor :modified_time
|
14
|
+
|
15
|
+
# ip address associated with user if avaialble.
|
16
|
+
# @return [String]
|
17
|
+
attr_accessor :ip_address
|
18
|
+
|
19
|
+
# session token associated with user if avaialble.
|
20
|
+
# @return [String]
|
21
|
+
attr_accessor :session_token
|
22
|
+
|
23
|
+
# Optionally tag the user with an user agent.
|
24
|
+
# @return [String]
|
25
|
+
attr_accessor :user_agent_string
|
26
|
+
|
27
|
+
# meta data
|
28
|
+
# @return [Object]
|
29
|
+
attr_accessor :metadata
|
30
|
+
|
31
|
+
# A mapping from model property names to API property names
|
32
|
+
def self.names
|
33
|
+
if @hash.nil?
|
34
|
+
@hash = {}
|
35
|
+
@hash["user_id"] = "user_id"
|
36
|
+
@hash["modified_time"] = "modified_time"
|
37
|
+
@hash["ip_address"] = "ip_address"
|
38
|
+
@hash["session_token"] = "session_token"
|
39
|
+
@hash["user_agent_string"] = "user_agent_string"
|
40
|
+
@hash["metadata"] = "metadata"
|
41
|
+
end
|
42
|
+
@hash
|
43
|
+
end
|
44
|
+
|
45
|
+
def initialize(user_id = nil,
|
46
|
+
modified_time = nil,
|
47
|
+
ip_address = nil,
|
48
|
+
session_token = nil,
|
49
|
+
user_agent_string = nil,
|
50
|
+
metadata = nil)
|
51
|
+
@user_id = user_id
|
52
|
+
@modified_time = modified_time
|
53
|
+
@ip_address = ip_address
|
54
|
+
@session_token = session_token
|
55
|
+
@user_agent_string = user_agent_string
|
56
|
+
@metadata = metadata
|
57
|
+
end
|
58
|
+
|
59
|
+
# Creates an instance of the object from a hash
|
60
|
+
def self.from_hash(hash)
|
61
|
+
if hash == nil
|
62
|
+
nil
|
63
|
+
else
|
64
|
+
# Extract variables from the hash
|
65
|
+
user_id = hash["user_id"]
|
66
|
+
modified_time = DateTime.iso8601(hash["modified_time"]) if hash["modified_time"]
|
67
|
+
ip_address = hash["ip_address"]
|
68
|
+
session_token = hash["session_token"]
|
69
|
+
user_agent_string = hash["user_agent_string"]
|
70
|
+
metadata = hash["metadata"]
|
71
|
+
|
72
|
+
# Create object from extracted values
|
73
|
+
UserModel.new(user_id,
|
74
|
+
modified_time,
|
75
|
+
ip_address,
|
76
|
+
session_token,
|
77
|
+
user_agent_string,
|
78
|
+
metadata)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/lib/moesif_api.rb
CHANGED
@@ -26,6 +26,7 @@ require_relative 'moesif_api/models/event_request_model.rb'
|
|
26
26
|
require_relative 'moesif_api/models/event_model.rb'
|
27
27
|
require_relative 'moesif_api/models/event_response_model.rb'
|
28
28
|
require_relative 'moesif_api/models/status_model.rb'
|
29
|
+
require_relative 'moesif_api/models/user_model.rb'
|
29
30
|
|
30
31
|
# Controllers
|
31
32
|
require_relative 'moesif_api/controllers/base_controller.rb'
|
@@ -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("eyJhcHAiOiIzMTU6MSIsInZlciI6IjIuMCIsIm9yZyI6IjM1MToxNSIsImlhdCI6MTQ4Nzk4MDgwMH0.o_hDQF_Y6-4Z3TWMBYi3bbbxHx4gCaW5ieRagJZtZew")
|
19
19
|
@@request_timeout = 30
|
20
20
|
@@assert_precision = 0.01
|
21
21
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
|
2
2
|
|
3
|
+
require 'time'
|
3
4
|
require_relative 'controller_test_base'
|
4
5
|
|
5
6
|
class ApiControllerTests < ControllerTestBase
|
@@ -51,7 +52,7 @@ class ApiControllerTests < ControllerTestBase
|
|
51
52
|
|
52
53
|
|
53
54
|
event_req = EventRequestModel.new()
|
54
|
-
event_req.time =
|
55
|
+
event_req.time = Time.now.utc.iso8601
|
55
56
|
event_req.uri = "https://api.acmeinc.com/items/reviews/"
|
56
57
|
event_req.verb = "PATCH"
|
57
58
|
event_req.api_version = "1.1.0"
|
@@ -60,7 +61,7 @@ class ApiControllerTests < ControllerTestBase
|
|
60
61
|
event_req.body = req_body
|
61
62
|
|
62
63
|
event_rsp = EventResponseModel.new()
|
63
|
-
event_rsp.time =
|
64
|
+
event_rsp.time = Time.now.utc.iso8601
|
64
65
|
event_rsp.status = 500
|
65
66
|
event_rsp.headers = rsp_headers
|
66
67
|
event_rsp.body = rsp_body
|
@@ -78,13 +79,36 @@ class ApiControllerTests < ControllerTestBase
|
|
78
79
|
assert_equal(@response_catcher.response.status_code, 201)
|
79
80
|
end
|
80
81
|
|
81
|
-
# Add Batched Events via Ingestion API
|
82
|
-
def test_add_batched_events()
|
82
|
+
# # Add Batched Events via Ingestion API
|
83
|
+
# def test_add_batched_events()
|
84
|
+
# # Parameters for the API call
|
85
|
+
# body = 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" }, { "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 } ] } }, "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| EventModel.from_hash(element)}
|
86
|
+
#
|
87
|
+
# # Perform the API call through the SDK function
|
88
|
+
# self.class.controller.create_events_batch(body)
|
89
|
+
#
|
90
|
+
# # Test response code
|
91
|
+
# assert_equal(@response_catcher.response.status_code, 201)
|
92
|
+
# end
|
93
|
+
|
94
|
+
|
95
|
+
# Update Single User via API
|
96
|
+
def test_update_user()
|
83
97
|
# Parameters for the API call
|
84
|
-
|
98
|
+
|
99
|
+
metadata = JSON.parse('{'\
|
100
|
+
'"email": "testrubyapi@user.com",'\
|
101
|
+
'"name": "ruby api user",'\
|
102
|
+
'"custom": "testdata"'\
|
103
|
+
'}')
|
104
|
+
|
105
|
+
user_model = UserModel.new()
|
106
|
+
user_model.modified_time = Time.now.utc.iso8601
|
107
|
+
user_model.user_id = "testrubyapiuser"
|
108
|
+
user_model.metadata = metadata
|
85
109
|
|
86
110
|
# Perform the API call through the SDK function
|
87
|
-
self.class.controller.
|
111
|
+
self.class.controller.update_user(user_model)
|
88
112
|
|
89
113
|
# Test response code
|
90
114
|
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.
|
4
|
+
version: 1.1.1
|
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:
|
12
|
+
date: 2017-03-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: test-unit
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- lib/moesif_api/models/event_request_model.rb
|
81
81
|
- lib/moesif_api/models/event_response_model.rb
|
82
82
|
- lib/moesif_api/models/status_model.rb
|
83
|
+
- lib/moesif_api/models/user_model.rb
|
83
84
|
- lib/moesif_api/moesif_api_client.rb
|
84
85
|
- test/controllers/controller_test_base.rb
|
85
86
|
- test/controllers/test_api_controller.rb
|