| 1 |
import apiFetch from '@wordpress/api-fetch'; |
| 2 |
import { __ } from '@wordpress/i18n'; |
| 3 |
|
| 4 |
export const get_auth_url = async ( |
| 5 |
provider, |
| 6 |
client_id, |
| 7 |
client_secret, |
| 8 |
redirect_url |
| 9 |
) => { |
| 10 |
try { |
| 11 |
const response = await apiFetch( { |
| 12 |
path: '/suremails/v1/get-auth-url', |
| 13 |
method: 'POST', |
| 14 |
headers: { |
| 15 |
'X-WP-Nonce': suremails.nonce, |
| 16 |
'Content-Type': 'application/json', |
| 17 |
}, |
| 18 |
body: JSON.stringify( { |
| 19 |
provider, |
| 20 |
client_id, |
| 21 |
client_secret, |
| 22 |
redirect_url, |
| 23 |
} ), |
| 24 |
} ); |
| 25 |
return response; |
| 26 |
} catch ( error ) { |
| 27 |
throw new Error( |
| 28 |
error.message || |
| 29 |
__( 'There was an issue getting the auth URL.', 'suremails' ) |
| 30 |
); |
| 31 |
} |
| 32 |
}; |
| 33 |
|