devcycle-server-sdk 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/README.md +175 -0
- data/Rakefile +10 -0
- data/devcycle-server-sdk.gemspec +38 -0
- data/docs/DevcycleApi.md +289 -0
- data/docs/ErrorResponse.md +20 -0
- data/docs/Event.md +26 -0
- data/docs/Feature.md +26 -0
- data/docs/UserData.md +48 -0
- data/docs/Variable.md +24 -0
- data/examples/sinatra/Gemfile +6 -0
- data/examples/sinatra/Gemfile.lock +51 -0
- data/examples/sinatra/README.md +14 -0
- data/examples/sinatra/app.rb +47 -0
- data/git_push.sh +57 -0
- data/lib/devcycle-server-sdk/api/devcycle_api.rb +347 -0
- data/lib/devcycle-server-sdk/api_client.rb +390 -0
- data/lib/devcycle-server-sdk/api_error.rb +57 -0
- data/lib/devcycle-server-sdk/configuration.rb +278 -0
- data/lib/devcycle-server-sdk/models/error_response.rb +234 -0
- data/lib/devcycle-server-sdk/models/event.rb +264 -0
- data/lib/devcycle-server-sdk/models/feature.rb +313 -0
- data/lib/devcycle-server-sdk/models/inline_response201.rb +218 -0
- data/lib/devcycle-server-sdk/models/user_data.rb +447 -0
- data/lib/devcycle-server-sdk/models/user_data_and_events_body.rb +229 -0
- data/lib/devcycle-server-sdk/models/variable.rb +303 -0
- data/lib/devcycle-server-sdk/version.rb +15 -0
- data/lib/devcycle-server-sdk.rb +47 -0
- data/spec/api/devcycle_api_spec.rb +80 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/error_response_spec.rb +40 -0
- data/spec/models/event_spec.rb +58 -0
- data/spec/models/feature_spec.rb +62 -0
- data/spec/models/inline_response201_spec.rb +34 -0
- data/spec/models/user_data_and_events_body_spec.rb +40 -0
- data/spec/models/user_data_spec.rb +128 -0
- data/spec/models/variable_spec.rb +56 -0
- data/spec/spec_helper.rb +111 -0
- metadata +134 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../..
|
3
|
+
specs:
|
4
|
+
devcycle-server-sdk (1.0.0)
|
5
|
+
typhoeus (~> 1.0, >= 1.0.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
daemons (1.4.1)
|
11
|
+
ethon (0.15.0)
|
12
|
+
ffi (>= 1.15.0)
|
13
|
+
eventmachine (1.2.7)
|
14
|
+
ffi (1.15.4)
|
15
|
+
multi_json (1.15.0)
|
16
|
+
mustermann (1.1.1)
|
17
|
+
ruby2_keywords (~> 0.0.1)
|
18
|
+
rack (2.2.3)
|
19
|
+
rack-protection (2.1.0)
|
20
|
+
rack
|
21
|
+
ruby2_keywords (0.0.5)
|
22
|
+
sinatra (2.1.0)
|
23
|
+
mustermann (~> 1.0)
|
24
|
+
rack (~> 2.2)
|
25
|
+
rack-protection (= 2.1.0)
|
26
|
+
tilt (~> 2.0)
|
27
|
+
sinatra-contrib (2.1.0)
|
28
|
+
multi_json
|
29
|
+
mustermann (~> 1.0)
|
30
|
+
rack-protection (= 2.1.0)
|
31
|
+
sinatra (= 2.1.0)
|
32
|
+
tilt (~> 2.0)
|
33
|
+
thin (1.8.1)
|
34
|
+
daemons (~> 1.0, >= 1.0.9)
|
35
|
+
eventmachine (~> 1.0, >= 1.0.4)
|
36
|
+
rack (>= 1, < 3)
|
37
|
+
tilt (2.0.10)
|
38
|
+
typhoeus (1.4.0)
|
39
|
+
ethon (>= 0.9.0)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
x86_64-darwin-19
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
devcycle-server-sdk!
|
46
|
+
sinatra
|
47
|
+
sinatra-contrib
|
48
|
+
thin
|
49
|
+
|
50
|
+
BUNDLED WITH
|
51
|
+
2.2.31
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# DevCycle Ruby SDK Example App
|
2
|
+
|
3
|
+
This is a test application demonstrating the use of the DevCycle Ruby SDK. It uses Sinatra as
|
4
|
+
a web framework to define several routes which can be called to trigger SDK functionality.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
Install the dependencies using bundler:
|
8
|
+
`bundle install`
|
9
|
+
|
10
|
+
## Run
|
11
|
+
Run the application using bundler:
|
12
|
+
`bundle exec ruby app.rb <YOUR SDK TOKEN>`
|
13
|
+
|
14
|
+
A valid DevCycle SDK token must be provided.
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require "sinatra/reloader" if development?
|
3
|
+
require 'devcycle-server-sdk'
|
4
|
+
|
5
|
+
token = ARGV[0]
|
6
|
+
|
7
|
+
if !token
|
8
|
+
fail Exception, 'Must provide server SDK token'
|
9
|
+
end
|
10
|
+
|
11
|
+
DevCycle.configure do |config|
|
12
|
+
# Configure API key authorization: bearerAuth
|
13
|
+
config.api_key['bearerAuth'] = token
|
14
|
+
# config.debugging = true
|
15
|
+
end
|
16
|
+
|
17
|
+
api_instance = DevCycle::DVCClient.new
|
18
|
+
user_data = DevCycle::UserData.new({
|
19
|
+
user_id: 'my-user',
|
20
|
+
app_version: '1.2.3'
|
21
|
+
})
|
22
|
+
|
23
|
+
get '/' do
|
24
|
+
'Hello world!'
|
25
|
+
end
|
26
|
+
|
27
|
+
get '/experiment' do
|
28
|
+
result = api_instance.get_variable_by_key("test-feature", user_data, false)
|
29
|
+
p result
|
30
|
+
|
31
|
+
"Your variable result is: #{result.value}"
|
32
|
+
end
|
33
|
+
|
34
|
+
get '/track-event' do
|
35
|
+
event_data = DevCycle::Event.new({
|
36
|
+
# type: "my-event",
|
37
|
+
target: "some_event_target",
|
38
|
+
value: 12,
|
39
|
+
meta_data: {
|
40
|
+
myKey: "my-value"
|
41
|
+
}
|
42
|
+
})
|
43
|
+
|
44
|
+
result = api_instance.track_event(user_data, event_data)
|
45
|
+
|
46
|
+
p result
|
47
|
+
end
|
data/git_push.sh
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
3
|
+
#
|
4
|
+
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
5
|
+
|
6
|
+
git_user_id=$1
|
7
|
+
git_repo_id=$2
|
8
|
+
release_note=$3
|
9
|
+
git_host=$4
|
10
|
+
|
11
|
+
if [ "$git_host" = "" ]; then
|
12
|
+
git_host="github.com"
|
13
|
+
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
14
|
+
fi
|
15
|
+
|
16
|
+
if [ "$git_user_id" = "" ]; then
|
17
|
+
git_user_id="GIT_USER_ID"
|
18
|
+
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
19
|
+
fi
|
20
|
+
|
21
|
+
if [ "$git_repo_id" = "" ]; then
|
22
|
+
git_repo_id="GIT_REPO_ID"
|
23
|
+
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
24
|
+
fi
|
25
|
+
|
26
|
+
if [ "$release_note" = "" ]; then
|
27
|
+
release_note="Minor update"
|
28
|
+
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
29
|
+
fi
|
30
|
+
|
31
|
+
# Initialize the local directory as a Git repository
|
32
|
+
git init
|
33
|
+
|
34
|
+
# Adds the files in the local repository and stages them for commit.
|
35
|
+
git add .
|
36
|
+
|
37
|
+
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
38
|
+
git commit -m "$release_note"
|
39
|
+
|
40
|
+
# Sets the new remote
|
41
|
+
git_remote=$(git remote)
|
42
|
+
if [ "$git_remote" = "" ]; then # git remote not defined
|
43
|
+
|
44
|
+
if [ "$GIT_TOKEN" = "" ]; then
|
45
|
+
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
46
|
+
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
47
|
+
else
|
48
|
+
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
49
|
+
fi
|
50
|
+
|
51
|
+
fi
|
52
|
+
|
53
|
+
git pull origin master
|
54
|
+
|
55
|
+
# Pushes (Forces) the changes in the local repository up to the remote repository
|
56
|
+
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
57
|
+
git push origin master 2>&1 | grep -v 'To https'
|
@@ -0,0 +1,347 @@
|
|
1
|
+
=begin
|
2
|
+
#DevCycle Bucketing API
|
3
|
+
|
4
|
+
#Documents the DevCycle Bucketing API which provides and API interface to User Bucketing and for generated SDKs.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.3.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'cgi'
|
14
|
+
|
15
|
+
module DevCycle
|
16
|
+
class DVCClient
|
17
|
+
attr_accessor :api_client
|
18
|
+
|
19
|
+
def initialize(api_client = ApiClient.default)
|
20
|
+
@api_client = api_client
|
21
|
+
end
|
22
|
+
|
23
|
+
def validate_model(model)
|
24
|
+
return if model.valid?
|
25
|
+
fail ArgumentError, "Invalid data provided for model #{model.class.name}: #{model.list_invalid_properties()}"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get all features by key for user data
|
29
|
+
# @param user_data [UserData]
|
30
|
+
# @param [Hash] opts the optional parameters
|
31
|
+
# @return [Hash<String, Feature>]
|
32
|
+
def get_features(user_data, opts = {})
|
33
|
+
if !user_data.is_a?(DevCycle::UserData)
|
34
|
+
fail ArgumentError, "user_data param must be an instance of UserData!"
|
35
|
+
end
|
36
|
+
|
37
|
+
validate_model(user_data)
|
38
|
+
|
39
|
+
data, _status_code, _headers = get_features_with_http_info(user_data, opts)
|
40
|
+
data
|
41
|
+
end
|
42
|
+
|
43
|
+
# Get all features by key for user data
|
44
|
+
# @param user_data [UserData]
|
45
|
+
# @param [Hash] opts the optional parameters
|
46
|
+
# @return [Array<(Hash<String, Feature>, Integer, Hash)>] Hash<String, Feature> data, response status code and response headers
|
47
|
+
def get_features_with_http_info(user_data, opts = {})
|
48
|
+
if @api_client.config.debugging
|
49
|
+
@api_client.config.logger.debug 'Calling API: DVCClient.get_features ...'
|
50
|
+
end
|
51
|
+
# verify the required parameter 'user_data' is set
|
52
|
+
if @api_client.config.client_side_validation && user_data.nil?
|
53
|
+
fail ArgumentError, "Missing the required parameter 'user_data' when calling DVCClient.get_features"
|
54
|
+
end
|
55
|
+
# resource path
|
56
|
+
local_var_path = '/v1/features'
|
57
|
+
|
58
|
+
# query parameters
|
59
|
+
query_params = opts[:query_params] || {}
|
60
|
+
|
61
|
+
# header parameters
|
62
|
+
header_params = opts[:header_params] || {}
|
63
|
+
# HTTP header 'Accept' (if needed)
|
64
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
65
|
+
# HTTP header 'Content-Type'
|
66
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
67
|
+
if !content_type.nil?
|
68
|
+
header_params['Content-Type'] = content_type
|
69
|
+
end
|
70
|
+
|
71
|
+
# form parameters
|
72
|
+
form_params = opts[:form_params] || {}
|
73
|
+
|
74
|
+
# http body (model)
|
75
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(user_data)
|
76
|
+
|
77
|
+
# return_type
|
78
|
+
return_type = opts[:debug_return_type] || 'Hash<String, Feature>'
|
79
|
+
|
80
|
+
# auth_names
|
81
|
+
auth_names = opts[:debug_auth_names] || ['bearerAuth']
|
82
|
+
|
83
|
+
new_options = opts.merge(
|
84
|
+
:operation => :"DVCClient.get_features",
|
85
|
+
:header_params => header_params,
|
86
|
+
:query_params => query_params,
|
87
|
+
:form_params => form_params,
|
88
|
+
:body => post_body,
|
89
|
+
:auth_names => auth_names,
|
90
|
+
:return_type => return_type
|
91
|
+
)
|
92
|
+
|
93
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
94
|
+
if @api_client.config.debugging
|
95
|
+
@api_client.config.logger.debug "API called: DVCClient#get_features\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
96
|
+
end
|
97
|
+
return data, status_code, headers
|
98
|
+
end
|
99
|
+
|
100
|
+
# Get variable by key for user data
|
101
|
+
# @param key [String] Variable key
|
102
|
+
# @param user_data [UserData]
|
103
|
+
# @param default Default value for variable if none is retrieved
|
104
|
+
# @param [Hash] opts the optional parameters
|
105
|
+
# @return [Variable]
|
106
|
+
def get_variable_by_key(key, user_data, default, opts = {})
|
107
|
+
if !user_data.is_a?(DevCycle::UserData)
|
108
|
+
fail ArgumentError, "user_data param must be an instance of UserData!"
|
109
|
+
end
|
110
|
+
|
111
|
+
validate_model(user_data)
|
112
|
+
|
113
|
+
data, _status_code, _headers = get_variable_by_key_with_http_info(key, user_data, default, opts)
|
114
|
+
data
|
115
|
+
end
|
116
|
+
|
117
|
+
# Get variable by key for user data
|
118
|
+
# @param key [String] Variable key
|
119
|
+
# @param user_data [UserData]
|
120
|
+
# @param default Default value for variable if none is retrieved
|
121
|
+
# @param [Hash] opts the optional parameters
|
122
|
+
# @return [Array<(Variable, Integer, Hash)>] Variable data, response status code and response headers
|
123
|
+
def get_variable_by_key_with_http_info(key, user_data, default, opts = {})
|
124
|
+
if @api_client.config.debugging
|
125
|
+
@api_client.config.logger.debug 'Calling API: DVCClient.get_variable_by_key ...'
|
126
|
+
end
|
127
|
+
# verify the required parameter 'key' is set
|
128
|
+
if @api_client.config.client_side_validation && key.nil?
|
129
|
+
fail ArgumentError, "Missing the required parameter 'key' when calling DVCClient.get_variable_by_key"
|
130
|
+
end
|
131
|
+
# verify the required parameter 'user_data' is set
|
132
|
+
if @api_client.config.client_side_validation && user_data.nil?
|
133
|
+
fail ArgumentError, "Missing the required parameter 'user_data' when calling DVCClient.get_variable_by_key"
|
134
|
+
end
|
135
|
+
# resource path
|
136
|
+
local_var_path = '/v1/variables/{key}'.sub('{' + 'key' + '}', CGI.escape(key.to_s))
|
137
|
+
|
138
|
+
# query parameters
|
139
|
+
query_params = opts[:query_params] || {}
|
140
|
+
|
141
|
+
# header parameters
|
142
|
+
header_params = opts[:header_params] || {}
|
143
|
+
# HTTP header 'Accept' (if needed)
|
144
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
145
|
+
# HTTP header 'Content-Type'
|
146
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
147
|
+
if !content_type.nil?
|
148
|
+
header_params['Content-Type'] = content_type
|
149
|
+
end
|
150
|
+
|
151
|
+
# form parameters
|
152
|
+
form_params = opts[:form_params] || {}
|
153
|
+
|
154
|
+
# http body (model)
|
155
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(user_data)
|
156
|
+
|
157
|
+
# return_type
|
158
|
+
return_type = opts[:debug_return_type] || 'Variable'
|
159
|
+
|
160
|
+
# auth_names
|
161
|
+
auth_names = opts[:debug_auth_names] || ['bearerAuth']
|
162
|
+
|
163
|
+
new_options = opts.merge(
|
164
|
+
:operation => :"DVCClient.get_variable_by_key",
|
165
|
+
:header_params => header_params,
|
166
|
+
:query_params => query_params,
|
167
|
+
:form_params => form_params,
|
168
|
+
:body => post_body,
|
169
|
+
:auth_names => auth_names,
|
170
|
+
:return_type => return_type
|
171
|
+
)
|
172
|
+
|
173
|
+
begin
|
174
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
175
|
+
if @api_client.config.debugging
|
176
|
+
@api_client.config.logger.debug "API called: DVCClient#get_variable_by_key\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
177
|
+
end
|
178
|
+
return data
|
179
|
+
rescue ApiError => error
|
180
|
+
if error.code != 404
|
181
|
+
@api_client.config.logger.error("Failed to retrieve variable value: #{error.message}")
|
182
|
+
end
|
183
|
+
|
184
|
+
return Variable.new(key: key, value: default)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
# Get all variables by key for user data
|
189
|
+
# @param user_data [UserData]
|
190
|
+
# @param [Hash] opts the optional parameters
|
191
|
+
# @return [Hash<String, Variable>]
|
192
|
+
def get_variables(user_data, opts = {})
|
193
|
+
if !user_data.is_a?(DevCycle::UserData)
|
194
|
+
fail ArgumentError, "user_data param must be an instance of UserData!"
|
195
|
+
end
|
196
|
+
|
197
|
+
validate_model(user_data)
|
198
|
+
|
199
|
+
data, _status_code, _headers = get_variables_with_http_info(user_data, opts)
|
200
|
+
data
|
201
|
+
end
|
202
|
+
|
203
|
+
# Get all variables by key for user data
|
204
|
+
# @param user_data [UserData]
|
205
|
+
# @param [Hash] opts the optional parameters
|
206
|
+
# @return [Array<(Hash<String, Variable>, Integer, Hash)>] Hash<String, Variable> data, response status code and response headers
|
207
|
+
def get_variables_with_http_info(user_data, opts = {})
|
208
|
+
if @api_client.config.debugging
|
209
|
+
@api_client.config.logger.debug 'Calling API: DVCClient.get_variables ...'
|
210
|
+
end
|
211
|
+
# verify the required parameter 'user_data' is set
|
212
|
+
if @api_client.config.client_side_validation && user_data.nil?
|
213
|
+
fail ArgumentError, "Missing the required parameter 'user_data' when calling DVCClient.get_variables"
|
214
|
+
end
|
215
|
+
# resource path
|
216
|
+
local_var_path = '/v1/variables'
|
217
|
+
|
218
|
+
# query parameters
|
219
|
+
query_params = opts[:query_params] || {}
|
220
|
+
|
221
|
+
# header parameters
|
222
|
+
header_params = opts[:header_params] || {}
|
223
|
+
# HTTP header 'Accept' (if needed)
|
224
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
225
|
+
# HTTP header 'Content-Type'
|
226
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
227
|
+
if !content_type.nil?
|
228
|
+
header_params['Content-Type'] = content_type
|
229
|
+
end
|
230
|
+
|
231
|
+
# form parameters
|
232
|
+
form_params = opts[:form_params] || {}
|
233
|
+
|
234
|
+
# http body (model)
|
235
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(user_data)
|
236
|
+
|
237
|
+
# return_type
|
238
|
+
return_type = opts[:debug_return_type] || 'Hash<String, Variable>'
|
239
|
+
|
240
|
+
# auth_names
|
241
|
+
auth_names = opts[:debug_auth_names] || ['bearerAuth']
|
242
|
+
|
243
|
+
new_options = opts.merge(
|
244
|
+
:operation => :"DVCClient.get_variables",
|
245
|
+
:header_params => header_params,
|
246
|
+
:query_params => query_params,
|
247
|
+
:form_params => form_params,
|
248
|
+
:body => post_body,
|
249
|
+
:auth_names => auth_names,
|
250
|
+
:return_type => return_type
|
251
|
+
)
|
252
|
+
|
253
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
254
|
+
if @api_client.config.debugging
|
255
|
+
@api_client.config.logger.debug "API called: DVCClient#get_variables\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
256
|
+
end
|
257
|
+
return data, status_code, headers
|
258
|
+
end
|
259
|
+
|
260
|
+
# Post events to DevCycle for user
|
261
|
+
# @param user_data_and_events_body [UserDataAndEventsBody]
|
262
|
+
# @param [Hash] opts the optional parameters
|
263
|
+
# @return [InlineResponse201]
|
264
|
+
def track_event(user_data, event_data, opts = {})
|
265
|
+
if !user_data.is_a?(DevCycle::UserData)
|
266
|
+
fail ArgumentError, "user_data param must be an instance of UserData!"
|
267
|
+
end
|
268
|
+
|
269
|
+
validate_model(user_data)
|
270
|
+
|
271
|
+
if !event_data.is_a?(DevCycle::Event)
|
272
|
+
fail ArgumentError, "event_data param must be an instance of Event!"
|
273
|
+
end
|
274
|
+
|
275
|
+
validate_model(event_data)
|
276
|
+
|
277
|
+
data, _status_code, _headers = track_event_with_http_info(user_data, event_data, opts)
|
278
|
+
data
|
279
|
+
end
|
280
|
+
|
281
|
+
# Post events to DevCycle for user
|
282
|
+
# @param user_data_and_events_body [UserDataAndEventsBody]
|
283
|
+
# @param [Hash] opts the optional parameters
|
284
|
+
# @return [Array<(InlineResponse201, Integer, Hash)>] InlineResponse201 data, response status code and response headers
|
285
|
+
def track_event_with_http_info(user_data, event_data, opts = {})
|
286
|
+
if @api_client.config.debugging
|
287
|
+
@api_client.config.logger.debug 'Calling API: DVCClient.post_events ...'
|
288
|
+
end
|
289
|
+
# verify the required parameter 'user_data_and_events_body' is set
|
290
|
+
if @api_client.config.client_side_validation && (user_data.nil? || event_data.nil?)
|
291
|
+
fail ArgumentError, "Missing the required parameter 'user_data_and_events_body' when calling DVCClient.post_events"
|
292
|
+
end
|
293
|
+
|
294
|
+
user_data_and_events_body = DevCycle::UserDataAndEventsBody.new({
|
295
|
+
user: user_data,
|
296
|
+
events: [event_data]
|
297
|
+
})
|
298
|
+
|
299
|
+
# resource path
|
300
|
+
local_var_path = '/v1/track'
|
301
|
+
|
302
|
+
# query parameters
|
303
|
+
query_params = opts[:query_params] || {}
|
304
|
+
|
305
|
+
# header parameters
|
306
|
+
header_params = opts[:header_params] || {}
|
307
|
+
# HTTP header 'Accept' (if needed)
|
308
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
309
|
+
# HTTP header 'Content-Type'
|
310
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
311
|
+
if !content_type.nil?
|
312
|
+
header_params['Content-Type'] = content_type
|
313
|
+
end
|
314
|
+
|
315
|
+
# form parameters
|
316
|
+
form_params = opts[:form_params] || {}
|
317
|
+
|
318
|
+
# http body (model)
|
319
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(user_data_and_events_body)
|
320
|
+
|
321
|
+
# if post_body.user.respond_to?(:to_hash)
|
322
|
+
# post_body.user = post_body.user.to_hash()
|
323
|
+
|
324
|
+
# return_type
|
325
|
+
return_type = opts[:debug_return_type] || 'InlineResponse201'
|
326
|
+
|
327
|
+
# auth_names
|
328
|
+
auth_names = opts[:debug_auth_names] || ['bearerAuth']
|
329
|
+
|
330
|
+
new_options = opts.merge(
|
331
|
+
:operation => :"DVCClient.post_events",
|
332
|
+
:header_params => header_params,
|
333
|
+
:query_params => query_params,
|
334
|
+
:form_params => form_params,
|
335
|
+
:body => post_body,
|
336
|
+
:auth_names => auth_names,
|
337
|
+
:return_type => return_type
|
338
|
+
)
|
339
|
+
|
340
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
341
|
+
if @api_client.config.debugging
|
342
|
+
@api_client.config.logger.debug "API called: DVCClient#post_events\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
343
|
+
end
|
344
|
+
return data, status_code, headers
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|