Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

A row import example with the Guzzle client in PHP.

$client = new GuzzleHttp\Client([
    'base_uri' => 'http://reminders-staging.alphacommapi.com/v1'
]);

$query = <<<'QUERY'
mutation addRecords (
  $rows: [RowInput!]
) {
  import {
    addRecords(rows: $rows) {
      name
      action
      status
      records {
        scriptId
        status
        messages {
          context
          message
          level
        }
      }
    }
  }
}
QUERY;

$variables = [
    'rows' => [
        [
          'reference' => 'a3e7a0c3513ba',
          'script' => '<script id>',
          'toPhoneNumbers' => [
              '+31641691884'
          ],
          'personFamilyName' => 'Alphacomm',
          'toMailAddress' => 'reminders@alphacomm.nl',
          'invoiceDescription' => 'Example payment',
          'invoiceDate' => '2019-04-04',
          'invoiceDueDate' => '2019-07-30',
          'invoiceReference' => '40824524',
          'invoiceCurrency' => 'EUR',
          'invoiceAmount' => '56445',
          'invoiceNumber' => '249075245',
          'personBirthDay' => '2000-01-01',
        ],
        [
          'reference' => 'b1f0e7a0c3523',
          'script' => '<script id>',
          'toPhoneNumbers' => [
              '+31641691884'
          ],
          'personFamilyName' => 'Jansen',
          'toMailAddress' => 'reminders-@alphacomm.nl',
          'invoiceDescription' => 'Example payment 2',
          'invoiceDate' => '2019-04-04',
          'invoiceDueDate' => '2019-07-30',
          'invoiceReference' => '40824524',
          'invoiceCurrency' => 'EUR',
          'invoiceAmount' => '56445',
          'invoiceNumber' => '249075245',
          'personBirthDay' => '2000-01-01',
        ],
    ],
];

$response = $client->request('POST', '', [
    'json' => [
        'query' => $query,
        'variables' => $variables,
    ],
    'headers' => ['X-AUTH-TOKEN' => '<TOKEN FROM PORTAL>'],
]);

  • No labels