Skip to content

Commit 550f3cf

Browse files
committed
Finish pixelbuy api schema version 1
1 parent e286043 commit 550f3cf

File tree

5 files changed

+331
-33
lines changed

5 files changed

+331
-33
lines changed

docs/default/developers/schema.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
sidebar_position: 2
3+
title: Schema
4+
description: PixelBuy web API schema.
5+
---
6+
7+
To allow people make its own website and connect it with PixelBuy, a format to get website data is provided.
8+
9+
## REST API
10+
11+
Make your site serve data with the typical `GET` and `POST` process.
12+
13+
Json content is used to explain the format.
14+
15+
### Authentication
16+
17+
Every website must provide a "secret", an API key to allow the user to get information from the website API.
18+
19+
PixelBuy is compatible with a variety of authentication formats:
20+
21+
* Query parameters, by providing the secret as a query parameter in the same URL.
22+
* Header property, by providing the secret as a http header in every connection.
23+
* Basic authentication, by passing the secret in a Basic authentication header in every connection.
24+
25+
### Version 1
26+
27+
**error:** The response to communicate an error.
28+
29+
```json5
30+
{
31+
"error": "error_message_code",
32+
"message": "An error has occur",
33+
"status": 404,
34+
}
35+
```
36+
37+
**(GET) order:** A store order, the player can be provided by only its name if you don't want to provide the UUID.
38+
39+
```json5
40+
{
41+
"id": 1234, // Order numeric ID / transaction number
42+
"date": "1970-01-25", // ISO-8601 formatted
43+
"player": "7ca003dc-175f-4f1f-b490-5651045311ad:Rubenicos", // [<uuid>:]<name>
44+
"execution": "BUY", // Optional, the value must be BUY, RECOVER or REFUND
45+
// The items can be empty if execution is RECOVER or REFUND
46+
"items": [
47+
{
48+
"product": 55, // Optional, it's the product identifier, can be any type of object
49+
"id": "super-pickaxe", // The item identifier configured on PixelBuy items
50+
"amount": 1, // The amount of items of this type, must be an integer number
51+
"price": 2.49, // The real amount of money spend on this item(s)
52+
},
53+
{
54+
"product": 94,
55+
"id": "eco-bundle",
56+
"amount": 6,
57+
"price": 5.04,
58+
}
59+
]
60+
}
61+
```
62+
63+
**(GET) server:** A server information.
64+
65+
```json5
66+
{
67+
// Orders that should be processed by PixelBuy
68+
"pending_orders": [
69+
{
70+
// Order object...
71+
},
72+
{
73+
// Order object...
74+
}
75+
],
76+
"next_check": 60, // Optional, the amount of seconds to wait until make the next check
77+
}
78+
```
79+
80+
**(POST) update:** Communicate to store a server update.
81+
82+
```json5
83+
{
84+
"processed_orders": [ 1234, 6727, 1897 ], // Order IDs that must be removed from server pending orders
85+
}
86+
```

docs/default/store/web-supervisor.md

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ title: Web supervisor
44
description: How to setup PixelBuy web supervisors.
55
---
66

7+
```mdx-code-block
8+
import DocCard from '@theme/DocCard';
9+
```
10+
711
The web supervisor interface is a type of system that retrieves data from a web store to apply any necessary delivery inside Minecraft server.
812

913
## Types
1014

1115
PixelBuy currently aims to support some delivery concepts:
1216

17+
* `PIXELBUY` - Website compatible with PixelBuy web API format.
1318
* `WOOMINECRAFT` - Self-hosted WordPress using **WooMinecraft** plugin.
1419
* `TEBEX` - BuyCraft-like delivery from **Tebex** store.
1520

@@ -18,10 +23,60 @@ PixelBuy currently aims to support some delivery concepts:
1823
Any web supervisor has common configuration paths.
1924

2025
```yaml
26+
Type: PIXELBUY
2127
Group: 'servername'
28+
URL: 'https://shop.mysite.com'
2229
```
2330
31+
* `type` - The type of web supervisor.
2432
* `group` - Is the server associated with the name that the supervisor is looking for orders.
33+
* `url` - Is the store url.
34+
35+
## PixelBuy
36+
37+
The PixelBuy web supervisor retrieves information from a site compatible with PixelBuy web API schema:
38+
39+
```mdx-code-block
40+
<DocCard item={{
41+
type: "link",
42+
href: "/pixelbuy/developers/schema/",
43+
label: "Schema",
44+
description: "PixelBuy web API schema"
45+
}}
46+
/>
47+
```
48+
49+
This supervisor also came with its own configuration.
50+
51+
```yaml
52+
Version: 1
53+
Format:
54+
Server: '{url}/api/server/{key}'
55+
Order: '{url}/api/order/{key}'
56+
Rest:
57+
Check-Interval: 30
58+
Auth: PARAMS
59+
Property: 'secret'
60+
Secret: ''
61+
```
62+
63+
* `version` - The version of PixelBuy schema.
64+
* `format.server` - The URL format to get server information (`{key}` will be replaced with server group).
65+
* `format.order` - The URL format to get order information (`{key}` will be replaced with order ID).
66+
* `rest.check-interval` - The interval in seconds to check new orders, set to `DETECT` to use a provided one by REST API.
67+
* `rest.auth` - The authentication type to connect with REST API.
68+
* `rest.property` - The property name, this both apply to `PARAMS` and `HEADER` authentication.
69+
* `rest.secret` - The secret key that is used to get information.
70+
71+
### Format version
72+
73+
* **Version 1:** Initial PixelBuy web API version, no changes.
74+
75+
### Auth types
76+
77+
* `PARAMS` - Use query parameters to provide the secret.
78+
* `HEADER` - Use header property to provide the secret.
79+
* `BASIC` - Use HTTP Basic authorization.
2580

