File size: 746 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import wpcom from 'calypso/lib/wp';

export interface SitePreviewLink {
	code: string;
	created_at: string;
	expires_at?: string;
}

export async function fetchSitePreviewLinks( siteId: number ): Promise< SitePreviewLink[] > {
	return wpcom.req.get( {
		path: `/sites/${ siteId }/preview-links`,
		apiNamespace: 'wpcom/v2',
	} );
}

export async function createSitePreviewLink( siteId: number ): Promise< SitePreviewLink > {
	return wpcom.req.post( {
		path: `/sites/${ siteId }/preview-links`,
		apiNamespace: 'wpcom/v2',
	} );
}

export async function deleteSitePreviewLink( siteId: number, code: string ) {
	return wpcom.req.post( {
		method: 'DELETE',
		path: `/sites/${ siteId }/preview-links/${ code }`,
		apiNamespace: 'wpcom/v2',
	} );
}