You are here

public function SendinblueApiV2::getAccount in SendinBlue 8.2

Same name and namespace in other branches
  1. 8 src/Tools/Api/SendinblueApiV2.php \Drupal\sendinblue\Tools\Api\SendinblueApiV2::getAccount()

Get the details of an account.

Return value

\Drupal\sendinblue\Tools\Model\GetAccount An array of account detail.

Overrides SendInBlueApiInterface::getAccount

File

src/Tools/Api/SendinblueApiV2.php, line 82

Class

SendinblueApiV2
Sendinblue REST client.

Namespace

Drupal\sendinblue\Tools\Api

Code

public function getAccount() {
  $account = $this->sIBHttpClient
    ->get("account", "");
  if ($account) {
    $accountData = $account['data'];
    return new GetAccount([
      'firstName' => $accountData[2]['first_name'],
      'lastName' => $accountData[2]['last_name'],
      'email' => $accountData[2]['email'],
      'companyName' => $accountData[2]['company'],
      'address' => [
        'city' => $accountData[2]['city'],
        'zipCode' => $accountData[2]['zip_code'],
        'country' => $accountData[2]['country'],
        'street' => $accountData[2]['address'],
      ],
      'plan' => [
        [
          'type' => $accountData[0]['plan_type'],
          'credits' => $accountData[0]['credits'],
          'creditsType' => $accountData[0]['credit_type'],
        ],
        [
          'type' => $accountData[1]['plan_type'],
          'credits' => $accountData[1]['credits'],
          'creditsType' => $accountData[1]['credit_type'],
        ],
      ],
    ]);
  }
  return null;
}