2681
## WooMinecraft
2782

@@ -30,14 +85,12 @@ The WooMinecraft supervisor type makes delayed checks to get what order commands
3085
The store plugin setup is the same as [WooMinecraft wiki](https://github.com/WooMinecraft/WooMinecraft/wiki/Step-2:-Setting-up-the-wordpress-side) and also [the commands](https://github.com/WooMinecraft/WooMinecraft/wiki/Step-3:-Creating-A-Package).
3186

3287
```yaml
33-
Check-Interval: 7
34-
URL: 'http://shop.mysite.com'
88+
Check-Interval: 600
3589
Key: 'asdUniqueKeyForServer'
3690
```
3791

38-
* `Check-Interval` - Is the interval in seconds to check WooMinecraft rest api from store url.
39-
* `URL` - Is the store url.
40-
* `Key` - Is the server key from [WooMinecraft configuration](https://github.com/WooMinecraft/WooMinecraft/wiki/Step-2:-Setting-up-the-wordpress-side).
92+
* `check-interval` - Is the interval in seconds to check WooMinecraft rest api from store url.
93+
* `key` - Is the server key from [WooMinecraft configuration](https://github.com/WooMinecraft/WooMinecraft/wiki/Step-2:-Setting-up-the-wordpress-side).
4194

4295
### WooCommerce integration
4396

@@ -62,8 +115,15 @@ Next you only need to set the generated key and secret into web supervisor confi
62115

63116
```yaml
64117
WooCommerce:
118+
Version: 3
119+
Auth: PARAMS
65120
ConsumerKey: 'ck_theGeneratedConsumerKey'
66121
ConsumerSecret: 'cs_theGeneratedConsumerSecret'
67122
```
68123

124+
* `version` - WooCommerce API version, currently only version 3 is supported.
125+
* `auth` - The [authentication type](https://woocommerce.github.io/woocommerce-rest-api-docs/#authentication-over-https) to connect with WooCommerce API (`PARAMS` or `BASIC`).
126+
* `consumerkey` - The generated key.
127+
* `consumersecret` - The generated secret.
128+
69129
Take in count that every consumer key starts with `ck_` and every consumer secret starts with `cs_`.

docs/es/developers/schema.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
sidebar_position: 2
3+
title: Schema
4+
description: Esquema de datos para hacer un sitio web compatible con PixelBuy.
5+
---
6+
7+
Para permitir que la gente haga su propio sitio web conectado con PixelBuy, se ha creado un formato en común.
8+
9+
## REST API
10+
11+
Hacer que tu sitio web transfiera datos con el proceso tipico de `GET` y `POST`.
12+
13+
Se usará contenido en Json para explicar el formato.
14+
15+
### Autenticación
16+
17+
Todos los sitios web compatibles con PixelBuy deben proveer una "clave secreta", la cual será usada por el usuario para obtener información de la API del sitio web.
18+
19+
PixelBuy es compatible con multiples formatos de autenticación:
20+
21+
* Query parameters, al proveer la clave secrete como un query parameter en el mismo URL.
22+
* Header property, al proveer la clave secrete como un header de http en cada conexión.
23+
* Basic authentication, al pasar la clave secreta en un header de Basic authentication header en cada conexión.
24+
25+
### Versión 1
26+
27+
**error:** Es la respuesta para comunicar un error.
28+
29+
```json5
30+
{
31+
"error": "error_message_code",
32+
"message": "An error has occur",
33+
"status": 404,
34+
}
35+
```
36+
37+
**(GET) order:** Una orden de compra, el jugador puede ser solo un nombre si no quieres dar el UUID.
38+
39+
```json5
40+
{
41+
"id": 1234, // ID numérico de la orden / número de transacción
42+
"date": "1970-01-25", // En formato ISO-8601
43+
"player": "7ca003dc-175f-4f1f-b490-5651045311ad:Rubenicos", // [<uuid>:]<nombre>
44+
"execution": "BUY", // Opcional, el valor debe ser BUY, RECOVER o REFUND
45+
// Puede no haber items si el valor de la ejecución es RECOVER o REFUND
46+
"items": [
47+
{
48+
"product": 55, // Opcional, es el identificador del producto, puede ser cualquier tipo de objeto
49+
"id": "super-pickaxe", // El identificador del item que fue configurado en PixelBuy
50+
"amount": 1, // La cantidad de items de este tipo, debe ser un número entero
51+
"price": 2.49, // La cantidad real de dinero gastado en este items (considera la cantidad de items)
52+
},
53+
{
54+
"product": 94,
55+
"id": "eco-bundle",
56+
"amount": 6,
57+
"price": 5.04,
58+
}
59+
]
60+
}
61+
```
62+
63+
**(GET) server:** Información sobre el servidor.
64+
65+
```json5
66+
{
67+
// Ordenes de compra que deberían ser procesadas por PixelBuy
68+
"pending_orders": [
69+
{
70+
// Objeto de una orden (arriba está especificado su formato)...
71+
},
72+
{
73+
// Otro objeto de una orden (arriba está especificado su formato)...
74+
}
75+
],
76+
"next_check": 60, // Opcional, the amount of seconds to wait until make the next check
77+
}
78+
```
79+
80+
**(POST) update:** Le dice a la tienda que debe ejecutarse una actualización.
81+
82+
```json5
83+
{
84+
"processed_orders": [ 1234, 6727, 1897 ], // Los IDs de las ordenes que compra que ya fueron procesadas (y por lo tanto ya no deberían aparecer en la información del servidor)
85+
}
86+
```

0 commit comments

Comments
 (0)