'use strict'; import React, {Component} from 'react'; import {withTranslation} from '../lib/i18n'; import {Trans} from 'react-i18next'; import { requiresAuthenticatedUser, Title, withPageHelpers } from '../lib/page' import { withAsyncErrorHandler, withErrorHandling } from '../lib/error-handling'; import axios from '../lib/axios'; import {Button} from '../lib/bootstrap-components'; import {getUrl} from "../lib/urls"; import {withComponentMixins} from "../lib/decorator-helpers"; import styles from "./styles.scss" @withComponentMixins([ withTranslation, withErrorHandling, withPageHelpers, requiresAuthenticatedUser ]) export default class API extends Component { constructor(props) { super(props); this.state = { accessToken: null }; } @withAsyncErrorHandler async loadAccessToken() { const response = await axios.get(getUrl('rest/access-token')); this.setState({ accessToken: response.data }); } componentDidMount() { // noinspection JSIgnoredPromiseFromCall this.loadAccessToken(); } async resetAccessToken() { const response = await axios.post(getUrl('rest/access-token-reset')); this.setState({ accessToken: response.data }); } render() { const t = this.props.t; 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('thisApiCallEitherInsertsANewSubscription')}
{t('thisApiCallEitherInsertsANewSubscription')}
GET {t('arguments')}
POST {t('arguments')}
{t('additionalPostArguments')}:
{t('example')}
curl -XPOST '{getUrl(`api/subscribe/B16uVTdW?access_token=${accessToken}`)}' \ --data 'EMAIL=test@example.com&MERGE_CHECKBOX=yes&REQUIRE_CONFIRMATION=yes'
{t('thisApiCallMarksASubscriptionAs')}
GET {t('arguments')}
POST {t('arguments')}
{t('example')}
curl -XPOST '{getUrl(`api/unsubscribe/B16uVTdW?access_token=${accessToken}`)}' \ --data 'EMAIL=test@example.com'
{t('thisApiCallDeletesASubscription')}
GET {t('arguments')}
POST {t('arguments')}
{t('example')}
curl -XPOST '{getUrl(`api/delete/B16uVTdW?access_token=${accessToken}`)}' \ --data 'EMAIL=test@example.com'
{t('thisApiCallCreatesANewCustomFieldForA')}
GET {t('arguments')}
POST {t('arguments')}
{t('example')}
curl -XPOST '{getUrl(`api/field/B16uVTdW?access_token=${accessToken}`)}' \ --data 'NAME=Birthday&TYPE=birthday-us&VISIBLE=yes'
{t('thisApiCallGetListOfBlacklistedEmails')}
GET {t('arguments')}
{t('example')}
curl -XGET '{getUrl(`api/blacklist/get?access_token=${accessToken}&limit=10&start=10&search=gmail`)}'
{t('thisApiCallEitherAddEmailsToBlacklist')}
GET {t('arguments')}
POST {t('arguments')}
{t('example')}
curl -XPOST '{getUrl(`api/blacklist/add?access_token={accessToken}`)}' \ --data 'EMAIL=test@example.com&'
{t('thisApiCallEitherDeleteEmailsFrom')}
GET {t('arguments')}
POST {t('arguments')}
{t('example')}
curl -XPOST '{getUrl(`api/blacklist/delete?access_token=${accessToken}`)}' \ --data 'EMAIL=test@example.com&'
{t('retrieveTheListsThatTheUserWithEmailHas')}
GET {t('arguments')}
{t('example')}
curl -XGET '{getUrl(`api/lists/test@example.com?access_token=${accessToken}`)}'
{t('Forces the RSS feed check to immediately check the campaign with the given CID (in :campaignCid). It works only for RSS campaigns.')}
GET {t('arguments')}
{t('example')}
curl -XGET '{getUrl(`api/rss/fetch/5OOnZKrp0?access_token=${accessToken}`)}'
{t('sendSingleEmailByTemplateId')}
GET {t('arguments')}
POST {t('arguments')}
{t('example')}
curl -XPOST '{getUrl(`api/templates/1/send?access_token={accessToken}`)}' \ --data 'EMAIL=test@example.com&SUBJECT=Test&VARIABLES[FOO]=bar&VARIABLES[TEST]=example'