'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('Get subscribers')}
{t('Query params')}
{t('example')}
curl -XGET '{getUrl(`api/subscriptions/P5wKkz-e7?access_token=${accessToken}&limit=10&start=10&search=gmail`)}'
{t('thisApiCallEitherInsertsANewSubscription')}
{t('Query params')}
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('Response example')}:
"data": ("id":"TTrw41znK")
{t('thisApiCallMarksASubscriptionAs')}
{t('Query params')}
POST {t('arguments')}
{t('example')}
curl -XPOST '{getUrl(`api/unsubscribe/B16uVTdW?access_token=${accessToken}`)}' \
--data 'EMAIL=test@example.com'
{t('Response example')}:
"data": ("id":"TTrw41znK", "unsubscribed":true)
{t('thisApiCallDeletesASubscription')}
{t('Query params')}
POST {t('arguments')}
{t('example')}
curl -XPOST '{getUrl(`api/delete/B16uVTdW?access_token=${accessToken}`)}' \
--data 'EMAIL=test@example.com'
{t('Response example')}:
"data": ("id":"TTrw41znK", "deleted":true)
{t('thisApiCallCreatesANewCustomFieldForA')}
{t('Query params')}
POST {t('arguments')}
{t('example')}
curl -XPOST '{getUrl(`api/field/B16uVTdW?access_token=${accessToken}`)}' \
--data 'NAME=Comment&TYPE=text'
{t('Response example')}:
"data": ("id":22, "tag":"MERGE_COMMENT")
{t('thisApiCallGetListOfBlacklistedEmails')}
{t('Query params')}
{t('example')}
curl -XGET '{getUrl(`api/blacklist/get?access_token=${accessToken}&limit=10&start=10&search=gmail`)}'
{t('thisApiCallEitherAddEmailsToBlacklist')}
{t('Query params')}
POST {t('arguments')}
{t('example')}
curl -XPOST '{getUrl(`api/blacklist/add?access_token=${accessToken}`)}' \
--data 'EMAIL=test@example.com'
{t('thisApiCallEitherDeleteEmailsFrom')}
{t('Query params')}
POST {t('arguments')}
{t('example')}
curl -XPOST '{getUrl(`api/blacklist/delete?access_token=${accessToken}`)}' \
--data 'EMAIL=test@example.com'
{t('retrieveTheListsThatTheUserWithEmailHas')}
{t('Query params')}
{t('example')}
curl -XGET '{getUrl(`api/lists/test@example.com?access_token=${accessToken}`)}'
{t('retrieveTheListsThatTheNamespaceHas')}
{t('Query params')}
{t('example')}
curl -XGET '{getUrl(`api/lists-by-namespace/1?access_token=${accessToken}`)}'
{t('createListDescription')}
{t('Query params')}
POST {t('arguments')}
{t('example')}
curl -XPOST '{getUrl(`api/list?access_token=${accessToken}`)}' \
-d 'NAMESPACE=1' \
-d 'UNSUBSCRIPTION_MODE=0' \
-d 'NAME=list1' \
-d 'DESCRIPTION=a very nice list' \
-d 'CONTACT_EMAIL=test@example.com' \
-d 'HOMEPAGE=example.com' \
-d 'FIELDWIZARD=first_last_name' \
-d 'SEND_CONFIGURATION=1' \
-d 'PUBLIC_SUBSCRIBE=1' \
-d 'LISTUNSUBSCRIBE_DISABLED=0'
{t('Response example')}:
"data": ("id":"WSGjaP1fY")
{t('deleteListDescription')}
{t('Query params')}
{t('example')}
curl -XDELETE '{getUrl(`api/list/WSGjaP1fY?access_token=${accessToken}`)}'
{t('Response example')}:
{t('Empty object')}
{t('forcesTheRssFeedCheckToImmediatelyCheck')}
{t('Query params')}
{t('example')}
curl -XGET '{getUrl(`api/rss/fetch/5OOnZKrp0?access_token=${accessToken}`)}'
{t('sendSingleEmailByTemplateWithGiven')}
{t('Query params')}
POST {t('arguments')}
{t('example')}
curl -XPOST '{getUrl(`api/templates/1/send?access_token=${accessToken}`)}' \
--data 'EMAIL=test@example.com&SUBJECT=Test&TAGS[FOO]=bar&TAGS[TEST]=example'