Skip to content

Commit

Permalink
Adds account command
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius committed Mar 21, 2020
1 parent a7f863e commit e66dbe3
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/Commands/AccountCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace AcquiaCli\Commands;

use AcquiaCloudApi\Endpoints\Account;

/**
* Class AccountCommand
* @package AcquiaCli\Commands
*/
class AccountCommand extends AcquiaCommand
{

/**
* Gets information about the user's account.
*
* @command account
*/
public function account()
{
$tz = $this->extraConfig['timezone'];
$format = $this->extraConfig['format'];
$timezone = new \DateTimeZone($tz);

$accountAdapter = new Account($this->cloudapi);
$account = $accountAdapter->get();

$lastLogin = new \DateTime($account->last_login_at);
$lastLogin->setTimezone($timezone);
$createdAt = new \DateTime($account->created_at);
$createdAt->setTimezone($timezone);

$this->say(sprintf('Name: %s', $account->name));
$this->say(sprintf('Last login: %s', $lastLogin->format($format)));
$this->say(sprintf('Created at: %s', $createdAt->format($format)));
$this->say(sprintf('Status: %s', $account->flags->active ? '' : ' '));
$this->say(sprintf('TFA: %s', $account->flags->tfa ? '' : ' '));
}
}

0 comments on commit e66dbe3

Please sign in to comment.