openapi_iplocation 1.0.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.
package/README.md ADDED
@@ -0,0 +1,141 @@
1
+ # openapi_iplocation
2
+
3
+ OpenapiIplocation - JavaScript client for openapi_iplocation
4
+ OpenAPI v3 specification and a set of generated API clients for iplocation.net
5
+ This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
6
+
7
+ - API version: 1.0.0
8
+ - Package version: 1.0.0
9
+ - Generator version: 7.6.0
10
+ - Build package: org.openapitools.codegen.languages.JavascriptClientCodegen
11
+ For more information, please visit [https://github.com/oapicf/openapi-iplocation](https://github.com/oapicf/openapi-iplocation)
12
+
13
+ ## Installation
14
+
15
+ ### For [Node.js](https://nodejs.org/)
16
+
17
+ #### npm
18
+
19
+ To publish the library as a [npm](https://www.npmjs.com/), please follow the procedure in ["Publishing npm packages"](https://docs.npmjs.com/getting-started/publishing-npm-packages).
20
+
21
+ Then install it via:
22
+
23
+ ```shell
24
+ npm install openapi_iplocation --save
25
+ ```
26
+
27
+ Finally, you need to build the module:
28
+
29
+ ```shell
30
+ npm run build
31
+ ```
32
+
33
+ ##### Local development
34
+
35
+ To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing `package.json` (and this README). Let's call this `JAVASCRIPT_CLIENT_DIR`. Then run:
36
+
37
+ ```shell
38
+ npm install
39
+ ```
40
+
41
+ Next, [link](https://docs.npmjs.com/cli/link) it globally in npm with the following, also from `JAVASCRIPT_CLIENT_DIR`:
42
+
43
+ ```shell
44
+ npm link
45
+ ```
46
+
47
+ To use the link you just defined in your project, switch to the directory you want to use your openapi_iplocation from, and run:
48
+
49
+ ```shell
50
+ npm link /path/to/<JAVASCRIPT_CLIENT_DIR>
51
+ ```
52
+
53
+ Finally, you need to build the module:
54
+
55
+ ```shell
56
+ npm run build
57
+ ```
58
+
59
+ #### git
60
+
61
+ If the library is hosted at a git repository, e.g.https://github.com/oapicf/openapi-iplocation
62
+ then install it via:
63
+
64
+ ```shell
65
+ npm install oapicf/openapi-iplocation --save
66
+ ```
67
+
68
+ ### For browser
69
+
70
+ The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following
71
+ the above steps with Node.js and installing browserify with `npm install -g browserify`,
72
+ perform the following (assuming *main.js* is your entry file):
73
+
74
+ ```shell
75
+ browserify main.js > bundle.js
76
+ ```
77
+
78
+ Then include *bundle.js* in the HTML pages.
79
+
80
+ ### Webpack Configuration
81
+
82
+ Using Webpack you may encounter the following error: "Module not found: Error:
83
+ Cannot resolve module", most certainly you should disable AMD loader. Add/merge
84
+ the following section to your webpack config:
85
+
86
+ ```javascript
87
+ module: {
88
+ rules: [
89
+ {
90
+ parser: {
91
+ amd: false
92
+ }
93
+ }
94
+ ]
95
+ }
96
+ ```
97
+
98
+ ## Getting Started
99
+
100
+ Please follow the [installation](#installation) instruction and execute the following JS code:
101
+
102
+ ```javascript
103
+ var OpenapiIplocation = require('openapi_iplocation');
104
+
105
+
106
+ var api = new OpenapiIplocation.DefaultApi()
107
+ var ip = "ip_example"; // {String} An IPv4 or IPv6 address that you would like to lookup.
108
+ var opts = {
109
+ 'format': "format_example", // {String} Output format, the following formats are supported: plain xml json jsonp php csv serialized
110
+ 'delimiter': "delimiter_example" // {String} Delimiter between proxies. Can be used only with format plain. The following types are supported: 1 for \"\\n\", 2 for \"<br>\".
111
+ };
112
+ var callback = function(error, data, response) {
113
+ if (error) {
114
+ console.error(error);
115
+ } else {
116
+ console.log('API called successfully. Returned data: ' + data);
117
+ }
118
+ };
119
+ api.rootGet(ip, opts, callback);
120
+
121
+ ```
122
+
123
+ ## Documentation for API Endpoints
124
+
125
+ All URIs are relative to *https://api.iplocation.net*
126
+
127
+ Class | Method | HTTP request | Description
128
+ ------------ | ------------- | ------------- | -------------
129
+ *OpenapiIplocation.DefaultApi* | [**rootGet**](docs/DefaultApi.md#rootGet) | **GET** / | Get geolocation of an IP address
130
+
131
+
132
+ ## Documentation for Models
133
+
134
+ - [OpenapiIplocation.Get200Response](docs/Get200Response.md)
135
+ - [OpenapiIplocation.Get400Response](docs/Get400Response.md)
136
+
137
+
138
+ ## Documentation for Authorization
139
+
140
+ Endpoints do not require authorization.
141
+
@@ -0,0 +1,695 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _superagent = _interopRequireDefault(require("superagent"));
8
+ var _querystring = _interopRequireDefault(require("querystring"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
11
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
12
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
13
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
14
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
15
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /**
16
+ * iplocation.net API
17
+ * OpenAPI v3 specification and a set of generated API clients for iplocation.net
18
+ *
19
+ * The version of the OpenAPI document: 1.0.0
20
+ * Contact: blah+oapicf@cliffano.com
21
+ *
22
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
23
+ * https://openapi-generator.tech
24
+ * Do not edit the class manually.
25
+ *
26
+ */
27
+ /**
28
+ * @module ApiClient
29
+ * @version 1.0.0
30
+ */
31
+ /**
32
+ * Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an
33
+ * application to use this class directly - the *Api and model classes provide the public API for the service. The
34
+ * contents of this file should be regarded as internal but are documented for completeness.
35
+ * @alias module:ApiClient
36
+ * @class
37
+ */
38
+ var ApiClient = /*#__PURE__*/function () {
39
+ /**
40
+ * The base URL against which to resolve every API call's (relative) path.
41
+ * Overrides the default value set in spec file if present
42
+ * @param {String} basePath
43
+ */
44
+ function ApiClient() {
45
+ var basePath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'https://api.iplocation.net';
46
+ _classCallCheck(this, ApiClient);
47
+ /**
48
+ * The base URL against which to resolve every API call's (relative) path.
49
+ * @type {String}
50
+ * @default https://api.iplocation.net
51
+ */
52
+ this.basePath = basePath.replace(/\/+$/, '');
53
+
54
+ /**
55
+ * The authentication methods to be included for all API calls.
56
+ * @type {Array.<String>}
57
+ */
58
+ this.authentications = {};
59
+
60
+ /**
61
+ * The default HTTP headers to be included for all API calls.
62
+ * @type {Array.<String>}
63
+ * @default {}
64
+ */
65
+ this.defaultHeaders = {
66
+ 'User-Agent': 'OpenAPI-Generator/1.0.0/Javascript'
67
+ };
68
+
69
+ /**
70
+ * The default HTTP timeout for all API calls.
71
+ * @type {Number}
72
+ * @default 60000
73
+ */
74
+ this.timeout = 60000;
75
+
76
+ /**
77
+ * If set to false an additional timestamp parameter is added to all API GET calls to
78
+ * prevent browser caching
79
+ * @type {Boolean}
80
+ * @default true
81
+ */
82
+ this.cache = true;
83
+
84
+ /**
85
+ * If set to true, the client will save the cookies from each server
86
+ * response, and return them in the next request.
87
+ * @default false
88
+ */
89
+ this.enableCookies = false;
90
+
91
+ /*
92
+ * Used to save and return cookies in a node.js (non-browser) setting,
93
+ * if this.enableCookies is set to true.
94
+ */
95
+ if (typeof window === 'undefined') {
96
+ this.agent = new _superagent["default"].agent();
97
+ }
98
+
99
+ /*
100
+ * Allow user to override superagent agent
101
+ */
102
+ this.requestAgent = null;
103
+
104
+ /*
105
+ * Allow user to add superagent plugins
106
+ */
107
+ this.plugins = null;
108
+ }
109
+
110
+ /**
111
+ * Returns a string representation for an actual parameter.
112
+ * @param param The actual parameter.
113
+ * @returns {String} The string representation of <code>param</code>.
114
+ */
115
+ return _createClass(ApiClient, [{
116
+ key: "paramToString",
117
+ value: function paramToString(param) {
118
+ if (param == undefined || param == null) {
119
+ return '';
120
+ }
121
+ if (param instanceof Date) {
122
+ return param.toJSON();
123
+ }
124
+ if (ApiClient.canBeJsonified(param)) {
125
+ return JSON.stringify(param);
126
+ }
127
+ return param.toString();
128
+ }
129
+
130
+ /**
131
+ * Returns a boolean indicating if the parameter could be JSON.stringified
132
+ * @param param The actual parameter
133
+ * @returns {Boolean} Flag indicating if <code>param</code> can be JSON.stringified
134
+ */
135
+ }, {
136
+ key: "buildUrl",
137
+ value:
138
+ /**
139
+ * Builds full URL by appending the given path to the base URL and replacing path parameter place-holders with parameter values.
140
+ * NOTE: query parameters are not handled here.
141
+ * @param {String} path The path to append to the base URL.
142
+ * @param {Object} pathParams The parameter values to append.
143
+ * @param {String} apiBasePath Base path defined in the path, operation level to override the default one
144
+ * @returns {String} The encoded path with parameter values substituted.
145
+ */
146
+ function buildUrl(path, pathParams, apiBasePath) {
147
+ var _this = this;
148
+ if (!path.match(/^\//)) {
149
+ path = '/' + path;
150
+ }
151
+ var url = this.basePath + path;
152
+
153
+ // use API (operation, path) base path if defined
154
+ if (apiBasePath !== null && apiBasePath !== undefined) {
155
+ url = apiBasePath + path;
156
+ }
157
+ url = url.replace(/\{([\w-\.#]+)\}/g, function (fullMatch, key) {
158
+ var value;
159
+ if (pathParams.hasOwnProperty(key)) {
160
+ value = _this.paramToString(pathParams[key]);
161
+ } else {
162
+ value = fullMatch;
163
+ }
164
+ return encodeURIComponent(value);
165
+ });
166
+ return url;
167
+ }
168
+
169
+ /**
170
+ * Checks whether the given content type represents JSON.<br>
171
+ * JSON content type examples:<br>
172
+ * <ul>
173
+ * <li>application/json</li>
174
+ * <li>application/json; charset=UTF8</li>
175
+ * <li>APPLICATION/JSON</li>
176
+ * </ul>
177
+ * @param {String} contentType The MIME content type to check.
178
+ * @returns {Boolean} <code>true</code> if <code>contentType</code> represents JSON, otherwise <code>false</code>.
179
+ */
180
+ }, {
181
+ key: "isJsonMime",
182
+ value: function isJsonMime(contentType) {
183
+ return Boolean(contentType != null && contentType.match(/^application\/json(;.*)?$/i));
184
+ }
185
+
186
+ /**
187
+ * Chooses a content type from the given array, with JSON preferred; i.e. return JSON if included, otherwise return the first.
188
+ * @param {Array.<String>} contentTypes
189
+ * @returns {String} The chosen content type, preferring JSON.
190
+ */
191
+ }, {
192
+ key: "jsonPreferredMime",
193
+ value: function jsonPreferredMime(contentTypes) {
194
+ for (var i = 0; i < contentTypes.length; i++) {
195
+ if (this.isJsonMime(contentTypes[i])) {
196
+ return contentTypes[i];
197
+ }
198
+ }
199
+ return contentTypes[0];
200
+ }
201
+
202
+ /**
203
+ * Checks whether the given parameter value represents file-like content.
204
+ * @param param The parameter to check.
205
+ * @returns {Boolean} <code>true</code> if <code>param</code> represents a file.
206
+ */
207
+ }, {
208
+ key: "isFileParam",
209
+ value: function isFileParam(param) {
210
+ // fs.ReadStream in Node.js and Electron (but not in runtime like browserify)
211
+ if (typeof require === 'function') {
212
+ var fs;
213
+ try {
214
+ fs = require('fs');
215
+ } catch (err) {}
216
+ if (fs && fs.ReadStream && param instanceof fs.ReadStream) {
217
+ return true;
218
+ }
219
+ }
220
+
221
+ // Buffer in Node.js
222
+ if (typeof Buffer === 'function' && param instanceof Buffer) {
223
+ return true;
224
+ }
225
+
226
+ // Blob in browser
227
+ if (typeof Blob === 'function' && param instanceof Blob) {
228
+ return true;
229
+ }
230
+
231
+ // File in browser (it seems File object is also instance of Blob, but keep this for safe)
232
+ if (typeof File === 'function' && param instanceof File) {
233
+ return true;
234
+ }
235
+ return false;
236
+ }
237
+
238
+ /**
239
+ * Normalizes parameter values:
240
+ * <ul>
241
+ * <li>remove nils</li>
242
+ * <li>keep files and arrays</li>
243
+ * <li>format to string with `paramToString` for other cases</li>
244
+ * </ul>
245
+ * @param {Object.<String, Object>} params The parameters as object properties.
246
+ * @returns {Object.<String, Object>} normalized parameters.
247
+ */
248
+ }, {
249
+ key: "normalizeParams",
250
+ value: function normalizeParams(params) {
251
+ var newParams = {};
252
+ for (var key in params) {
253
+ if (params.hasOwnProperty(key) && params[key] != undefined && params[key] != null) {
254
+ var value = params[key];
255
+ if (this.isFileParam(value) || Array.isArray(value)) {
256
+ newParams[key] = value;
257
+ } else {
258
+ newParams[key] = this.paramToString(value);
259
+ }
260
+ }
261
+ }
262
+ return newParams;
263
+ }
264
+
265
+ /**
266
+ * Builds a string representation of an array-type actual parameter, according to the given collection format.
267
+ * @param {Array} param An array parameter.
268
+ * @param {module:ApiClient.CollectionFormatEnum} collectionFormat The array element separator strategy.
269
+ * @returns {String|Array} A string representation of the supplied collection, using the specified delimiter. Returns
270
+ * <code>param</code> as is if <code>collectionFormat</code> is <code>multi</code>.
271
+ */
272
+ }, {
273
+ key: "buildCollectionParam",
274
+ value: function buildCollectionParam(param, collectionFormat) {
275
+ if (param == null) {
276
+ return null;
277
+ }
278
+ switch (collectionFormat) {
279
+ case 'csv':
280
+ return param.map(this.paramToString, this).join(',');
281
+ case 'ssv':
282
+ return param.map(this.paramToString, this).join(' ');
283
+ case 'tsv':
284
+ return param.map(this.paramToString, this).join('\t');
285
+ case 'pipes':
286
+ return param.map(this.paramToString, this).join('|');
287
+ case 'multi':
288
+ //return the array directly as SuperAgent will handle it as expected
289
+ return param.map(this.paramToString, this);
290
+ case 'passthrough':
291
+ return param;
292
+ default:
293
+ throw new Error('Unknown collection format: ' + collectionFormat);
294
+ }
295
+ }
296
+
297
+ /**
298
+ * Applies authentication headers to the request.
299
+ * @param {Object} request The request object created by a <code>superagent()</code> call.
300
+ * @param {Array.<String>} authNames An array of authentication method names.
301
+ */
302
+ }, {
303
+ key: "applyAuthToRequest",
304
+ value: function applyAuthToRequest(request, authNames) {
305
+ var _this2 = this;
306
+ authNames.forEach(function (authName) {
307
+ var auth = _this2.authentications[authName];
308
+ switch (auth.type) {
309
+ case 'basic':
310
+ if (auth.username || auth.password) {
311
+ request.auth(auth.username || '', auth.password || '');
312
+ }
313
+ break;
314
+ case 'bearer':
315
+ if (auth.accessToken) {
316
+ var localVarBearerToken = typeof auth.accessToken === 'function' ? auth.accessToken() : auth.accessToken;
317
+ request.set({
318
+ 'Authorization': 'Bearer ' + localVarBearerToken
319
+ });
320
+ }
321
+ break;
322
+ case 'apiKey':
323
+ if (auth.apiKey) {
324
+ var data = {};
325
+ if (auth.apiKeyPrefix) {
326
+ data[auth.name] = auth.apiKeyPrefix + ' ' + auth.apiKey;
327
+ } else {
328
+ data[auth.name] = auth.apiKey;
329
+ }
330
+ if (auth['in'] === 'header') {
331
+ request.set(data);
332
+ } else {
333
+ request.query(data);
334
+ }
335
+ }
336
+ break;
337
+ case 'oauth2':
338
+ if (auth.accessToken) {
339
+ request.set({
340
+ 'Authorization': 'Bearer ' + auth.accessToken
341
+ });
342
+ }
343
+ break;
344
+ default:
345
+ throw new Error('Unknown authentication type: ' + auth.type);
346
+ }
347
+ });
348
+ }
349
+
350
+ /**
351
+ * Deserializes an HTTP response body into a value of the specified type.
352
+ * @param {Object} response A SuperAgent response object.
353
+ * @param {(String|Array.<String>|Object.<String, Object>|Function)} returnType The type to return. Pass a string for simple types
354
+ * or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
355
+ * return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
356
+ * all properties on <code>data<code> will be converted to this type.
357
+ * @returns A value of the specified type.
358
+ */
359
+ }, {
360
+ key: "deserialize",
361
+ value: function deserialize(response, returnType) {
362
+ if (response == null || returnType == null || response.status == 204) {
363
+ return null;
364
+ }
365
+
366
+ // Rely on SuperAgent for parsing response body.
367
+ // See http://visionmedia.github.io/superagent/#parsing-response-bodies
368
+ var data = response.body;
369
+ if (data == null || _typeof(data) === 'object' && typeof data.length === 'undefined' && !Object.keys(data).length) {
370
+ // SuperAgent does not always produce a body; use the unparsed response as a fallback
371
+ data = response.text;
372
+ }
373
+ return ApiClient.convertToType(data, returnType);
374
+ }
375
+
376
+ /**
377
+ * Callback function to receive the result of the operation.
378
+ * @callback module:ApiClient~callApiCallback
379
+ * @param {String} error Error message, if any.
380
+ * @param data The data returned by the service call.
381
+ * @param {String} response The complete HTTP response.
382
+ */
383
+
384
+ /**
385
+ * Invokes the REST service using the supplied settings and parameters.
386
+ * @param {String} path The base URL to invoke.
387
+ * @param {String} httpMethod The HTTP method to use.
388
+ * @param {Object.<String, String>} pathParams A map of path parameters and their values.
389
+ * @param {Object.<String, Object>} queryParams A map of query parameters and their values.
390
+ * @param {Object.<String, Object>} headerParams A map of header parameters and their values.
391
+ * @param {Object.<String, Object>} formParams A map of form parameters and their values.
392
+ * @param {Object} bodyParam The value to pass as the request body.
393
+ * @param {Array.<String>} authNames An array of authentication type names.
394
+ * @param {Array.<String>} contentTypes An array of request MIME types.
395
+ * @param {Array.<String>} accepts An array of acceptable response MIME types.
396
+ * @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
397
+ * constructor for a complex type.
398
+ * @param {String} apiBasePath base path defined in the operation/path level to override the default one
399
+ * @param {module:ApiClient~callApiCallback} callback The callback function.
400
+ * @returns {Object} The SuperAgent request object.
401
+ */
402
+ }, {
403
+ key: "callApi",
404
+ value: function callApi(path, httpMethod, pathParams, queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts, returnType, apiBasePath, callback) {
405
+ var _this3 = this;
406
+ var url = this.buildUrl(path, pathParams, apiBasePath);
407
+ var request = (0, _superagent["default"])(httpMethod, url);
408
+ if (this.plugins !== null) {
409
+ for (var index in this.plugins) {
410
+ if (this.plugins.hasOwnProperty(index)) {
411
+ request.use(this.plugins[index]);
412
+ }
413
+ }
414
+ }
415
+
416
+ // apply authentications
417
+ this.applyAuthToRequest(request, authNames);
418
+
419
+ // set query parameters
420
+ if (httpMethod.toUpperCase() === 'GET' && this.cache === false) {
421
+ queryParams['_'] = new Date().getTime();
422
+ }
423
+ request.query(this.normalizeParams(queryParams));
424
+
425
+ // set header parameters
426
+ request.set(this.defaultHeaders).set(this.normalizeParams(headerParams));
427
+
428
+ // set requestAgent if it is set by user
429
+ if (this.requestAgent) {
430
+ request.agent(this.requestAgent);
431
+ }
432
+
433
+ // set request timeout
434
+ request.timeout(this.timeout);
435
+ var contentType = this.jsonPreferredMime(contentTypes);
436
+ if (contentType) {
437
+ // Issue with superagent and multipart/form-data (https://github.com/visionmedia/superagent/issues/746)
438
+ if (contentType != 'multipart/form-data') {
439
+ request.type(contentType);
440
+ }
441
+ }
442
+ if (contentType === 'application/x-www-form-urlencoded') {
443
+ request.send(_querystring["default"].stringify(this.normalizeParams(formParams)));
444
+ } else if (contentType == 'multipart/form-data') {
445
+ var _formParams = this.normalizeParams(formParams);
446
+ for (var key in _formParams) {
447
+ if (_formParams.hasOwnProperty(key)) {
448
+ var _formParamsValue = _formParams[key];
449
+ if (this.isFileParam(_formParamsValue)) {
450
+ // file field
451
+ request.attach(key, _formParamsValue);
452
+ } else if (Array.isArray(_formParamsValue) && _formParamsValue.length && this.isFileParam(_formParamsValue[0])) {
453
+ // multiple files
454
+ _formParamsValue.forEach(function (file) {
455
+ return request.attach(key, file);
456
+ });
457
+ } else {
458
+ request.field(key, _formParamsValue);
459
+ }
460
+ }
461
+ }
462
+ } else if (bodyParam !== null && bodyParam !== undefined) {
463
+ if (!request.header['Content-Type']) {
464
+ request.type('application/json');
465
+ }
466
+ request.send(bodyParam);
467
+ }
468
+ var accept = this.jsonPreferredMime(accepts);
469
+ if (accept) {
470
+ request.accept(accept);
471
+ }
472
+ if (returnType === 'Blob') {
473
+ request.responseType('blob');
474
+ } else if (returnType === 'String') {
475
+ request.responseType('text');
476
+ }
477
+
478
+ // Attach previously saved cookies, if enabled
479
+ if (this.enableCookies) {
480
+ if (typeof window === 'undefined') {
481
+ this.agent._attachCookies(request);
482
+ } else {
483
+ request.withCredentials();
484
+ }
485
+ }
486
+ request.end(function (error, response) {
487
+ if (callback) {
488
+ var data = null;
489
+ if (!error) {
490
+ try {
491
+ data = _this3.deserialize(response, returnType);
492
+ if (_this3.enableCookies && typeof window === 'undefined') {
493
+ _this3.agent._saveCookies(response);
494
+ }
495
+ } catch (err) {
496
+ error = err;
497
+ }
498
+ }
499
+ callback(error, data, response);
500
+ }
501
+ });
502
+ return request;
503
+ }
504
+
505
+ /**
506
+ * Parses an ISO-8601 string representation or epoch representation of a date value.
507
+ * @param {String} str The date value as a string.
508
+ * @returns {Date} The parsed date object.
509
+ */
510
+ }, {
511
+ key: "hostSettings",
512
+ value:
513
+ /**
514
+ * Gets an array of host settings
515
+ * @returns An array of host settings
516
+ */
517
+ function hostSettings() {
518
+ return [{
519
+ 'url': "https://api.iplocation.net",
520
+ 'description': "No description provided"
521
+ }];
522
+ }
523
+ }, {
524
+ key: "getBasePathFromSettings",
525
+ value: function getBasePathFromSettings(index) {
526
+ var variables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
527
+ var servers = this.hostSettings();
528
+
529
+ // check array index out of bound
530
+ if (index < 0 || index >= servers.length) {
531
+ throw new Error("Invalid index " + index + " when selecting the host settings. Must be less than " + servers.length);
532
+ }
533
+ var server = servers[index];
534
+ var url = server['url'];
535
+
536
+ // go through variable and assign a value
537
+ for (var variable_name in server['variables']) {
538
+ if (variable_name in variables) {
539
+ var variable = server['variables'][variable_name];
540
+ if (!('enum_values' in variable) || variable['enum_values'].includes(variables[variable_name])) {
541
+ url = url.replace("{" + variable_name + "}", variables[variable_name]);
542
+ } else {
543
+ throw new Error("The variable `" + variable_name + "` in the host URL has invalid value " + variables[variable_name] + ". Must be " + server['variables'][variable_name]['enum_values'] + ".");
544
+ }
545
+ } else {
546
+ // use default value
547
+ url = url.replace("{" + variable_name + "}", server['variables'][variable_name]['default_value']);
548
+ }
549
+ }
550
+ return url;
551
+ }
552
+
553
+ /**
554
+ * Constructs a new map or array model from REST data.
555
+ * @param data {Object|Array} The REST data.
556
+ * @param obj {Object|Array} The target object or array.
557
+ */
558
+ }], [{
559
+ key: "canBeJsonified",
560
+ value: function canBeJsonified(str) {
561
+ if (typeof str !== 'string' && _typeof(str) !== 'object') return false;
562
+ try {
563
+ var type = str.toString();
564
+ return type === '[object Object]' || type === '[object Array]';
565
+ } catch (err) {
566
+ return false;
567
+ }
568
+ }
569
+ }, {
570
+ key: "parseDate",
571
+ value: function parseDate(str) {
572
+ if (isNaN(str)) {
573
+ return new Date(str.replace(/(\d)(T)(\d)/i, '$1 $3'));
574
+ }
575
+ return new Date(+str);
576
+ }
577
+
578
+ /**
579
+ * Converts a value to the specified type.
580
+ * @param {(String|Object)} data The data to convert, as a string or object.
581
+ * @param {(String|Array.<String>|Object.<String, Object>|Function)} type The type to return. Pass a string for simple types
582
+ * or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
583
+ * return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
584
+ * all properties on <code>data<code> will be converted to this type.
585
+ * @returns An instance of the specified type or null or undefined if data is null or undefined.
586
+ */
587
+ }, {
588
+ key: "convertToType",
589
+ value: function convertToType(data, type) {
590
+ if (data === null || data === undefined) return data;
591
+ switch (type) {
592
+ case 'Boolean':
593
+ return Boolean(data);
594
+ case 'Integer':
595
+ return parseInt(data, 10);
596
+ case 'Number':
597
+ return parseFloat(data);
598
+ case 'String':
599
+ return String(data);
600
+ case 'Date':
601
+ return ApiClient.parseDate(String(data));
602
+ case 'Blob':
603
+ return data;
604
+ default:
605
+ if (type === Object) {
606
+ // generic object, return directly
607
+ return data;
608
+ } else if (typeof type.constructFromObject === 'function') {
609
+ // for model type like User and enum class
610
+ return type.constructFromObject(data);
611
+ } else if (Array.isArray(type)) {
612
+ // for array type like: ['String']
613
+ var itemType = type[0];
614
+ return data.map(function (item) {
615
+ return ApiClient.convertToType(item, itemType);
616
+ });
617
+ } else if (_typeof(type) === 'object') {
618
+ // for plain object type like: {'String': 'Integer'}
619
+ var keyType, valueType;
620
+ for (var k in type) {
621
+ if (type.hasOwnProperty(k)) {
622
+ keyType = k;
623
+ valueType = type[k];
624
+ break;
625
+ }
626
+ }
627
+ var result = {};
628
+ for (var k in data) {
629
+ if (data.hasOwnProperty(k)) {
630
+ var key = ApiClient.convertToType(k, keyType);
631
+ var value = ApiClient.convertToType(data[k], valueType);
632
+ result[key] = value;
633
+ }
634
+ }
635
+ return result;
636
+ } else {
637
+ // for unknown type, return the data directly
638
+ return data;
639
+ }
640
+ }
641
+ }
642
+ }, {
643
+ key: "constructFromObject",
644
+ value: function constructFromObject(data, obj, itemType) {
645
+ if (Array.isArray(data)) {
646
+ for (var i = 0; i < data.length; i++) {
647
+ if (data.hasOwnProperty(i)) obj[i] = ApiClient.convertToType(data[i], itemType);
648
+ }
649
+ } else {
650
+ for (var k in data) {
651
+ if (data.hasOwnProperty(k)) obj[k] = ApiClient.convertToType(data[k], itemType);
652
+ }
653
+ }
654
+ }
655
+ }]);
656
+ }();
657
+ /**
658
+ * Enumeration of collection format separator strategies.
659
+ * @enum {String}
660
+ * @readonly
661
+ */
662
+ ApiClient.CollectionFormatEnum = {
663
+ /**
664
+ * Comma-separated values. Value: <code>csv</code>
665
+ * @const
666
+ */
667
+ CSV: ',',
668
+ /**
669
+ * Space-separated values. Value: <code>ssv</code>
670
+ * @const
671
+ */
672
+ SSV: ' ',
673
+ /**
674
+ * Tab-separated values. Value: <code>tsv</code>
675
+ * @const
676
+ */
677
+ TSV: '\t',
678
+ /**
679
+ * Pipe(|)-separated values. Value: <code>pipes</code>
680
+ * @const
681
+ */
682
+ PIPES: '|',
683
+ /**
684
+ * Native array. Value: <code>multi</code>
685
+ * @const
686
+ */
687
+ MULTI: 'multi'
688
+ };
689
+
690
+ /**
691
+ * The default API client implementation.
692
+ * @type {module:ApiClient}
693
+ */
694
+ ApiClient.instance = new ApiClient();
695
+ var _default = exports["default"] = ApiClient;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _ApiClient = _interopRequireDefault(require("../ApiClient"));
8
+ var _Get200Response = _interopRequireDefault(require("../model/Get200Response"));
9
+ var _Get400Response = _interopRequireDefault(require("../model/Get400Response"));
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
12
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
13
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
14
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
16
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /**
17
+ * iplocation.net API
18
+ * OpenAPI v3 specification and a set of generated API clients for iplocation.net
19
+ *
20
+ * The version of the OpenAPI document: 1.0.0
21
+ * Contact: blah+oapicf@cliffano.com
22
+ *
23
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
24
+ * https://openapi-generator.tech
25
+ * Do not edit the class manually.
26
+ *
27
+ */
28
+ /**
29
+ * Default service.
30
+ * @module api/DefaultApi
31
+ * @version 1.0.0
32
+ */
33
+ var DefaultApi = exports["default"] = /*#__PURE__*/function () {
34
+ /**
35
+ * Constructs a new DefaultApi.
36
+ * @alias module:api/DefaultApi
37
+ * @class
38
+ * @param {module:ApiClient} [apiClient] Optional API client implementation to use,
39
+ * default to {@link module:ApiClient#instance} if unspecified.
40
+ */
41
+ function DefaultApi(apiClient) {
42
+ _classCallCheck(this, DefaultApi);
43
+ this.apiClient = apiClient || _ApiClient["default"].instance;
44
+ }
45
+
46
+ /**
47
+ * Callback function to receive the result of the rootGet operation.
48
+ * @callback module:api/DefaultApi~rootGetCallback
49
+ * @param {String} error Error message, if any.
50
+ * @param {module:model/Get200Response} data The data returned by the service call.
51
+ * @param {String} response The complete HTTP response.
52
+ */
53
+
54
+ /**
55
+ * Get geolocation of an IP address
56
+ * Retrieve geolocation of an IP address.
57
+ * @param {String} ip An IPv4 or IPv6 address that you would like to lookup.
58
+ * @param {Object} opts Optional parameters
59
+ * @param {String} [format] Output format, the following formats are supported: plain xml json jsonp php csv serialized
60
+ * @param {String} [delimiter] Delimiter between proxies. Can be used only with format plain. The following types are supported: 1 for \"\\n\", 2 for \"<br>\".
61
+ * @param {module:api/DefaultApi~rootGetCallback} callback The callback function, accepting three arguments: error, data, response
62
+ * data is of type: {@link module:model/Get200Response}
63
+ */
64
+ return _createClass(DefaultApi, [{
65
+ key: "rootGet",
66
+ value: function rootGet(ip, opts, callback) {
67
+ opts = opts || {};
68
+ var postBody = null;
69
+ // verify the required parameter 'ip' is set
70
+ if (ip === undefined || ip === null) {
71
+ throw new Error("Missing the required parameter 'ip' when calling rootGet");
72
+ }
73
+ var pathParams = {};
74
+ var queryParams = {
75
+ 'ip': ip,
76
+ 'format': opts['format'],
77
+ 'delimiter': opts['delimiter']
78
+ };
79
+ var headerParams = {};
80
+ var formParams = {};
81
+ var authNames = [];
82
+ var contentTypes = [];
83
+ var accepts = ['application/json'];
84
+ var returnType = _Get200Response["default"];
85
+ return this.apiClient.callApi('/', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback);
86
+ }
87
+ }]);
88
+ }();
package/dist/index.js ADDED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "ApiClient", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _ApiClient["default"];
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "DefaultApi", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _DefaultApi["default"];
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "Get200Response", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _Get200Response["default"];
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "Get400Response", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _Get400Response["default"];
28
+ }
29
+ });
30
+ var _ApiClient = _interopRequireDefault(require("./ApiClient"));
31
+ var _Get200Response = _interopRequireDefault(require("./model/Get200Response"));
32
+ var _Get400Response = _interopRequireDefault(require("./model/Get400Response"));
33
+ var _DefaultApi = _interopRequireDefault(require("./api/DefaultApi"));
34
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _ApiClient = _interopRequireDefault(require("../ApiClient"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
11
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
12
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /**
15
+ * iplocation.net API
16
+ * OpenAPI v3 specification and a set of generated API clients for iplocation.net
17
+ *
18
+ * The version of the OpenAPI document: 1.0.0
19
+ * Contact: blah+oapicf@cliffano.com
20
+ *
21
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
22
+ * https://openapi-generator.tech
23
+ * Do not edit the class manually.
24
+ *
25
+ */
26
+ /**
27
+ * The Get200Response model module.
28
+ * @module model/Get200Response
29
+ * @version 1.0.0
30
+ */
31
+ var Get200Response = /*#__PURE__*/function () {
32
+ /**
33
+ * Constructs a new <code>Get200Response</code>.
34
+ * @alias module:model/Get200Response
35
+ */
36
+ function Get200Response() {
37
+ _classCallCheck(this, Get200Response);
38
+ Get200Response.initialize(this);
39
+ }
40
+
41
+ /**
42
+ * Initializes the fields of this object.
43
+ * This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins).
44
+ * Only for internal use.
45
+ */
46
+ return _createClass(Get200Response, null, [{
47
+ key: "initialize",
48
+ value: function initialize(obj) {}
49
+
50
+ /**
51
+ * Constructs a <code>Get200Response</code> from a plain JavaScript object, optionally creating a new instance.
52
+ * Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
53
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
54
+ * @param {module:model/Get200Response} obj Optional instance to populate.
55
+ * @return {module:model/Get200Response} The populated <code>Get200Response</code> instance.
56
+ */
57
+ }, {
58
+ key: "constructFromObject",
59
+ value: function constructFromObject(data, obj) {
60
+ if (data) {
61
+ obj = obj || new Get200Response();
62
+ if (data.hasOwnProperty('ip')) {
63
+ obj['ip'] = _ApiClient["default"].convertToType(data['ip'], 'String');
64
+ }
65
+ if (data.hasOwnProperty('ip_number')) {
66
+ obj['ip_number'] = _ApiClient["default"].convertToType(data['ip_number'], 'String');
67
+ }
68
+ if (data.hasOwnProperty('ip_version')) {
69
+ obj['ip_version'] = _ApiClient["default"].convertToType(data['ip_version'], 'Number');
70
+ }
71
+ if (data.hasOwnProperty('country_name')) {
72
+ obj['country_name'] = _ApiClient["default"].convertToType(data['country_name'], 'String');
73
+ }
74
+ if (data.hasOwnProperty('country_code2')) {
75
+ obj['country_code2'] = _ApiClient["default"].convertToType(data['country_code2'], 'String');
76
+ }
77
+ if (data.hasOwnProperty('isp')) {
78
+ obj['isp'] = _ApiClient["default"].convertToType(data['isp'], 'String');
79
+ }
80
+ if (data.hasOwnProperty('response_code')) {
81
+ obj['response_code'] = _ApiClient["default"].convertToType(data['response_code'], 'String');
82
+ }
83
+ if (data.hasOwnProperty('response_message')) {
84
+ obj['response_message'] = _ApiClient["default"].convertToType(data['response_message'], 'String');
85
+ }
86
+ }
87
+ return obj;
88
+ }
89
+
90
+ /**
91
+ * Validates the JSON data with respect to <code>Get200Response</code>.
92
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
93
+ * @return {boolean} to indicate whether the JSON data is valid with respect to <code>Get200Response</code>.
94
+ */
95
+ }, {
96
+ key: "validateJSON",
97
+ value: function validateJSON(data) {
98
+ // ensure the json data is a string
99
+ if (data['ip'] && !(typeof data['ip'] === 'string' || data['ip'] instanceof String)) {
100
+ throw new Error("Expected the field `ip` to be a primitive type in the JSON string but got " + data['ip']);
101
+ }
102
+ // ensure the json data is a string
103
+ if (data['ip_number'] && !(typeof data['ip_number'] === 'string' || data['ip_number'] instanceof String)) {
104
+ throw new Error("Expected the field `ip_number` to be a primitive type in the JSON string but got " + data['ip_number']);
105
+ }
106
+ // ensure the json data is a string
107
+ if (data['country_name'] && !(typeof data['country_name'] === 'string' || data['country_name'] instanceof String)) {
108
+ throw new Error("Expected the field `country_name` to be a primitive type in the JSON string but got " + data['country_name']);
109
+ }
110
+ // ensure the json data is a string
111
+ if (data['country_code2'] && !(typeof data['country_code2'] === 'string' || data['country_code2'] instanceof String)) {
112
+ throw new Error("Expected the field `country_code2` to be a primitive type in the JSON string but got " + data['country_code2']);
113
+ }
114
+ // ensure the json data is a string
115
+ if (data['isp'] && !(typeof data['isp'] === 'string' || data['isp'] instanceof String)) {
116
+ throw new Error("Expected the field `isp` to be a primitive type in the JSON string but got " + data['isp']);
117
+ }
118
+ // ensure the json data is a string
119
+ if (data['response_code'] && !(typeof data['response_code'] === 'string' || data['response_code'] instanceof String)) {
120
+ throw new Error("Expected the field `response_code` to be a primitive type in the JSON string but got " + data['response_code']);
121
+ }
122
+ // ensure the json data is a string
123
+ if (data['response_message'] && !(typeof data['response_message'] === 'string' || data['response_message'] instanceof String)) {
124
+ throw new Error("Expected the field `response_message` to be a primitive type in the JSON string but got " + data['response_message']);
125
+ }
126
+ return true;
127
+ }
128
+ }]);
129
+ }();
130
+ /**
131
+ * IPv4 or IPv6 address used to lookup geolocation.
132
+ * @member {String} ip
133
+ */
134
+ Get200Response.prototype['ip'] = undefined;
135
+
136
+ /**
137
+ * IP number in long integer (represented as string).
138
+ * @member {String} ip_number
139
+ */
140
+ Get200Response.prototype['ip_number'] = undefined;
141
+
142
+ /**
143
+ * IP version either 4 or 6.
144
+ * @member {Number} ip_version
145
+ */
146
+ Get200Response.prototype['ip_version'] = undefined;
147
+
148
+ /**
149
+ * Full name of the IP country.
150
+ * @member {String} country_name
151
+ */
152
+ Get200Response.prototype['country_name'] = undefined;
153
+
154
+ /**
155
+ * ISO ALPHA-2 Country Code.
156
+ * @member {String} country_code2
157
+ */
158
+ Get200Response.prototype['country_code2'] = undefined;
159
+
160
+ /**
161
+ * Internet Service Provider (ISP) who owns the IP address.
162
+ * @member {String} isp
163
+ */
164
+ Get200Response.prototype['isp'] = undefined;
165
+
166
+ /**
167
+ * Response status code to indicate success or failed completion of the API call.
168
+ * @member {String} response_code
169
+ */
170
+ Get200Response.prototype['response_code'] = undefined;
171
+
172
+ /**
173
+ * Response message to indicate success or failed completion of the API call.
174
+ * @member {String} response_message
175
+ */
176
+ Get200Response.prototype['response_message'] = undefined;
177
+ var _default = exports["default"] = Get200Response;
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _ApiClient = _interopRequireDefault(require("../ApiClient"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
11
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
12
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /**
15
+ * iplocation.net API
16
+ * OpenAPI v3 specification and a set of generated API clients for iplocation.net
17
+ *
18
+ * The version of the OpenAPI document: 1.0.0
19
+ * Contact: blah+oapicf@cliffano.com
20
+ *
21
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
22
+ * https://openapi-generator.tech
23
+ * Do not edit the class manually.
24
+ *
25
+ */
26
+ /**
27
+ * The Get400Response model module.
28
+ * @module model/Get400Response
29
+ * @version 1.0.0
30
+ */
31
+ var Get400Response = /*#__PURE__*/function () {
32
+ /**
33
+ * Constructs a new <code>Get400Response</code>.
34
+ * @alias module:model/Get400Response
35
+ */
36
+ function Get400Response() {
37
+ _classCallCheck(this, Get400Response);
38
+ Get400Response.initialize(this);
39
+ }
40
+
41
+ /**
42
+ * Initializes the fields of this object.
43
+ * This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins).
44
+ * Only for internal use.
45
+ */
46
+ return _createClass(Get400Response, null, [{
47
+ key: "initialize",
48
+ value: function initialize(obj) {}
49
+
50
+ /**
51
+ * Constructs a <code>Get400Response</code> from a plain JavaScript object, optionally creating a new instance.
52
+ * Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
53
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
54
+ * @param {module:model/Get400Response} obj Optional instance to populate.
55
+ * @return {module:model/Get400Response} The populated <code>Get400Response</code> instance.
56
+ */
57
+ }, {
58
+ key: "constructFromObject",
59
+ value: function constructFromObject(data, obj) {
60
+ if (data) {
61
+ obj = obj || new Get400Response();
62
+ if (data.hasOwnProperty('response_code')) {
63
+ obj['response_code'] = _ApiClient["default"].convertToType(data['response_code'], 'String');
64
+ }
65
+ if (data.hasOwnProperty('response_message')) {
66
+ obj['response_message'] = _ApiClient["default"].convertToType(data['response_message'], 'String');
67
+ }
68
+ }
69
+ return obj;
70
+ }
71
+
72
+ /**
73
+ * Validates the JSON data with respect to <code>Get400Response</code>.
74
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
75
+ * @return {boolean} to indicate whether the JSON data is valid with respect to <code>Get400Response</code>.
76
+ */
77
+ }, {
78
+ key: "validateJSON",
79
+ value: function validateJSON(data) {
80
+ // ensure the json data is a string
81
+ if (data['response_code'] && !(typeof data['response_code'] === 'string' || data['response_code'] instanceof String)) {
82
+ throw new Error("Expected the field `response_code` to be a primitive type in the JSON string but got " + data['response_code']);
83
+ }
84
+ // ensure the json data is a string
85
+ if (data['response_message'] && !(typeof data['response_message'] === 'string' || data['response_message'] instanceof String)) {
86
+ throw new Error("Expected the field `response_message` to be a primitive type in the JSON string but got " + data['response_message']);
87
+ }
88
+ return true;
89
+ }
90
+ }]);
91
+ }();
92
+ /**
93
+ * Response status code to indicate success or failed completion of the API call.
94
+ * @member {String} response_code
95
+ */
96
+ Get400Response.prototype['response_code'] = undefined;
97
+
98
+ /**
99
+ * Response message to indicate success or failed completion of the API call.
100
+ * @member {String} response_message
101
+ */
102
+ Get400Response.prototype['response_message'] = undefined;
103
+ var _default = exports["default"] = Get400Response;
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "openapi_iplocation",
3
+ "version": "1.0.0",
4
+ "description": "OpenAPI v3 specification and a set of generated API clients for iplocation.net",
5
+ "license": "MIT",
6
+ "main": "dist/index.js",
7
+ "scripts": {
8
+ "build": "babel src -d dist",
9
+ "prepare": "npm run build",
10
+ "test": "mocha --require @babel/register --recursive"
11
+ },
12
+ "browser": {
13
+ "fs": false
14
+ },
15
+ "dependencies": {
16
+ "@babel/cli": "^7.0.0",
17
+ "superagent": "^5.3.0"
18
+ },
19
+ "devDependencies": {
20
+ "@babel/core": "^7.0.0",
21
+ "@babel/plugin-proposal-class-properties": "^7.0.0",
22
+ "@babel/plugin-proposal-decorators": "^7.0.0",
23
+ "@babel/plugin-proposal-do-expressions": "^7.0.0",
24
+ "@babel/plugin-proposal-export-default-from": "^7.0.0",
25
+ "@babel/plugin-proposal-export-namespace-from": "^7.0.0",
26
+ "@babel/plugin-proposal-function-bind": "^7.0.0",
27
+ "@babel/plugin-proposal-function-sent": "^7.0.0",
28
+ "@babel/plugin-proposal-json-strings": "^7.0.0",
29
+ "@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
30
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
31
+ "@babel/plugin-proposal-numeric-separator": "^7.0.0",
32
+ "@babel/plugin-proposal-optional-chaining": "^7.0.0",
33
+ "@babel/plugin-proposal-pipeline-operator": "^7.0.0",
34
+ "@babel/plugin-proposal-throw-expressions": "^7.0.0",
35
+ "@babel/plugin-syntax-dynamic-import": "^7.0.0",
36
+ "@babel/plugin-syntax-import-meta": "^7.0.0",
37
+ "@babel/preset-env": "^7.0.0",
38
+ "@babel/register": "^7.0.0",
39
+ "expect.js": "^0.3.1",
40
+ "mocha": "^8.0.1",
41
+ "sinon": "^7.2.0"
42
+ },
43
+ "files": [
44
+ "dist"
45
+ ]
46
+ }