@apiverve/moonphases 1.0.2

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,116 @@
1
+ Moon Phases API
2
+ ============
3
+
4
+ Moon Phases is a simple tool for getting the moon phases. It returns the moon phase for a given date.
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 [Moon Phases API](https://apiverve.com/marketplace/api/moonphases)
11
+
12
+ ---
13
+
14
+ ## Installation
15
+ npm install @apiverve/moonphases --save
16
+
17
+ ---
18
+
19
+ ## Configuration
20
+
21
+ Before using the moonphases 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 Moon Phases API documentation is found here: [https://docs.apiverve.com/api/moonphases](https://docs.apiverve.com/api/moonphases).
29
+ You can find parameters, example responses, and status codes documented here.
30
+
31
+ ### Setup
32
+
33
+ ```
34
+ var moonphasesAPI = require('@apiverve/moonphases');
35
+ var api = new moonphasesAPI({
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
+ date: "05-15-2024"
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
+ "phase": "Waxing Crescent",
75
+ "phaseEmoji": "🌒",
76
+ "waxing": true,
77
+ "waning": false,
78
+ "lunarAge": 4.6931005661474368,
79
+ "lunarAgePercent": 0.15892337168867243,
80
+ "lunationNumber": 1254,
81
+ "lunarDistance": 61.355400333718848,
82
+ "nextFullMoon": "2024-06-12T00:00:00Z",
83
+ "lastFullMoon": "2024-04-13T00:00:00Z"
84
+ }
85
+ }
86
+ ```
87
+
88
+ ---
89
+
90
+ ## Customer Support
91
+
92
+ Need any assistance? [Get in touch with Customer Support](https://apiverve.com/contact).
93
+
94
+ ---
95
+
96
+ ## Updates
97
+ Stay up to date by following [@apiverveHQ](https://twitter.com/apiverveHQ) on Twitter.
98
+
99
+ ---
100
+
101
+ ## Legal
102
+
103
+ 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.
104
+
105
+ ---
106
+
107
+ ## License
108
+ Licensed under the The MIT License (MIT)
109
+
110
+ Copyright (©) 2024 APIVerve, and Evlar LLC
111
+
112
+ 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:
113
+
114
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
115
+
116
+ 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 moonphasesWrapper {
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/moonphases';
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 = ["date"];
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 = moonphasesWrapper;
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@apiverve/moonphases",
3
+ "version": "1.0.2",
4
+ "description": "Moon Phases is a simple tool for getting the moon phases. It returns the moon phase for a given date.",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "mocha"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/apiverve/moonphases-API.git"
12
+ },
13
+ "keywords": [
14
+ "moon phases","moon phases api","moon phases tool","moon phases software","moon phases service"
15
+ ],
16
+ "author": "APIVerve <hello@apiverve.com> (http://apiverve.com/)",
17
+ "license": "MIT",
18
+ "bugs": {
19
+ "url": "https://github.com/apiverve/moonphases-API/issues"
20
+ },
21
+ "homepage": "https://github.com/apiverve/moonphases-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
+ "axios": "^0.15.3"
31
+ }
32
+ }
package/tmp/build.dat ADDED
@@ -0,0 +1 @@
1
+ #