Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.

Commit 45a6ad8

Browse files
author
Kevin Richter
committed
Fix import namespace and wrapper examples
1 parent 5e26ddc commit 45a6ad8

File tree

6 files changed

+55
-44
lines changed

6 files changed

+55
-44
lines changed

package-lock.json

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"@mapcreator/maps4news": "^1.4.22",
99
"esdoc": "^1.1.0",
1010
"esdoc-ecmascript-proposal-plugin": "^1.0.0",
11+
"esdoc-importpath-plugin": "^1.0.2",
1112
"esdoc-standard-plugin": "^1.0.0",
1213
"swagger-ui": "^3.18.1"
1314
},
@@ -47,8 +48,19 @@
4748
"option": {
4849
"all": true
4950
}
51+
},
52+
{
53+
"name": "esdoc-importpath-plugin",
54+
"option": {
55+
"stripPackageName": true,
56+
"replaces": [
57+
{
58+
"from": "src",
59+
"to": "@mapcreator/maps4news/src"
60+
}
61+
]
62+
}
5063
}
5164
]
5265
}
53-
5466
}

source/includes/v1/_directory.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
- [API OpenAPI (Swagger) Definition](api/index.html)
66
- [API Wrapper](wrapper.html)
77
- [API Wrapper Class Documentation](/wrapper/index.html)
8+
- [Basic Usage Examples](examples.html)

source/v1/api.html.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ To Log in and try it out hit the "Try out" button and use `client_id` **2**.
4444
}
4545
```
4646

47-
All JSON responses from the API a wrapper in a base object.
47+
All JSON responses from the API is wrapped in a base object.
4848

49-
Be sure to include an `Accept: application/json` header, otherwise errors like `401, 403 & 404` will either return HTML or redirect you to the login page.
49+
Be sure to include an `Accept: application/json` header, otherwise errors like `401`, `403` & `404` will either return HTML or redirect you to the login page.
5050

5151

5252
# Query Parameters
@@ -70,7 +70,9 @@ X-Page: 1
7070
X-Per-Page: 50
7171
```
7272

73-
By default de API returns 12 items per page. This can be increased to a maximum of 50 items per page.
73+
By default the API returns 12 items per page and defaults to page 1.
74+
75+
The number of items per page can be increased to a maximum of 50 items.
7476

7577
## Sorting
7678

@@ -80,7 +82,7 @@ By default de API returns 12 items per page. This can be increased to a maximum
8082
?sort=-id,name
8183
```
8284

83-
The API supports sorting ascending or descending sorting on multiple columns (seperated by a comma) on the resources.
85+
The API supports sorting ascending or descending sorting on multiple columns (separated by a comma) on the resources.
8486

8587
**Sortable columns are whitelisted inside the API, there is currently no documentation on what columns are whitelisted**
8688

@@ -92,7 +94,8 @@ The API supports sorting ascending or descending sorting on multiple columns (se
9294
?search[name]=Kevin&search[company]=$:4News
9395
```
9496

95-
Searching can be done on multiple columns, we use the URL array syntax for this.
97+
Searching can be done on multiple columns, we use the URL array syntax for this.
98+
9699
The basic syntax is `operator:value`, so: `=:Maps4News`
97100

98101
**The same is for searchable columns, these are whitelisted per resource**

