Skip to content

Commit 5f5afdd

Browse files
authored
Add documentation for the apps management API (#14)
1 parent 4ff4de4 commit 5f5afdd

File tree

3 files changed

+168
-1
lines changed

3 files changed

+168
-1
lines changed

_data/sidebar.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ menu:
4242
- links:
4343
- page: Configuration API
4444
url: /api
45+
- page: Apps
46+
url: /api/apps
4547
- page: Actions
4648
url: /api/actions
4749
- page: Parsers

api-apps.md

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
---
2+
layout: page
3+
permalink: /api/apps
4+
---
5+
6+
# Apps
7+
Apps represent your Android applications on Hover’s server. Each app has a unique API token, and a page where you can view information about users’ USSD sessions.
8+
9+
#### App object schema
10+
```json
11+
{
12+
"data": {
13+
"id": "783038", // [string] Unique identifier for the object
14+
"type": "app", // [string] Object type
15+
"attributes": { // [hash] Hash containing object details
16+
"id": 783038, // [integer] Unique identifier for the object
17+
"icon": "noimg.svg", // [string] App icon
18+
"name": "Hover Runner", // [string] App name
19+
"package_name": "com.usehover.runner", // [string] App's package name
20+
"token": "e8c1b06780d823c0764476c4b9ce49da", // [string] securely generated app token
21+
"webhook_url": null, // [string] Webhook URL
22+
"webhook_secret": null, // [string] securely generated webhook secret
23+
"organization_id": 62,
24+
"created_at": "2020-08-05T05:18:49Z",
25+
"updated_at": "2020-08-05T05:18:49Z",
26+
"archived_at": null,
27+
"transactions_count": 0,
28+
"is_tester": false,
29+
"apk_url": null
30+
},
31+
"relationships": {
32+
"organization": {
33+
"data": {
34+
"id": "62",
35+
"type": "organization"
36+
}
37+
}
38+
}
39+
}
40+
}
41+
```
42+
43+
#### Create an app
44+
###### `POST /api/apps`
45+
46+
This endpoint expects a JSON object with the following schema:
47+
48+
```json
49+
{
50+
"app": {
51+
"name": "Example App", // [string][required] App name
52+
"package_name": "com.example.app", // [string][required] Package name
53+
"webhook_url": "https://example.com/app" // [string][optional] Webhook URL
54+
}
55+
}
56+
```
57+
58+
59+
Example:
60+
61+
```bash
62+
curl \
63+
-H "Content-Type: application/json" \
64+
-H "Authorization: JWT-TOKEN" \
65+
-X POST -d '{ "app": { "name": "Example App", "package_name": "com.example.app", "webhook_url": "https://example.com/app" }}' \
66+
http://localhost:3000/api/apps
67+
```
68+
69+
*Response:*
70+
71+
```json
72+
{
73+
"data": {
74+
"id": "43120",
75+
"type": "app",
76+
"attributes": {
77+
"id": 43120,
78+
"icon": "noimg.svg",
79+
"name": "Example App",
80+
"package_name": "com.example.app",
81+
"token": "49addc974685a64b2c2a75a72b7aa1dc",
82+
"webhook_url": "https://example.com/app",
83+
"webhook_secret": "9a62320275d84bb241a0d34d11a1b27a",
84+
"organization_id": 62,
85+
"created_at": "2020-08-05T07:12:14Z",
86+
"updated_at": "2020-08-05T07:12:14Z",
87+
"archived_at": null,
88+
"transactions_count": 0,
89+
"is_tester": false,
90+
"apk_url": null
91+
},
92+
"relationships": {
93+
"organization": {
94+
"data": {
95+
"id": "62",
96+
"type": "organization"
97+
}
98+
}
99+
}
100+
}
101+
}
102+
```
103+
104+
105+
106+
#### Retrieve an app
107+
###### `GET api/apps/APP_ID`
108+
109+
Example:
110+
```bash
111+
curl \
112+
-H "Content-Type: application/json" \
113+
-H "Authorization: JWT-TOKEN" \
114+
http://localhost:3000/api/apps/43120
115+
```
116+
The server will respond with an app JSON object.
117+
118+
#### Update an app
119+
###### `PATCH /api/apps/APP_ID`
120+
121+
In this example, we're updating the package name:
122+
```bash
123+
curl \
124+
-H "Content-Type: application/json" \
125+
-H "Authorization: JWT-TOKEN" \
126+
-X PATCH -d '{ "app": { "package_name": "com.example.app.v1" }}' \
127+
https://www.usehover.com/api/apps/43120
128+
```
129+
130+
The server responds with the updated app in JSON format.
131+
132+
#### Archive an app
133+
###### `DELETE api/apps/APP_ID`
134+
135+
This endpoint archives the specified app. You can undo this action by making a PUT request to `api/apps/APP_ID/restore`.
136+
137+
Example:
138+
139+
```bash
140+
curl \
141+
-H "Content-Type: application/json" \
142+
-H "Authorization: JWT-TOKEN" \
143+
-X DELETE \
144+
https://www.usehover.com/api/apps/43120
145+
```
146+
147+
The server should respond with the following JSON payload.
148+
```json
149+
{"id":43120,"archived":true}
150+
```
151+
152+
#### Restore an app
153+
###### `PUT api/apps/APP_ID/restore`
154+
155+
This endpoint restores an archived app.
156+
157+
```bash
158+
curl \
159+
-H "Content-Type: application/json" \
160+
-H "Authorization: JWT-TOKEN" \
161+
-X PUT \
162+
https://www.usehover.com/api/apps/43120/restore
163+
```
164+
165+
The server will respond with an app object. The `archived_at` attribute should be `null`.

api-parsers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ curl \
120120
-H "Content-Type: application/json" \
121121
-H "Authorization: JWT-TOKEN" \
122122
-X PATCH -d '{"parser":{ "regex":".*Airtime[\\s]*Balance:[\\s]*(?<balance>[0.00-9.99]+).*" }}' \
123-
https://www.usehover.com/api/parsers
123+
https://www.usehover.com/api/parsers/157340
124124
```
125125

126126
The server responds with the updated parser in JSON format.

0 commit comments

Comments
 (0)