-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b4cf30
commit a0acf0e
Showing
37 changed files
with
615 additions
and
1,362 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.