Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

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

$variables = [
    'rows' => [
        [
          'reference' => 'f0e7a0c3a3e7a0c3513ba',
          '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>'],
]);

...