Skip to content

Commit 71ee619

Browse files
committed
Add data structure for main objects
1 parent f5631ef commit 71ee619

File tree

2 files changed

+87
-17
lines changed

2 files changed

+87
-17
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22

33
Official repository for the documentation of the [WooCommerce Memberships](https://woocommerce.com/products/woocommerce-memberships/) REST API.
44

5-
If you are looking for the general plugin documentation, [please follow this link](https://docs.woocommerce.com/document/woocommerce-memberships/).
5+
> If you are looking for the general **plugin documentation**, [please follow this link](https://docs.woocommerce.com/document/woocommerce-memberships/).
66
7-
### Contributing
7+
## Contributing
88

99
You can contribute to this documentation by:
1010

11-
* [Opening an issue](https://github.com/skyverge/woocommerce-memberships-rest-api-docs/issues/new) to report a problem or an information missing, etc.
11+
* [Opening an issue](https://github.com/skyverge/woocommerce-memberships-rest-api-docs/issues/new) to report a problem or information missing, etc.
1212
* Opening a pull request to extend the documentation.
1313

14-
Please **do not submit feature requests for the REST API** here. You can use the [WooIdeas board](http://ideas.woocommerce.com/forums/133476-woocommerce?category_id=125014) or [Contact SkyVerge support](https://www.skyverge.com/support/) for that.
14+
> Please **do not submit feature requests or support requests for the REST API** here. You can use the [WooIdeas board](http://ideas.woocommerce.com/forums/133476-woocommerce?category_id=125014) or [Contact SkyVerge support](https://www.skyverge.com/support/).
1515
16-
### Updating pages
16+
## Updating pages
1717

1818
This project uses [Slate](https://github.com/lord/slate) for building the documentation pages.
1919

2020
Follow [Slate readme](https://github.com/lord/slate/blob/master/README.md) and [wiki](https://github.com/lord/slate/wiki) for instructions on how to edit files and make changes.
2121

22-
### Deploying an update
22+
## Deploying an update
2323

2424
To install locally use:
2525

source/index.html.md

Lines changed: 81 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,47 @@ Follow instructions from the [WooCommerce core REST API Authentication chapter](
3939

4040
## Available Routes
4141

42-
This endpoint lists all routes, along with supported HTTP methods for each, made available by WooCommerce Memberships.
42+
**`/memberships`**
43+
44+
The memberships root endpoint lists all routes, along with supported HTTP methods for each, made available by WooCommerce Memberships.
4345

4446
### HTTP REQUEST
4547

4648
`GET http://example.com/wp-json/wc/v2/memberships`
4749

4850
# User Memberships
4951

50-
## Get User Memberships
52+
## The User Membership
53+
54+
A user membership is created when a customer gets access to a membership plan, therefore all user memberships are linked to one user and one membership plan only. Also, a membership has a status and a start date.
55+
56+
### Data Structure
57+
58+
A user membership has the following data structure in the REST API:
59+
60+
Property | Type | Description
61+
-------------------- | --------------------------------| ------------
62+
`id` | <code>int</code> | The unique identifier (integer) of the user membership.
63+
`customer_id` | <code>int</code> | The unique identifier (integer) of the customer that owns the membership.
64+
`plan_id` | <code>int</code> | The unique identifier (integer) of the membership plan the membership is for.
65+
`status` | <code>string</code> | The current status (string) of the user membership.
66+
`order_id` | <code>int&#124;null</code> | The unique identifier (integer) of the order that may have granted access to the matching membership plan. If the user membership is not linked to an order, it will return _`null`_.
67+
`subcription_id` | <code>int&#124;null</code> | The unique identifier (integer) of a subscription that may be linked to the user membership. This property will exist only if the site is running WooCommerce Subscriptions alongside with Memberships. If there is no link to a subscription, the value will be _`null`_.
68+
`product_id` | <code>int&#124;null</code> | The unique identifier (integer) of a product that may have granted access to the matching membership plan. If the user membership is not linked to a product, it will return _`null`_.
69+
`date_created` | <code>datetime</code> | The date (in Atom format) when the user membership object was created, in the local timezone. This does not necessarily match with the start date.
70+
`date_created_gmt` | <code>datetime</code> | The date (in Atom format) when the user membership object was created, in UTC. This does not necessarily match with the start date.
71+
`start_date` | <code>datetime</code> | The date (in Atom format) when the membership starts, in the local timezone.
72+
`start_date_gmt` | <code>datetime</code> | The date (in Atom format) when the membership starts, in UTC.
73+
`end_date` | <code>datetime&#124;null</code> | The date (in Atom format) when the ends, in the local timezone. This is `null` if the membership doesn't have an end date.
74+
`end_date_gmt` | <code>datetime&#124;null</code> | The date (in Atom format) when the ends, in UTC. This is `null` if the membership doesn't have an end date.
75+
`paused_date` | <code>datetime&#124;null</code> | The date (in Atom format) when the membership was last paused, in the local timezone. This is `null` if the membership was never paused. The value is not removed if the membership changes status.
76+
`paused_date_gmt` | <code>datetime&#124;null</code> | The date (in Atom format) when the membership was last paused, in UTC. This is `null` if the membership was never paused. The value is not removed if the membership changes status.
77+
`cancelled_date` | <code>datetime&#124;null</code> | The date (in Atom format) when the membership was cancelled, in the local timezone. This is `null` if the membership was not cancelled.
78+
`cancelled_date_gmt` | <code>datetime&#124;null</code> | The date (in Atom format) when the membership was cancelled, in UTC. This is `null` if the membership was not cancelled.
79+
`meta_data` | <code>array</code> | Holds any WordPress meta data set on the membership. Each array item has an `id` (integer), a `key` (string) and a `value` (either a boolean, an integer, or string, or serialized data).
80+
`links` | <code>array</code> | An array of items linking to related objects accessible through the REST API.
81+
82+
## Get All User Memberships
5183

5284
```php
5385
// TODO
@@ -100,6 +132,8 @@ This endpoint lists all routes, along with supported HTTP methods for each, made
100132
]
101133
```
102134

135+
**`memberships/members`**
136+
103137
This endpoint retrieves all user memberships.
104138

105139
### HTTP Request
@@ -108,7 +142,7 @@ This endpoint retrieves all user memberships.
108142

109143
### Query Parameters
110144

111-
Parameter | Value | Default | Description
145+
Parameter | Type | Default | Description
112146
-------------- | -----------------------------------------| --------- | ------------
113147
`customer` | <code>int&#124;string</code> | _`null`_ | List user memberships belonging to a specific user, specified by ID (integer), email address or login name (string).
114148
`order` | <code>int</code> | _`null`_ | List user memberships created from a specific order, given by its ID (integer).
@@ -119,7 +153,7 @@ Parameter | Value | Default | Descript
119153

120154
### Pagination Parameters
121155

122-
Parameter | Value | Default | Description
156+
Parameter | Type | Default | Description
123157
-------------- | ----------------------------------------| --------- | ------------
124158
`page` | <code>int</code> | `1` | Main pagination parameter (integer). Only a given number of user memberships will be listed at any time, per page, according to the site settings.
125159
`per_page` | <code>int</code> | _`null`_ | The default number of results to return per page. The default value is normally set by WordPress own settings.
@@ -128,7 +162,7 @@ Parameter | Value | Default | Descripti
128162
`include` | <code>int&#124;int[]</code> | _`null`_ | Ensure that the specified user memberships with given ID (integer) or IDs (array of integers) will be included in the results, if found.
129163

130164

131-
## Get User Membership
165+
## Get One User Membership
132166

133167

134168
```php
@@ -180,6 +214,8 @@ Parameter | Value | Default | Descripti
180214
}
181215
```
182216

217+
**`memberships/members/<id>`**
218+
183219
This endpoint retrieves a specific user membership.
184220

185221
### HTTP Request
@@ -188,14 +224,46 @@ This endpoint retrieves a specific user membership.
188224

189225
### URL Parameters
190226

191-
Parameter | Value | Description
227+
Parameter | Type | Description
192228
--------- | ----------------- | ------------
193229
`id` | <code>int</code> | Integer matching the requested user membership ID.
194230

195-
196231
# Membership Plans
197232

198-
## Get Membership Plans
233+
## The Membership Plan
234+
235+
A membership plan is a collection of settings and conditions according to which customers can get access to restricted content, products, get member only discounts and so on.
236+
237+
### Data Structure
238+
239+
A membership plan has the following data structure in the REST API:
240+
241+
Property | Type | Description
242+
---------------------------------- | ------------------------------| ------------
243+
`id` | <code>int</code> | The unique identifier (integer) of the membership plan.
244+
`name` | <code>string</code> | The membership plan name.
245+
`slug` | <code>string</code> | The membership plan slug (a unique string identifier).
246+
`status` | <code>string</code> | The membership plan status (this usually matches standard WordPress post statuses, with `publish` or `draft` being the most common for plans).
247+
`access_method` | <code>string</code> | The method that membership plan prescribes for users to gain access.
248+
`access_length_type` | <code>string</code> | The access length type: specific (relative dates), fixed (fixed dates) or unlimited.
249+
`access_length` | <code>string</code> | The length in a human readable format (e.g. 2 weeks or 3 months, 1 year, etc.) that a user membership created for this plan will have, by default. This could be an empty string for unlimited memberships that have no set end (or may be tied to a subscription).
250+
`access_length_seconds` | <code>int&#124;null</code> | The equivalent in seconds of the access length, calculated by approximation in the site timezone. If the access length is nto set this will return _`null`_.
251+
`access_length_seconds_gmt` | <code>int&#124;null</code> | The equivalent in seconds of the access length, calculated by approximation in UTC. If the access length is nto set this will return _`null`_.
252+
`access_product_ids` | <code>int[]</code> | An optional array of product IDs (integers) to products that will grant access to the membership plan upon purchase. If no products grant access to the membership plan, the value will be an empty array.
253+
`is_subscription_plan` | <code>bool</code> | Whether the plan has at least one subscription among the products that can grant access. If Subscriptions is inactive this field will not exist.
254+
`is_subscription_installment_plan` | <code>bool</code> | Whether the plan uses the subscription for managing installment plans (the membership plan length is not directly tied to the subscription length). If Subscription is inactive this field will not exist.
255+
`access_start_date` | <code>datetime</code> | If the plan length type is based on fixed dates, this will be the date when any user membership will start, otherwise it will default to now, in the local timezone and in Atom format.
256+
`access_start_date_gmt` | <code>datetime</code> | If the plan length type is based on fixed dates, this will be the date when any user membership will start, otherwise it will default to now, in the UTC and in Atom format.
257+
`access_end_date` | <code>datetime</code> | If the plan length type is fixed this will be a fixed date when any membership will end, otherwise it will be a date calculated relatively to now, in the local timezone and in Atom format.
258+
`access_end_date_gmt` | <code>datetime</code> | If the plan length type is fixed this will be a fixed date when any membership will end, otherwise it will be a date calculated relatively to now, in UTC and in Atom format.
259+
`date_created` | <code>datetime</code> | The date (in Atom format) when the membership plan object was created, in the local timezone.
260+
`date_created_gmt` | <code>datetime</code> | The date (in Atom format) when the membership plan object was created, in UTC.
261+
`date_modified` | <code>datetime</code> | The date (in Atom format) when the membership plan object was last modified, in the local timezone.
262+
`date_modified_gmt` | <code>datetime</code> | The date (in Atom format) when the membership plan object was last modified, in UTC.
263+
`meta_data` | <code>array</code> | Holds any WordPress meta data set on the plan. Each array item has an `id` (integer), a `key` (string) and a `value` (either a boolean, an integer, or string, or serialized data).
264+
`links` | <code>array</code> | An array of items linking to related objects accessible through the REST API.
265+
266+
## Get All Membership Plans
199267

200268
```php
201269
// TODO
@@ -256,6 +324,8 @@ Parameter | Value | Description
256324
]
257325
```
258326

327+
**`/memberships/plans`**
328+
259329
This endpoint retrieves all membership plans.
260330

261331
### HTTP Request
@@ -278,9 +348,7 @@ Parameter | Value | Default | Descripti
278348
`exclude` | <code>int&#124;int[]</code> | _`null`_ | Ensure that the specified membership plans with given ID (integer) or IDs (array of integers) will be excluded from the results, if found.
279349
`include` | <code>int&#124;int[]</code> | _`null`_ | Ensure that the specified membership plans with given ID (integer) or IDs (array of integers) will be included in the results, if found.
280350

281-
282-
## Get Membership Plan
283-
351+
## Get One Membership Plan
284352

285353
```php
286354
// TODO
@@ -339,6 +407,8 @@ Parameter | Value | Default | Descripti
339407
}
340408
```
341409

410+
**`/memberships/plans/<id>`**
411+
342412
This endpoint retrieves a specific membership plan.
343413

344414
### HTTP Request

0 commit comments

Comments
 (0)