Skip to content

Commit 032703e

Browse files
committed
Merge branch 'release/3.0.0-alpha1'
2 parents 0518ad0 + f89a6f9 commit 032703e

File tree

94 files changed

+1734
-19756
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1734
-19756
lines changed

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
9+
# Change these settings to your own preference
10+
indent_style = space
11+
indent_size = 2
12+
13+
# We recommend you to keep these unchanged
14+
end_of_line = lf
15+
charset = utf-8
16+
trim_trailing_whitespace = true
17+
insert_final_newline = true
18+
19+
[*.md]
20+
trim_trailing_whitespace = false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ node_modules
2929

3030
www/
3131
config.json
32+
typings

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<a name="3.0.0-alpha1"></a>
2+
### 3.0.0-alpha1 (2016-07-23)
3+
4+
First version for ng2.

README.md

Lines changed: 156 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,196 @@
11
wp-api-angularjs
22
================
33

4-
AngularJS services to consume [WP-API v2](http://v2.wp-api.org/)
4+
Angular2 services to consume [WP-API v2](http://v2.wp-api.org/) (< 2.5kb gziped)
55

6-
## Documentation
7-
8-
<http://shprink.github.io/wp-api-angularjs/>
6+
If you want to use AngularJS v1, here is the latest version: [v2.0.0-rc3](https://github.com/shprink/wp-api-angularjs/tree/v2.0.0-rc3)
97

108
## Installation
119

12-
### npm
10+
### Dependencies
11+
12+
make sure you have those packages installed:
13+
14+
- '@angular/core'
15+
- '@angular/http'
16+
- 'rxjs'
17+
18+
### via npm
1319

20+
```shell
21+
npm install [email protected]
1422
```
15-
npm install wp-api-angularjs
23+
24+
## Bootstrap
25+
26+
27+
```js
28+
import {
29+
WPAPI_PROVIDERS,
30+
defaultWpApi
31+
} from 'wp-api-angularjs';
32+
33+
import {App} from './app';
34+
35+
bootstrap(App, [
36+
WPAPI_PROVIDERS,
37+
defaultWpApi({
38+
baseUrl: "http://YOUR_DOMAIN/wp-json/",
39+
namespace: '/wp/v2' // (optional, default: '/wp/v2')
40+
})
41+
]);
42+
1643
```
1744

18-
then import the dist file
45+
## API
46+
47+
Every method return an Obervable. If you want to get a Promise you will need to add the rxjs `toPromise` operator:
48+
49+
```js
50+
import 'rxjs/add/operator/toPromise';
51+
52+
class Test {
53+
constructor(private wpApiPosts: WpApiPosts) {
54+
this.wpApiPosts.getList()
55+
.toPromise()
56+
.then(response => response.json())
57+
.then(body => {})
58+
.catch(error => {})
59+
}
60+
}
1961

2062
```
21-
# ES5
22-
require('wp-api-angularjs');
2363

24-
# or ES6
25-
import 'wp-api-angularjs';
64+
### RequestOptionsArgs
65+
66+
Every request can have an optional [`RequestOptionsArgs`](https://angular.io/docs/ts/latest/api/http/index/RequestOptionsArgs-interface.html) object.
67+
68+
```js
69+
class RequestOptionsArgs {
70+
url : string
71+
method : string|RequestMethod
72+
search : string|URLSearchParams
73+
headers : Headers
74+
body : any
75+
withCredentials : boolean
76+
}
2677
```
2778

28-
### Bower
79+
This is where you can add query string to your request or change the headers.
80+
81+
### WpApiPosts
82+
83+
```ts
84+
getList(options?: RequestOptionsArgs): Observable<Response>;
85+
get(postId, options?: RequestOptionsArgs): Observable<Response>;
86+
create(body: any, options?: RequestOptionsArgs): Observable<Response>;
87+
update(postId, body: any, options?: RequestOptionsArgs): Observable<Response>;
88+
delete(postId, options?: RequestOptionsArgs): Observable<Response>;
89+
getMetaList(postId, options?: RequestOptionsArgs): Observable<Response>;
90+
getMeta(postId, metaId, options?: RequestOptionsArgs): Observable<Response>;
91+
getRevisionList(postId, options?: RequestOptionsArgs): Observable<Response>;
92+
getRevision(postId, revisionId, options?: RequestOptionsArgs): Observable<Response>;
93+
getCategoryList(postId, options?: RequestOptionsArgs): Observable<Response>;
94+
getCategory(postId, categoryId, options?: RequestOptionsArgs): Observable<Response>;
95+
getTagList(postId, options?: RequestOptionsArgs): Observable<Response>;
96+
getTag(postId, tagId, options?: RequestOptionsArgs): Observable<Response>;
97+
```
2998

99+
### WpApiPages
100+
101+
```ts
102+
getList(options?: RequestOptionsArgs): Observable<Response>;
103+
get(pageId: number, options?: RequestOptionsArgs): Observable<Response>;
104+
create(body: any, options?: RequestOptionsArgs): Observable<Response>;
105+
update(pageId: number, body: any, options?: RequestOptionsArgs): Observable<Response>;
106+
delete(pageId: number, options?: RequestOptionsArgs): Observable<Response>;
107+
getMetaList(pageId: number, options?: RequestOptionsArgs): Observable<Response>;
108+
getMeta(pageId: number, metaId: number, options?: RequestOptionsArgs): Observable<Response>;
109+
getRevisionList(pageId: number, options?: RequestOptionsArgs): Observable<Response>;
110+
getRevision(pageId: number, revisionId: number, options?: RequestOptionsArgs): Observable<Response>;
30111
```
31-
bower install shprink/wp-api-angularjs
112+
113+
### WpApiComments
114+
115+
```ts
116+
getList(options?: RequestOptionsArgs): Observable<Response>;
117+
get(commentId: number, options?: RequestOptionsArgs): Observable<Response>;
118+
create(body: any, options?: RequestOptionsArgs): Observable<Response>;
119+
update(commentId: number, body: any, options?: RequestOptionsArgs): Observable<Response>;
120+
delete(commentId: number, options?: RequestOptionsArgs): Observable<Response>;
32121
```
33122
34-
## Authentication
123+
### WpApiTypes
35124
36-
This library only supports basic auth. OAuth1 not being suitable for JS clients (it would mean exposing key and password out of the open)
125+
```ts
126+
getList(options?: RequestOptionsArgs): Observable<Response>;
127+
get(postType: string, options?: RequestOptionsArgs): Observable<Response>;
128+
```
37129
38-
### Basic auth
130+
### WpApiMedia
39131
40-
Basic auth is only secured to use if used during the app run time and used with a secured connection to your Blog (via SSL).
132+
```ts
133+
getList(options?: RequestOptionsArgs): Observable<Response>;
134+
get(mediaId: number, options?: RequestOptionsArgs): Observable<Response>;
135+
create(body: any, options?: RequestOptionsArgs): Observable<Response>;
136+
update(mediaId: number, body: any, options?: RequestOptionsArgs): Observable<Response>;
137+
delete(mediaId: number, options?: RequestOptionsArgs): Observable<Response>;
138+
```
41139
42-
#### During run time
140+
### WpApiUsers
43141
44-
Make sure your WP-API runs with an SSL certificate (https) otherwise this will expose your credentials at every request.
142+
```ts
143+
getList(options?: RequestOptionsArgs): Observable<Response>;
144+
me(options?: RequestOptionsArgs): Observable<Response>;
145+
get(userId: number, options?: RequestOptionsArgs): Observable<Response>;
146+
create(body: any, options?: RequestOptionsArgs): Observable<Response>;
147+
update(userId: number, body: any, options?: RequestOptionsArgs): Observable<Response>;
148+
delete(userId: number, options?: RequestOptionsArgs): Observable<Response>;
149+
```
45150
46-
Display a form for users to connect and use the following code to register credentials:
151+
### WpApiTaxonomies
47152
153+
```ts
154+
getList(options?: RequestOptionsArgs): Observable<Response>;
155+
get(taxonomiesType: string, options?: RequestOptionsArgs): Observable<Response>;
48156
```
49-
.controller(function(WpApi){
50-
WpApi.setBasicCredentials(<login>, <password>);
51-
});
157+
158+
### WpApiStatuses
159+
160+
```ts
161+
getList(options?: RequestOptionsArgs): Observable<Response>;
162+
get(statusesName: string, options?: RequestOptionsArgs): Observable<Response>;
52163
```
53164
54-
#### During configuration
165+
### WpApiTerms
55166
56-
You can also set basic credentials during the configuration but use this should only be used for testing as it embed credentials in the application code.
167+
`taxonomiesType` can be `tags`, `categories` and more.
57168
169+
```ts
170+
getList(taxonomiesType: string, options?: RequestOptionsArgs): Observable<Response>;
171+
get(taxonomiesType: string, termId: number, options?: RequestOptionsArgs): Observable<Response>;
172+
create(taxonomiesType: string, body: any, options?: RequestOptionsArgs): Observable<Response>;
173+
update(taxonomiesType: string, termId: number, body: any, options?: RequestOptionsArgs): Observable<Response>;
174+
delete(taxonomiesType: string, termId: number, options?: RequestOptionsArgs): Observable<Response>;
58175
```
59-
.config(function(WpApiProvider){
60-
WpApiProvider.setBasicCredentials(<login>, <password>);
61-
});
176+
177+
### WpApiCustom
178+
179+
```ts
180+
getList(options?: RequestOptionsArgs): Observable<Response>;
181+
get(customId: number, options?: RequestOptionsArgs): Observable<Response>;
182+
create(body: any, options?: RequestOptionsArgs): Observable<Response>;
183+
update(customId: number, body: any, options?: RequestOptionsArgs): Observable<Response>;
184+
delete(customId: number, options?: RequestOptionsArgs): Observable<Response>;
62185
```
63186
187+
## Authentication
188+
189+
TO BE DEFINED
190+
64191
## Contribute
65192
66-
```
193+
```shell
67194
npm install
68195
cp config.dist.json config.json
69196

bower.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)