@apiverve/babynamegenerator 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 APIVerve, and Evlar LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,159 @@
1
+ Baby Name Generator API
2
+ ============
3
+
4
+ Baby Name Generator is a simple tool for generating baby names. It returns a list of baby names.
5
+
6
+ ![Build Status](https://img.shields.io/badge/build-passing-green)
7
+ ![Code Climate](https://img.shields.io/badge/maintainability-B-purple)
8
+
9
+ This is a Javascript Wrapper for the [Baby Name Generator API](https://apiverve.com/marketplace/api/babynamegenerator)
10
+
11
+ ---
12
+
13
+ ## Installation
14
+ npm install @apiverve/babynamegenerator --save
15
+
16
+ ---
17
+
18
+ ## Configuration
19
+
20
+ Before using the babynamegenerator API client, you have to setup your account and obtain your API Key.
21
+ You can get it by signing up at [https://apiverve.com](https://apiverve.com)
22
+
23
+ ---
24
+
25
+ ## Usage
26
+
27
+ The Baby Name Generator API documentation is found here: [https://docs.apiverve.com/api/babynamegenerator](https://docs.apiverve.com/api/babynamegenerator).
28
+ You can find parameters, example responses, and status codes documented here.
29
+
30
+ ### Setup
31
+
32
+ ```
33
+ var babynamegeneratorAPI = require('@apiverve/babynamegenerator');
34
+ var api = new babynamegeneratorAPI({
35
+ api_key: [YOUR_API_KEY],
36
+ secure: true //(Optional, defaults to true)
37
+ });
38
+ ```
39
+
40
+ ---
41
+
42
+
43
+ ### Perform Request
44
+ Using the API client, you can perform requests to the API.
45
+
46
+ ###### Define Query
47
+
48
+ ```
49
+ var query = {
50
+ gender: "male",
51
+ count: 1
52
+ };
53
+ ```
54
+
55
+ ###### Simple Request (using Callback)
56
+
57
+ ```
58
+ api.execute(query, function (error, data) {
59
+ if (error) {
60
+ return console.error(error);
61
+ } else {
62
+ console.log(data);
63
+ }
64
+ });
65
+ ```
66
+
67
+ ###### Example Response
68
+
69
+ ```
70
+ {
71
+ "status": "ok",
72
+ "error": null,
73
+ "data": {
74
+ "count": 10,
75
+ "names": [
76
+ {
77
+ "firstName": "Natalie",
78
+ "middleName": "Kay",
79
+ "fullName": "Natalie Kay"
80
+ },
81
+ {
82
+ "firstName": "Rosa",
83
+ "middleName": "Theresa",
84
+ "fullName": "Rosa Theresa"
85
+ },
86
+ {
87
+ "firstName": "Mae",
88
+ "middleName": "Ellen",
89
+ "fullName": "Mae Ellen"
90
+ },
91
+ {
92
+ "firstName": "Lucia",
93
+ "middleName": "Toni",
94
+ "fullName": "Lucia Toni"
95
+ },
96
+ {
97
+ "firstName": "Carrie",
98
+ "middleName": "Bonnie",
99
+ "fullName": "Carrie Bonnie"
100
+ },
101
+ {
102
+ "firstName": "Samantha",
103
+ "middleName": "Roberta",
104
+ "fullName": "Samantha Roberta"
105
+ },
106
+ {
107
+ "firstName": "Gwendolyn",
108
+ "middleName": "Constance",
109
+ "fullName": "Gwendolyn Constance"
110
+ },
111
+ {
112
+ "firstName": "Flora",
113
+ "middleName": "Opal",
114
+ "fullName": "Flora Opal"
115
+ },
116
+ {
117
+ "firstName": "Terry",
118
+ "middleName": "Linda",
119
+ "fullName": "Terry Linda"
120
+ },
121
+ {
122
+ "firstName": "Clara",
123
+ "middleName": "Lora",
124
+ "fullName": "Clara Lora"
125
+ }
126
+ ]
127
+ }
128
+ }
129
+ ```
130
+
131
+ ---
132
+
133
+ ## Customer Support
134
+
135
+ Need any assistance? [Get in touch with Customer Support](https://apiverve.com/contact).
136
+
137
+ ---
138
+
139
+ ## Updates
140
+ Stay up to date by following [@apiverveHQ](https://twitter.com/apiverveHQ) on Twitter.
141
+
142
+ ---
143
+
144
+ ## Legal
145
+
146
+ All usage of the mailboxlayer website, API, and services is subject to the [APIVerve Terms of Service](https://apiverve.com/terms) and all legal documents and agreements.
147
+
148
+ ---
149
+
150
+ ## License
151
+ Licensed under the The MIT License (MIT)
152
+
153
+ Copyright (©) 2024 APIVerve, and Evlar LLC
154
+
155
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
156
+
157
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
158
+
159
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/index.js ADDED
@@ -0,0 +1,81 @@
1
+ const axios = require('axios');
2
+
3
+ class babynamegeneratorWrapper {
4
+
5
+ constructor(options) {
6
+ if (!options || typeof options !== 'object') {
7
+ throw new Error('Options object must be provided.');
8
+ }
9
+
10
+ const { api_key, secure = true } = options;
11
+
12
+ if (!api_key || typeof api_key !== 'string') {
13
+ throw new Error('API key must be provided as a non-empty string.');
14
+ }
15
+ if (typeof secure !== 'boolean') {
16
+ throw new Error('Secure parameter must be a boolean value.');
17
+ }
18
+
19
+ this.APIKey = api_key;
20
+ this.IsSecure = secure;
21
+
22
+ // secure is deprecated, all requests must be made over HTTPS
23
+ this.baseURL = 'https://api.apiverve.com/v1/babynamegenerator';
24
+ }
25
+
26
+ async execute(query, callback) {
27
+ if (!query || typeof query !== 'object') {
28
+ throw new Error('Query parameters must be provided as an object.');
29
+ }
30
+
31
+ var requiredParams = ["gender"];
32
+ if (requiredParams.length > 0) {
33
+ for (var i = 0; i < requiredParams.length; i++) {
34
+ if (!query[requiredParams[i]]) {
35
+ throw new Error(`Required parameter [${requiredParams[i]}] is missing.`);
36
+ }
37
+ }
38
+ }
39
+
40
+ const method = 'GET';
41
+ const url = method === 'POST' ? this.baseURL : this.constructURL(query);
42
+
43
+ try {
44
+ const response = await axios({
45
+ method,
46
+ url,
47
+ headers: {
48
+ 'Content-Type': 'application/json',
49
+ 'x-api-key': this.APIKey,
50
+ 'auth-mode': 'npm-package'
51
+ },
52
+ data: method === 'POST' ? query : undefined
53
+ });
54
+
55
+ const data = response.data;
56
+ callback(null, data);
57
+ return data;
58
+ } catch (error) {
59
+ if (error.response.data) {
60
+ callback(error.response.data, null);
61
+ throw error.response.data;
62
+ } else {
63
+ callback(error, null);
64
+ throw error;
65
+ }
66
+ }
67
+ }
68
+
69
+ constructURL(query) {
70
+ let url = this.baseURL;
71
+ if (Object.keys(query).length > 0) {
72
+ const queryString = Object.keys(query)
73
+ .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`)
74
+ .join('&');
75
+ url += `?${queryString}`;
76
+ }
77
+ return url;
78
+ }
79
+ }
80
+
81
+ module.exports = babynamegeneratorWrapper;
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@apiverve/babynamegenerator",
3
+ "version": "1.0.0",
4
+ "description": "Baby Name Generator is a simple tool for generating baby names. It returns a list of baby names.",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "mocha"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/apiverve/babynamegenerator-API.git"
12
+ },
13
+ "keywords": [
14
+ "baby name generator"," baby names"," baby name generator api"," baby names api"," baby name generator tool"," baby names tool"," baby name generator software"," baby names software"," baby name generator service"," baby names service"," baby name generator library"," baby names library"," baby name generator sdk"," baby names sdk"," baby name generator code"," baby names code"," baby name generator script"," baby names script"," baby name generator program"," baby names program"," baby name generator application"," baby names application"," baby name generator app"," baby names app"," baby name generator tool"," baby names tool"," baby name generator utility"," baby names utility"," baby name generator helper"," baby names helper"," baby name generator helper tool"," baby names helper tool"," baby name generator helper software"," baby names helper software"," baby name generator helper service"," baby names helper service"," baby name generator helper library"," baby names helper library"," baby name generator helper sdk"," baby names helper sdk"," baby name generator helper code"," baby names helper code"," baby name generator helper script"," baby names helper script"," baby name generator helper program"," baby names helper program"," baby name generator helper application"," baby names helper application"," baby name generator helper app"," baby names helper app"," baby name generator helper tool"," baby names helper tool"," baby name generator helper utility"," baby names helper utility"," baby name generator helper"
15
+ ],
16
+ "author": "APIVerve <hello@apiverve.com> (http://apiverve.com/)",
17
+ "license": "MIT",
18
+ "bugs": {
19
+ "url": "https://github.com/apiverve/babynamegenerator-API/issues"
20
+ },
21
+ "homepage": "https://github.com/apiverve/babynamegenerator-API",
22
+ "devDependencies": {
23
+ "mocha": "^2.3.4",
24
+ "chai": "^3.4.1",
25
+ "dotenv": "^2.0.0"
26
+ },
27
+ "dependencies": {
28
+ "node-fetch": "3.3.2",
29
+ "promise": "^7.1.1",
30
+ "request": "^2.69.0"
31
+ }
32
+ }
package/tmp/build.dat ADDED
@@ -0,0 +1 @@
1
+ #