moesif_api 1.2.4 → 1.2.5
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f03579dcdef101fe45b4f839f3059c77e1079766a116db2d326f672f744fbe08
|
4
|
+
data.tar.gz: 00f963b0abb153bae0bb3c61d61cb7b0e309c7c8e9121cbc164e6e6288fa3582
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8952a4d79b418b0e71161df18b941726324aa8d9efa3b5889f0144f2c5a666e6bf8c40af27fc4e901925f552853e2b28b2f0ca549d0ada1e48f655eb8cfb0e1
|
7
|
+
data.tar.gz: b0fb53a6940026d7cdfcc7bf245bb705ef2591222ce8d5767fd593e909cdba170ee922cab2d64e7a3dca213f6c44e38120d5e973a6e2feb8ccf5a5106ff1fac7
|
@@ -132,7 +132,7 @@ module MoesifApi
|
|
132
132
|
end
|
133
133
|
|
134
134
|
|
135
|
-
# Update Data for a
|
135
|
+
# Update Data for multiple Users in a single batch (batch size must be less than 250kb)
|
136
136
|
# @param [list of UserModel] body Required parameter.
|
137
137
|
# @return void response from the API call
|
138
138
|
def update_users_batch(body)
|
@@ -211,5 +211,83 @@ module MoesifApi
|
|
211
211
|
# Return the response
|
212
212
|
return _response
|
213
213
|
end
|
214
|
+
|
215
|
+
# Add Data for a Single Company
|
216
|
+
# @param [CompanyModel] body Required parameter.
|
217
|
+
# @return void response from the API call
|
218
|
+
def add_company(body)
|
219
|
+
# the base uri for api requests
|
220
|
+
_query_builder = Configuration.base_uri.dup
|
221
|
+
|
222
|
+
# prepare query string for API call
|
223
|
+
_query_builder << '/v1/companies'
|
224
|
+
|
225
|
+
# validate and preprocess url
|
226
|
+
_query_url = APIHelper.clean_url _query_builder
|
227
|
+
|
228
|
+
# prepare headers
|
229
|
+
_headers = {
|
230
|
+
'content-type' => 'application/json; charset=utf-8',
|
231
|
+
'X-Moesif-Application-Id' => Configuration.application_id,
|
232
|
+
'User-Agent' => 'moesifapi-ruby/' + Configuration.version
|
233
|
+
}
|
234
|
+
|
235
|
+
# Create the HttpRequest object for the call
|
236
|
+
_request = @http_client.post _query_url, headers: _headers, parameters: body.to_json
|
237
|
+
|
238
|
+
# Call the on_before_request callback
|
239
|
+
@http_call_back.on_before_request(_request) if @http_call_back
|
240
|
+
|
241
|
+
# Invoke the API call and get the response
|
242
|
+
_response = @http_client.execute_as_string(_request)
|
243
|
+
|
244
|
+
# Wrap the request and response in an HttpContext object
|
245
|
+
_context = HttpContext.new(_request, _response)
|
246
|
+
|
247
|
+
# Call the on_after_response callback
|
248
|
+
@http_call_back.on_after_response(_context) if @http_call_back
|
249
|
+
|
250
|
+
# Global error handling using HTTP status codes.
|
251
|
+
validate_response(_context)
|
252
|
+
end
|
253
|
+
|
254
|
+
# Update Data for multiple Companies in a single batch (batch size must be less than 250kb)
|
255
|
+
# @param [list of CompanyModel] body Required parameter.
|
256
|
+
# @return void response from the API call
|
257
|
+
def add_companies_batch(body)
|
258
|
+
# the base uri for api requests
|
259
|
+
_query_builder = Configuration.base_uri.dup
|
260
|
+
|
261
|
+
# prepare query string for API call
|
262
|
+
_query_builder << '/v1/companies/batch'
|
263
|
+
|
264
|
+
# validate and preprocess url
|
265
|
+
_query_url = APIHelper.clean_url _query_builder
|
266
|
+
|
267
|
+
# prepare headers
|
268
|
+
_headers = {
|
269
|
+
'content-type' => 'application/json; charset=utf-8',
|
270
|
+
'X-Moesif-Application-Id' => Configuration.application_id,
|
271
|
+
'User-Agent' => 'moesifapi-ruby/' + Configuration.version
|
272
|
+
}
|
273
|
+
|
274
|
+
# Create the HttpRequest object for the call
|
275
|
+
_request = @http_client.post _query_url, headers: _headers, parameters: body.to_json
|
276
|
+
|
277
|
+
# Call the on_before_request callback
|
278
|
+
@http_call_back.on_before_request(_request) if @http_call_back
|
279
|
+
|
280
|
+
# Invoke the API call and get the response
|
281
|
+
_response = @http_client.execute_as_string(_request)
|
282
|
+
|
283
|
+
# Wrap the request and response in an HttpContext object
|
284
|
+
_context = HttpContext.new(_request, _response)
|
285
|
+
|
286
|
+
# Call the on_after_response callback
|
287
|
+
@http_call_back.on_after_response(_context) if @http_call_back
|
288
|
+
|
289
|
+
# Global error handling using HTTP status codes.
|
290
|
+
validate_response(_context)
|
291
|
+
end
|
214
292
|
end
|
215
293
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
module MoesifApi
|
5
|
+
class CompanyModel < BaseModel
|
6
|
+
|
7
|
+
# company id of the company
|
8
|
+
# @return [String]
|
9
|
+
attr_accessor :company_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 company with the company domain.
|
24
|
+
# @return [String]
|
25
|
+
attr_accessor :company_domain
|
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["company_id"] = "company_id"
|
36
|
+
@hash["modified_time"] = "modified_time"
|
37
|
+
@hash["ip_address"] = "ip_address"
|
38
|
+
@hash["session_token"] = "session_token"
|
39
|
+
@hash["company_domain"] = "company_domain"
|
40
|
+
@hash["metadata"] = "metadata"
|
41
|
+
end
|
42
|
+
@hash
|
43
|
+
end
|
44
|
+
|
45
|
+
def initialize(company_id = nil,
|
46
|
+
modified_time = nil,
|
47
|
+
ip_address = nil,
|
48
|
+
session_token = nil,
|
49
|
+
company_domain = nil,
|
50
|
+
metadata = nil)
|
51
|
+
@company_id = company_id
|
52
|
+
@modified_time = modified_time
|
53
|
+
@ip_address = ip_address
|
54
|
+
@session_token = session_token
|
55
|
+
@company_domain = company_domain
|
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
|
+
company_id = hash["company_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
|
+
company_domain = hash["company_domain"]
|
70
|
+
metadata = hash["metadata"]
|
71
|
+
|
72
|
+
# Create object from extracted values
|
73
|
+
UserModel.new(company_id,
|
74
|
+
modified_time,
|
75
|
+
ip_address,
|
76
|
+
session_token,
|
77
|
+
company_domain,
|
78
|
+
metadata)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/lib/moesif_api.rb
CHANGED
@@ -27,6 +27,7 @@ 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
29
|
require_relative 'moesif_api/models/user_model.rb'
|
30
|
+
require_relative 'moesif_api/models/company_model.rb'
|
30
31
|
|
31
32
|
# Controllers
|
32
33
|
require_relative 'moesif_api/controllers/base_controller.rb'
|
@@ -134,4 +134,44 @@ class ApiControllerTests < ControllerTestBase
|
|
134
134
|
assert_equal(@response_catcher.response.status_code, 200)
|
135
135
|
end
|
136
136
|
|
137
|
+
# Add Single Company via API
|
138
|
+
def test_add_company()
|
139
|
+
# Parameters for the API call
|
140
|
+
|
141
|
+
company_model = CompanyModel.new()
|
142
|
+
company_model.modified_time = Time.now.utc.iso8601
|
143
|
+
company_model.company_id = "1"
|
144
|
+
|
145
|
+
# Perform the API call through the SDK function
|
146
|
+
self.class.controller.add_company(company_model)
|
147
|
+
|
148
|
+
# Test response code
|
149
|
+
assert_equal(@response_catcher.response.status_code, 201)
|
150
|
+
end
|
151
|
+
|
152
|
+
# Add Batched Companies via Ingestion API
|
153
|
+
def test_add_companies_batch()
|
154
|
+
# Parameters for the API call
|
155
|
+
|
156
|
+
company_model_A = CompanyModel.new()
|
157
|
+
company_model_A.modified_time = Time.now.utc.iso8601
|
158
|
+
company_model_A.company_id = "1"
|
159
|
+
|
160
|
+
company_model_B = CompanyModel.new()
|
161
|
+
company_model_B.modified_time = Time.now.utc.iso8601
|
162
|
+
company_model_B.company_id = "2"
|
163
|
+
company_model_B.metadata = JSON.parse('{'\
|
164
|
+
'"string_field": "value_1",'\
|
165
|
+
'"name": "ruby api user",'\
|
166
|
+
'"custom": "testdata"'\
|
167
|
+
'}')
|
168
|
+
|
169
|
+
companies = [company_model_A, company_model_B]
|
170
|
+
|
171
|
+
# Perform the API call through the SDK function
|
172
|
+
self.class.controller.add_companies_batch(companies)
|
173
|
+
|
174
|
+
# Test response code
|
175
|
+
assert_equal(@response_catcher.response.status_code, 201)
|
176
|
+
end
|
137
177
|
end
|
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.2.
|
4
|
+
version: 1.2.5
|
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: 2019-02-
|
12
|
+
date: 2019-02-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: test-unit
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- lib/moesif_api/http/http_response.rb
|
79
79
|
- lib/moesif_api/http/unirest_client.rb
|
80
80
|
- lib/moesif_api/models/base_model.rb
|
81
|
+
- lib/moesif_api/models/company_model.rb
|
81
82
|
- lib/moesif_api/models/event_model.rb
|
82
83
|
- lib/moesif_api/models/event_request_model.rb
|
83
84
|
- lib/moesif_api/models/event_response_model.rb
|