'use strict'; import React, { Component } from 'react'; import { translate, Trans } from 'react-i18next'; import { requiresAuthenticatedUser, withPageHelpers, Title } from '../lib/page' import { withErrorHandling, withAsyncErrorHandler } from '../lib/error-handling'; import URL from 'url-parse'; import axios from '../lib/axios'; import { Button } from '../lib/bootstrap-components'; @translate() @withPageHelpers @withErrorHandling @requiresAuthenticatedUser export default class API extends Component { constructor(props) { super(props); this.state = { accessToken: null }; } @withAsyncErrorHandler async loadAccessToken() { const response = await axios.get('/rest/access-token'); this.setState({ accessToken: response.data }); } componentDidMount() { this.loadAccessToken(); } async resetAccessToken() { const response = await axios.post('/rest/access-token-reset'); this.setState({ accessToken: response.data }); } render() { const t = this.props.t; const thisUrl = new URL(); const serviceUrl = thisUrl.origin + '/'; const accessToken = this.state.accessToken || 'ACCESS_TOKEN'; let accessTokenMsg; if (this.state.accessToken) { accessTokenMsg =
{accessToken}
error
and data
properties. If the response error
has a value set then the request failed.Content-Type
when making a request. You can either use application/x-www-form-urlencoded
for normal form data or application/json
for a JSON payload. Using multipart/form-data
is not supported.{t('This API call either inserts a new subscription or updates existing. Fields not included are left as is, so if you update only LAST_NAME value, then FIRST_NAME is kept untouched for an existing subscription.')}
GET {t('arguments')}
POST {t('arguments')}
{t('Additional POST arguments')}:
{t('Example')}
curl -XPOST {serviceUrl}api/subscribe/B16uVTdW?access_token={accessToken} \ --data 'EMAIL=test@example.com&MERGE_CHECKBOX=yes&REQUIRE_CONFIRMATION=yes'
{t('This API call marks a subscription as unsubscribed')}
GET {t('arguments')}
POST {t('arguments')}
{t('Example')}
curl -XPOST {serviceUrl}api/unsubscribe/B16uVTdW?access_token={accessToken} \ --data 'EMAIL=test@example.com'
{t('This API call deletes a subscription')}
GET {t('arguments')}
POST {t('arguments')}
{t('Example')}
curl -XPOST {serviceUrl}api/delete/B16uVTdW?access_token={accessToken} \ --data 'EMAIL=test@example.com'
{t('This API call creates a new custom field for a list.')}
GET {t('arguments')}
POST {t('arguments')}
{t('Example')}
curl -XPOST {serviceUrl}api/field/B16uVTdW?access_token={accessToken} \ --data 'NAME=Birthday&TYPE=birthday-us&VISIBLE=yes'
{t('This API call get list of blacklisted emails.')}
GET {t('arguments')}
{t('Example')}
curl -XGET '{serviceUrl}api/blacklist/get?access_token={accessToken}&limit=10&start=10&search=gmail'
{t('This API call either add emails to blacklist')}
GET {t('arguments')}
POST {t('arguments')}
{t('Example')}
curl -XPOST '{serviceUrl}api/blacklist/add?access_token={accessToken}' \ --data 'EMAIL=test@example.com&'
{t('This API call either delete emails from blacklist')}
GET {t('arguments')}
POST {t('arguments')}
{t('Example')}
curl -XPOST '{serviceUrl}api/blacklist/delete?access_token={accessToken}' \ --data 'EMAIL=test@example.com&'
{t('Retrieve the lists that the user with :email has subscribed to.')}
GET {t('arguments')}
{t('Example')}
curl -XGET '{{serviceUrl}}api/lists/test@example.com?access_token={{accessToken}}