dashattach 0.0.1 → 0.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/README.md +67 -0
- package/index.js +2 -2
- package/package.json +3 -3
- package/test.js +9 -0
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# DashAttach
|
|
2
|
+
Dashattach - library for interacting with the Dash API.
|
|
3
|
+
|
|
4
|
+
Last version: 0.0.3
|
|
5
|
+
|
|
6
|
+
npm: https://www.npmjs.com/package/dashattach
|
|
7
|
+
|
|
8
|
+
## Documentation
|
|
9
|
+
|
|
10
|
+
Installing - `npm i dashattach`
|
|
11
|
+
|
|
12
|
+
### Install and import
|
|
13
|
+
```bash
|
|
14
|
+
npm install dashattach
|
|
15
|
+
```
|
|
16
|
+
```JavaScript (ESM)
|
|
17
|
+
import DashAttach from "dashattach"
|
|
18
|
+
```
|
|
19
|
+
### Login
|
|
20
|
+
```JavaScript
|
|
21
|
+
await DashAttach.auth.login(user, password)
|
|
22
|
+
// Example:
|
|
23
|
+
await DashAttach.auth.login("Dasher", "Password30532")
|
|
24
|
+
// Check is login:
|
|
25
|
+
await DashAttach.auth.myInfo.isLogin()
|
|
26
|
+
// Example:
|
|
27
|
+
if (await DashAttach.auth.myInfo.isLogin()) {
|
|
28
|
+
console.log("You is login in Dash")
|
|
29
|
+
} else {
|
|
30
|
+
console.log("You is not login in Dash")
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
### Get my information
|
|
34
|
+
```JavaScript
|
|
35
|
+
await DashAttach.auth.myInfo.getMyId() // get my id in Dash. Return: number/null
|
|
36
|
+
await DashAttach.auth.myInfo.getMyUsername() // get my username in Dash. Return: string
|
|
37
|
+
await DashAttach.auth.myInfo.getMyMessages() // get my messages in Dash. Return: array
|
|
38
|
+
```
|
|
39
|
+
### Get user information
|
|
40
|
+
```JavaScript
|
|
41
|
+
await DashAttach.info.users.getUsername(id) // get username of user by id. Support: olny number, return: string
|
|
42
|
+
await DashAttach.info.users.getId(username) // get id of user by id. Return: number
|
|
43
|
+
await DashAttach.info.users.getRole(user) // get role of user by id/username. Return: string
|
|
44
|
+
await DashAttach.info.description.getDescription(user) // get description of user by id/username. Return: string
|
|
45
|
+
await DashAttach.info.users.date.join(user) // get join date of user by id/username. Return: string
|
|
46
|
+
await DashAttach.info.users.date.lastActive(user) // get date of last active of user by id/username. Return: string
|
|
47
|
+
await DashAttach.info.users.getLinks(user) // get links of user by id/username. Return: array
|
|
48
|
+
await DashAttach.info.users.getAchievements(user) // get achievements of user by id/username. Return: array
|
|
49
|
+
await DashAttach.info.users.getRecommendedProject(user) // get recommended project of user by id/username. Return: object
|
|
50
|
+
await DashAttach.info.users.getProjects(user, offset, limit) // get projects of user by id/username. Return: array
|
|
51
|
+
await DashAttach.info.users.getFollowers(user, offset, limit) // get followers of user by id/username. Return: array
|
|
52
|
+
await DashAttach.info.users.getFollowing(user, offset, limit) // get following of user by id/username. Return: array
|
|
53
|
+
await DashAttach.info.users.getGradient(user) // get gradient (olny for Dash Supporters) of user by id/username. Return: unknown
|
|
54
|
+
DashAttach.info.users.getAvatar(user) // get avatar url of user by id/username. Return: string
|
|
55
|
+
```
|
|
56
|
+
### Get project information
|
|
57
|
+
```JavaScript
|
|
58
|
+
await DashAttach.info.projects.getName(id) // get name of project. Return: string
|
|
59
|
+
await DashAttach.info.projects.getAuthorId(id) // get id of author of project. Return: number
|
|
60
|
+
await DashAttach.info.projects.getAuthorUsername(id) // get username of author of project. Return: string
|
|
61
|
+
await DashAttach.info.projects.getDescription(id) // get description of project. Return: string
|
|
62
|
+
DashAttach.info.projects.getTrumbnail(id) // get trumbnail user of project. Return: string
|
|
63
|
+
```
|
|
64
|
+
### Other
|
|
65
|
+
```JavaScript
|
|
66
|
+
await DashAttach.featuredProjects(offset, limit) // get featured projects. Return: array
|
|
67
|
+
```
|
package/index.js
CHANGED
|
@@ -5,8 +5,8 @@ import info from "./src/components/information.js"
|
|
|
5
5
|
import actions from "./src/components/actions.js"
|
|
6
6
|
|
|
7
7
|
const DashAttach = {
|
|
8
|
-
featuredProjects: async () => {
|
|
9
|
-
const result = await (await fetch(
|
|
8
|
+
featuredProjects: async (offset, limit) => {
|
|
9
|
+
const result = await (await fetch(`https://api.dashblocks.org/featured-projects?offset=${+offset || 0}&limit=${+limit || 5}`)).json()
|
|
10
10
|
return result
|
|
11
11
|
},
|
|
12
12
|
auth,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dashattach",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Library for interacting with the Dash API.",
|
|
5
5
|
"homepage": "https://github.com/shaman2016scratch/DashAttach",
|
|
6
6
|
"bugs": {
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
},
|
|
13
13
|
"license": "GPL-3.0",
|
|
14
14
|
"author": "polzovatel_8787",
|
|
15
|
-
"type": "
|
|
15
|
+
"type": "module",
|
|
16
16
|
"main": "index.js",
|
|
17
17
|
"scripts": {
|
|
18
|
-
"test": "
|
|
18
|
+
"test": "node test.js"
|
|
19
19
|
}
|
|
20
20
|
}
|
package/test.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import DashAttach from "./index.js";
|
|
2
|
+
|
|
3
|
+
console.log(await DashAttach.info.users.getRole(7))
|
|
4
|
+
console.log(await DashAttach.info.users.getGradient(7))
|
|
5
|
+
console.log(await DashAttach.info.users.getId(7))
|
|
6
|
+
console.log(await DashAttach.info.users.getUsername(7))
|
|
7
|
+
console.log(await DashAttach.info.projects.getAuthorUsername(100))
|
|
8
|
+
console.log(await DashAttach.featuredProjects(0, 10))
|
|
9
|
+
console.log(await DashAttach.auth.myInfo.isLogin())
|