feat(wordpress): add auth and new post trigger (#1160)

This commit is contained in:
Ali BARIN
2023-08-09 22:34:21 +02:00
committed by GitHub
parent 5046c4c911
commit ec42446daa
19 changed files with 284 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
import listStatuses from './list-statuses';
export default [listStatuses];

View File

@@ -0,0 +1,37 @@
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
type Status = {
slug: string;
name: string;
}
type Statuses = Record<string, Status>;
export default {
name: 'List statuses',
key: 'listStatuses',
async run($: IGlobalVariable) {
const statuses: {
data: IJSONObject[];
} = {
data: [],
};
const { data } = await $.http.get<Statuses>('?rest_route=/wp/v2/statuses');
if (!data) return statuses;
const values = Object.values(data);
if (!values?.length) return statuses;
for (const status of values) {
statuses.data.push({
value: status.slug,
name: status.name,
})
}
return statuses;
},
};