@apiverve/tenseconverter 1.0.3

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,110 @@
1
+ Tense Converter API
2
+ ============
3
+
4
+ Tense Converter is a simple tool for converting text to past or future tense. It returns the text converted to the specified tense.
5
+
6
+ ![Build Status](https://img.shields.io/badge/build-passing-green)
7
+ ![Code Climate](https://img.shields.io/badge/maintainability-B-purple)
8
+ ![Prod Ready](https://img.shields.io/badge/production-ready-blue)
9
+
10
+ This is a Javascript Wrapper for the [Tense Converter API](https://apiverve.com/marketplace/api/tenseconverter)
11
+
12
+ ---
13
+
14
+ ## Installation
15
+ npm install @apiverve/tenseconverter --save
16
+
17
+ ---
18
+
19
+ ## Configuration
20
+
21
+ Before using the tenseconverter API client, you have to setup your account and obtain your API Key.
22
+ You can get it by signing up at [https://apiverve.com](https://apiverve.com)
23
+
24
+ ---
25
+
26
+ ## Usage
27
+
28
+ The Tense Converter API documentation is found here: [https://docs.apiverve.com/api/tenseconverter](https://docs.apiverve.com/api/tenseconverter).
29
+ You can find parameters, example responses, and status codes documented here.
30
+
31
+ ### Setup
32
+
33
+ ```
34
+ var tenseconverterAPI = require('@apiverve/tenseconverter');
35
+ var api = new tenseconverterAPI({
36
+ api_key: [YOUR_API_KEY],
37
+ secure: true //(Optional, defaults to true)
38
+ });
39
+ ```
40
+
41
+ ---
42
+
43
+
44
+ ### Perform Request
45
+ Using the API client, you can perform requests to the API.
46
+
47
+ ###### Define Query
48
+
49
+ ```
50
+ var query = {
51
+ "text": "I am walking down the street, and I can see a dog",
52
+ "tense": "past"
53
+ };
54
+ ```
55
+
56
+ ###### Simple Request (using Callback)
57
+
58
+ ```
59
+ api.execute(query, function (error, data) {
60
+ if (error) {
61
+ return console.error(error);
62
+ } else {
63
+ console.log(data);
64
+ }
65
+ });
66
+ ```
67
+
68
+ ###### Example Response
69
+
70
+ ```
71
+ {
72
+ "status": "ok",
73
+ "error": null,
74
+ "data": {
75
+ "tense": "past",
76
+ "result": "I was walking down the street, and I could see a dog",
77
+ "changed": true
78
+ }
79
+ }
80
+ ```
81
+
82
+ ---
83
+
84
+ ## Customer Support
85
+
86
+ Need any assistance? [Get in touch with Customer Support](https://apiverve.com/contact).
87
+
88
+ ---
89
+
90
+ ## Updates
91
+ Stay up to date by following [@apiverveHQ](https://twitter.com/apiverveHQ) on Twitter.
92
+
93
+ ---
94
+
95
+ ## Legal
96
+
97
+ All usage of the APIVerve website, API, and services is subject to the [APIVerve Terms of Service](https://apiverve.com/terms) and all legal documents and agreements.
98
+
99
+ ---
100
+
101
+ ## License
102
+ Licensed under the The MIT License (MIT)
103
+
104
+ Copyright (©) 2024 APIVerve, and Evlar LLC
105
+
106
+ 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:
107
+
108
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
109
+
110
+ 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,90 @@
1
+ const axios = require('axios');
2
+
3
+ class tenseconverterWrapper {
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/tenseconverter';
24
+ }
25
+
26
+ async execute(query, callback) {
27
+ if(arguments.length > 1) {
28
+ if (!query || typeof query !== 'object') {
29
+ throw new Error('Query parameters must be provided as an object.');
30
+ }
31
+ } else {
32
+ callback = query;
33
+ query = {};
34
+ }
35
+
36
+ var requiredParams = ["text", "tense"];
37
+ if (requiredParams.length > 0) {
38
+ for (var i = 0; i < requiredParams.length; i++) {
39
+ if (!query[requiredParams[i]]) {
40
+ throw new Error(`Required parameter [${requiredParams[i]}] is missing.`);
41
+ }
42
+ }
43
+ }
44
+
45
+ const method = 'POST';
46
+ const url = method === 'POST' ? this.baseURL : this.constructURL(query);
47
+
48
+ try {
49
+ const response = await axios({
50
+ method,
51
+ url,
52
+ headers: {
53
+ 'Content-Type': 'application/json',
54
+ 'x-api-key': this.APIKey,
55
+ 'auth-mode': 'npm-package'
56
+ },
57
+ data: method === 'POST' ? query : undefined
58
+ });
59
+
60
+ const data = response.data;
61
+ callback(null, data);
62
+ return data;
63
+ } catch (error) {
64
+ if (error.response.data) {
65
+ callback(error.response.data, null);
66
+ throw error.response.data;
67
+ } else {
68
+ callback(error, null);
69
+ throw error;
70
+ }
71
+ }
72
+ }
73
+
74
+ constructURL(query) {
75
+ let url = this.baseURL;
76
+
77
+ if(query && typeof query === 'object')
78
+ {
79
+ if (Object.keys(query).length > 0) {
80
+ const queryString = Object.keys(query)
81
+ .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`)
82
+ .join('&');
83
+ url += `?${queryString}`;
84
+ }
85
+ }
86
+ return url;
87
+ }
88
+ }
89
+
90
+ module.exports = tenseconverterWrapper;
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@apiverve/tenseconverter",
3
+ "version": "1.0.3",
4
+ "description": "Tense Converter is a simple tool for converting text to past or future tense. It returns the text converted to the specified tense.",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "mocha"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/apiverve/tenseconverter-API.git"
12
+ },
13
+ "keywords": [
14
+ "tense converter","tense converter api","tense converter tool","tense converter software","tense converter service"
15
+ ],
16
+ "author": "APIVerve <hello@apiverve.com> (http://apiverve.com/)",
17
+ "license": "MIT",
18
+ "bugs": {
19
+ "url": "https://github.com/apiverve/tenseconverter-API/issues"
20
+ },
21
+ "homepage": "https://github.com/apiverve/tenseconverter-API",
22
+ "devDependencies": {
23
+ "mocha": "^10.4.0",
24
+ "chai": "^5.1.1",
25
+ "dotenv": "^16.4.5"
26
+ },
27
+ "dependencies": {
28
+ "node-fetch": "3.3.2",
29
+ "promise": "^8.3.0",
30
+ "axios": "1.6.8"
31
+ }
32
+ }
package/tmp/build.dat ADDED
@@ -0,0 +1 @@
1
+ #