source/v1/examples.html.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Details about how to build a map object can be found on the [map object page](di
5454
<br/>
5555

5656
```javascript--wrapper
57-
await revision.build();
57+
await revision.build("http://example.com/callback");
5858
```
5959

6060
Lastly, we can queue a build of your map. This will create a `JobResult` resource for that revision.

source/v1/wrapper.html.md

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,14 @@ api.authenticate().then(function() {
143143
```
144144

145145

146-
This will create a pop-up window containing the login page. Once the pop-up redirects back to the callback it will resolve the promise. The callback can be an empty page hosted on the same domain.
146+
This will create a pop-up window containing the login page.
147+
Once the pop-up redirects back to the callback it will resolve the promise.
148+
The callback can be an empty page hosted on the same domain.
147149

148-
Callback url is set to the current url by default. The script is smart enough close the page if it detects that it's a child after authentication. This means that either the current page can be set as the callback (default) or a blank page. The callback must be hosted on the same domain as the application to allow for cross window communication.
150+
Callback url is set to the current url by default.
151+
The script is smart enough close the page if it detects that it's a child after authentication.
152+
This means that either the current page can be set as the callback (default) or a blank page.
153+
The callback must be hosted on the same domain as the application to allow for cross window communication.
149154

150155
## Dummy flow
151156

@@ -171,6 +176,9 @@ The dummy flow can be used when a token *should* be present in the cache.
171176

172177
# Basics
173178

179+
These examples assume that an instance of the api exists and is authenticated.
180+
See the node and web authentication examples for more information on authenticating.
181+
174182
```js
175183
const me = await api.users.get('me');
176184
const colors = await me.colors.list();
@@ -182,10 +190,13 @@ const colors = await me.colors.list();
182190
const colors = await api.users.select('me').colors.list();
183191
```
184192

185-
These examples assume that an instance of the api exists and is authenticated.
186-
See the node and web authentication examples for more information on authenticating.
193+
The wrapper exposes relations which return proxies.
194+
These proxies can be used to either build a route to a resource or to fetch resources.
195+
This means that `api.users.get('me')` is the same as calling the route `/v1/users/me`.
196+
All proxies expose the methods `new`, `list` and `lister`.
197+
Most proxies expose the methods `select` and `get`.
187198

188-
The wrapper exposes relations which return proxies. These proxies can be used to either build a route to a resource or to fetch resources. This means that `api.users.get('me')` is the same as calling the route `/v1/users/me`. All proxies expose the methods `new`, `list` and `lister`. Most proxies expose the methods `select` and `get`.
199+
<br/><br/>
189200

190201
```js
191202
// Case translation
@@ -195,17 +206,18 @@ const data = {
195206

196207
const test = api.static().new(data);
197208

198-
test.fooBarBaz === 123;
209+
test.fooBarBaz === 123; // true
199210
```
200211

201-
The wrapper will transform snake_case named variables returned from the api into camelCase named variables. This means that for example `place_name` will be transformed into `placeName`.
212+
The wrapper will transform snake_case named variables returned from the api into camelCase named variables.
213+
This means that for example `place_name` will be transformed into `placeName`.
202214

203215
Async methods return a `Promise` this means that both `then/catch` and `await/async` syntax are supported.
204216

205217

206218
## Getting a resource
207219

208-
> Fetch resource and all it's properties
220+
> Fetch resource and all its properties
209221
210222
```js
211223
api.colors.get(1).then(function(color) {
@@ -223,12 +235,13 @@ api.users.select('me').mapstyleSets.list().then(function(sets) {
223235
});
224236
```
225237

226-
Resources are bound to the base api class by default. Resources can be fetched in
227-
two ways; by selecting them (`.select`) or by fetching them (`.get`). Selecting them will only set the
228-
object's id to it's properties. Fetching a resource
238+
Resources are bound to the base api class by default. Resources can be fetched in two ways;
239+
by selecting them (`.select`) or by fetching them (`.get`). Selecting them will only set the
240+
object's id to its properties. Fetching a resource returns a `Promise` that will resolve with the requested resource.
241+
242+
Selection is only useful as a stepping stone to related resources that can be easily obtained using the id of the parent.
229243

230-
Selection is only useful as a stepping stone to related resources that can be easily obtained
231-
using the id of the parent. Please refer to the api documentation for further reference.
244+
Please refer to the [api documentation](/wrapper/class/src/proxy/ResourceProxy.js~ResourceProxy.html) for further reference.
232245

233246
## Create a new resource
234247

@@ -262,29 +275,6 @@ api.colors.get(1).then(color => {
262275

263276
Setting the id to null forces the creation of a new object upon saving.
264277

265-
## Creating a new job and revision
266-
267-
```js
268-
const object = {}; // Should contain the map definition
269-
270-
const job = await api.jobs.new({
271-
title: "api map",
272-
jobTypeId: 1
273-
}).save();
274-
275-
const revision = await job.revisions.new({
276-
mapstyleSetId: 1
277-
}).save(object);
278-
279-
// Will resolve when the request finishes. Not when the build is done.
280-
await revision.build("https://example.com/callback");
281-
```
282-
283-
Creating a new job and building it is pretty straight forward.
284-
Revisions are slightly different then other resource instances.
285-
Their save function requires the new map definition as an argument.
286-
This is to make it easier to re-use the same revision instance.
287-
288278
## Pagination
289279

290280
> Listing resources with pagination. First page with 5 items per page

0 commit comments

Comments
 (0)