File size: 1,100 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
31
32
33
34
35
36
37
import { DOMAIN_WAPI_INFO_FETCH } from 'calypso/state/action-types';
import { registerHandlers } from 'calypso/state/data-layer/handler-registry';
import { http } from 'calypso/state/data-layer/wpcom-http/actions';
import { dispatchRequest } from 'calypso/state/data-layer/wpcom-http/utils';
import {
	fetchWapiDomainInfoFailure,
	fetchWapiDomainInfoSuccess,
} from 'calypso/state/domains/transfer/actions';

export const fetchWapiDomainInfo = ( action ) =>
	http(
		{
			apiVersion: '1.1',
			method: 'GET',
			path: '/domains/' + action.domain + '/status/',
		},
		action
	);

export const handlefetchWapiDomainInfoSuccess = ( action, status ) => [
	fetchWapiDomainInfoSuccess( action.domain, status ),
];

export const handlefetchWapiDomainInfoFailure = ( action, error ) => [
	fetchWapiDomainInfoFailure( action.domain, error ),
];

registerHandlers( 'state/data-layer/wpcom/domains/status/index.js', {
	[ DOMAIN_WAPI_INFO_FETCH ]: [
		dispatchRequest( {
			fetch: fetchWapiDomainInfo,
			onSuccess: handlefetchWapiDomainInfoSuccess,
			onError: handlefetchWapiDomainInfoFailure,
		} ),
	],
} );