Skip to content

Commit

Permalink
v3
Browse files Browse the repository at this point in the history
  • Loading branch information
biologyscience committed Feb 19, 2023
1 parent 3b4cf30 commit a0acf0e
Show file tree
Hide file tree
Showing 37 changed files with 615 additions and 1,362 deletions.
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

28 changes: 4 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p align="center"> <img src="https://alpha-coders.js.org/svg/Alpha%20Coders.svg" alt="Cover" height="200px" width="600px"> </p>

# About
A complete package used to interact with the [Wallpaper Abyss / The Alpha Coders API](https://api.alphacoders.com/api/instructions) to get wallpapers, wallpaper count, collections, and much more !
A complete package used to interact with the [Wallpaper Abyss / The Alpha Coders API](https://api.alphacoders.com/api/instructions) to get wallpapers, wallpaper count, and much more !

You will need an API key which can obtained from [The Alpha Coders API](https://api.alphacoders.com/api/instructions) to use this package.

Expand All @@ -10,11 +10,6 @@ You will need an API key which can obtained from [The Alpha Coders API](https://
npm i alpha-coders
```

<!-- ### NOTE:
If you would like to use the v2 of the Alpha Coders API, kindly install the package using `npm i [email protected]`
The default installation of the package uses the v3 of the Alpha Coders API. -->

# Features
- Made with JavaScript.
- Easy to use.
Expand All @@ -33,32 +28,17 @@ The default installation of the package uses the v3 of the Alpha Coders API. -->
**M** - Method

- [Alpha](https://biologyscience.gitbook.io/alpha-coders/reference/classes/alpha) **C**
- [getWallpapers](https://biologyscience.gitbook.io/alpha-coders/reference/properties/getwallpapers) **P**
- [getSpecificWallpapers](https://biologyscience.gitbook.io/alpha-coders/reference/properties/getspecificwallpapers) **P**
- [bySort](https://biologyscience.gitbook.io/alpha-coders/reference/methods/bysort) **M**
- [fromCategory](https://biologyscience.gitbook.io/alpha-coders/reference/methods/fromcategory) **M**
- [fromCollection](https://biologyscience.gitbook.io/alpha-coders/reference/methods/fromcollection) **M**
- [fromGroup](https://biologyscience.gitbook.io/alpha-coders/reference/methods/fromgroup) **M**
- [fromSubCategory](https://biologyscience.gitbook.io/alpha-coders/reference/methods/fromsubcategory) **M**
- [fromFeatured](https://biologyscience.gitbook.io/alpha-coders/reference/methods/fromfeatured) **M**
- [fromPopular](https://biologyscience.gitbook.io/alpha-coders/reference/methods/frompopular) **M**
- [fromTag](https://biologyscience.gitbook.io/alpha-coders/reference/methods/fromtag) **M**
- [fromUser](https://biologyscience.gitbook.io/alpha-coders/reference/methods/fromuser) **M**
- [getWallpaperCount](https://biologyscience.gitbook.io/alpha-coders/reference/properties/getwallpapercount) **P**
- [inEntireDB](https://biologyscience.gitbook.io/alpha-coders/reference/methods/inentiredb) **M**
- [inCategory](https://biologyscience.gitbook.io/alpha-coders/reference/methods/incategory) **M**
- [inCollection](https://biologyscience.gitbook.io/alpha-coders/reference/methods/incollection) **M**
- [inGroup](https://biologyscience.gitbook.io/alpha-coders/reference/methods/ingroup) **M**
- [inSubCategory](https://biologyscience.gitbook.io/alpha-coders/reference/methods/insubcategory) **M**
- [inTag](https://biologyscience.gitbook.io/alpha-coders/reference/methods/intag) **M**
- [inUser](https://biologyscience.gitbook.io/alpha-coders/reference/methods/inuser) **M**
- [getList](https://biologyscience.gitbook.io/alpha-coders/reference/properties/getlist) **P**
- [ofCategory](https://biologyscience.gitbook.io/alpha-coders/reference/methods/ofcategory) **M**
- [ofCollection](https://biologyscience.gitbook.io/alpha-coders/reference/methods/ofcollection) **M**
- [ofGroup](https://biologyscience.gitbook.io/alpha-coders/reference/methods/ofgroup) **M**
- [ofSubCategory](https://biologyscience.gitbook.io/alpha-coders/reference/methods/ofsubcategory) **M**
- [search](https://biologyscience.gitbook.io/alpha-coders/reference/methods/search) **M**
- [getWallpaperInfo](https://biologyscience.gitbook.io/alpha-coders/reference/methods/getwallpaperinfo) **M**
- [getRandomWallpaper](https://biologyscience.gitbook.io/alpha-coders/reference/methods/getrandomwallpaper) **M**
- [getWallpaper](https://biologyscience.gitbook.io/alpha-coders/reference/methods/getwallpaper) **M**
- [getRandomWallpapers](https://biologyscience.gitbook.io/alpha-coders/reference/methods/getrandomwallpapers) **M**
- [queryCount](https://biologyscience.gitbook.io/alpha-coders/reference/methods/querycount) **M**

<br>
Expand Down
57 changes: 14 additions & 43 deletions main/index.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,25 @@
const Others = require('./methods/others');

class Alpha
{
baseURL = new URL('https://wall.alphacoders.com/api2.0/get.php');
baseURL = new URL('https://api.alphacoders.com/3.0');

constructor(apiToken)
{
this.apiToken = apiToken;
this.baseURL.searchParams.set('auth', this.apiToken);
}
if (apiToken === undefined) throw new Error('API Key is not provided !');

getWallpapers =
{
baseURL: this.baseURL,
bySort: require('./methods/getWallpapers/bySort'),
fromCategory: require('./methods/getWallpapers/fromCategory'),
fromCollection: require('./methods/getWallpapers/fromCollection'),
fromGroup: require('./methods/getWallpapers/fromGroup'),
fromSubCategory: require('./methods/getWallpapers/fromSubCategory'),
fromFeatured: require('./methods/getWallpapers/fromFeatured'),
fromPopular: require('./methods/getWallpapers/fromPopular'),
fromTag: require('./methods/getWallpapers/fromTag'),
fromUser: require('./methods/getWallpapers/fromUser')
}
this.baseURL.searchParams.set('auth', apiToken);

getWallpaperCount =
{
baseURL: this.baseURL,
inEntireDB: require('./methods/getWallpaperCount/inEntireDB'),
inCategory: require('./methods/getWallpaperCount/inCategory'),
inCollection: require('./methods/getWallpaperCount/inCollection'),
inGroup: require('./methods/getWallpaperCount/inGroup'),
inSubCategory: require('./methods/getWallpaperCount/inSubCategory'),
inFeatured: require('./methods/getWallpaperCount/inFeatured'),
inPopular: require('./methods/getWallpaperCount/inPopular'),
inTag: require('./methods/getWallpaperCount/inTag'),
inUser: require('./methods/getWallpaperCount/inUser')
}
require('./utils').setBaseURL(this.baseURL);
};

getList =
{
baseURL: this.baseURL,
ofCategory: require('./methods/getList/ofCategory'),
ofCollection: require('./methods/getList/ofCollection'),
ofGroup: require('./methods/getList/ofGroup'),
ofSubCategory: require('./methods/getList/ofSubCategory')
}
getSpecificWallpapers = require('./methods/getSpecificWallpapers');
getList = require('./methods/getList');

search = require('./methods/search');
getWallpaperInfo = require('./methods/getWallpaperInfo');
getRandomWallpaper = require('./methods/getRandomWallpaper');
queryCount = require('./methods/queryCount');
}
search = Others.search;
getWallpaper = Others.getWallpaper;
getRandomWallpapers = Others.getRandomWallpaper;
queryCount = Others.queryCount;
};

module.exports = Alpha;
46 changes: 46 additions & 0 deletions main/methods/getList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const process = require('../utils');

function ofCategory()
{
const url = process.getBaseURL();

url.searchParams.set('method', 'category_list');

return new Promise((resolve) =>
{
fetch(url).then(x => x.json()).then((response) =>
{
if (process.response(response) === null) return resolve(null);

const send = process.data(response.categories, 'LIST');

resolve(send);
});
});
};

function ofSubCategory(id, page)
{
const url = process.getBaseURL();

if (id === undefined) throw new Error('Category ID not provided !');

url.searchParams.set('method', 'sub_category_list');
url.searchParams.set('id', id);

page !== undefined ? url.searchParams.set('page', page) : null;

return new Promise((resolve) =>
{
fetch(url).then(x => x.json()).then((response) =>
{
if (process.response(response) === null) return resolve(null);

const send = process.data(response.sub_categories, 'LIST');

resolve(send);
});
});
};

module.exports = { ofCategory, ofSubCategory };
20 changes: 0 additions & 20 deletions main/methods/getList/ofCategory.js

This file was deleted.

20 changes: 0 additions & 20 deletions main/methods/getList/ofCollection.js

This file was deleted.

21 changes: 0 additions & 21 deletions main/methods/getList/ofGroup.js

This file was deleted.

21 changes: 0 additions & 21 deletions main/methods/getList/ofSubCategory.js

This file was deleted.

58 changes: 0 additions & 58 deletions main/methods/getRandomWallpaper.js

This file was deleted.

Loading

0 comments on commit a0acf0e

Please sign in to comment.