-
Notifications
You must be signed in to change notification settings - Fork 122
/
Copy pathconstants.dart
169 lines (155 loc) · 2.45 KB
/
constants.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
const URL_JWT_BASE = '/wp-json/jwt-auth/v1';
const URL_WP_BASE = '/wp-json/wp/v2';
const URL_JWT_TOKEN = '$URL_JWT_BASE/token';
const URL_JWT_TOKEN_VALIDATE = '$URL_JWT_BASE/token/validate';
const URL_CATEGORIES = '$URL_WP_BASE/categories';
const URL_COMMENTS = '$URL_WP_BASE/comments';
const URL_MEDIA = '$URL_WP_BASE/media';
const URL_PAGES = '$URL_WP_BASE/pages';
const URL_POSTS = '$URL_WP_BASE/posts';
const URL_TAGS = '$URL_WP_BASE/tags';
const URL_USERS = '$URL_WP_BASE/users';
const URL_USER_ME = '$URL_WP_BASE/users/me';
enum WordPressAuthenticator {
JWT,
ApplicationPasswords,
}
enum WordPressContext { view, embed, edit }
enum Order {
asc,
desc,
}
enum PostOrderBy {
author,
date,
id,
include,
modified,
parent,
relevance,
slug,
title,
}
enum PostPageStatus {
publish,
future,
draft,
pending,
private,
}
enum PostCommentStatus {
open,
closed,
}
enum PostPingStatus {
open,
closed,
}
enum PostFormat {
standard,
aside,
chat,
gallery,
link,
image,
quote,
status,
video,
audio,
}
enum UserOrderBy {
id,
include,
name,
registered_date,
slug,
email,
url,
}
enum CommentOrderBy {
date,
date_gmt,
id,
include,
post,
parent,
type,
}
enum CommentStatus {
all,
approve,
hold,
spam,
trash,
}
enum CommentType {
comment,
//TODO: Add all comment types
}
enum CategoryTagOrderBy {
id,
include,
name,
slug,
term_group,
description,
count,
}
enum PageOrderBy {
author,
date,
id,
include,
modified,
parent,
relevance,
slug,
title,
menu_order,
}
enum MediaOrderBy {
author,
date,
id,
include,
modified,
parent,
relevance,
slug,
title,
}
enum MediaStatus {
inherit,
publish,
future,
draft,
pending,
private,
}
enum MediaType {
image,
video,
audio,
application,
}
/// Converts an enum string to enum value name.
String enumStringToName(String enumString) {
return enumString.split('.')[1];
}
/// Formats a list of [items] to a comma(,) separated string to pass it as a
/// URL parameter.
String listToUrlString<T>(List<T> items) {
if (items == null || items.length == 0) return '';
return items.join(',');
}
/// Formats a [Map] of parameters to a string of URL friendly parameters.
String constructUrlParams(Map<String, String> params) {
StringBuffer p = new StringBuffer('/?');
params.forEach((key, value) {
if (value != '') {
p.write('$key=$value');
p.write('&');
}
});
return p.toString();
}