package API::Command::GetClientInfo;
use strict;
use warnings;

use Data::Dumper;
use Apache2::Const qw(OK FORBIDDEN HTTP_OK HTTP_UNAUTHORIZED HTTP_NOT_FOUND);

use base 'API::Command';

sub area { return "client"; }
sub cmd  { return "info"; }

sub execute {
    my ($self) = @_;

    my $response = $self->SUPER::execute();
    return $response if ($response);

    my $clientID = $self->getRouteParam(":clientId");

    my $o = Common::DB::Item::Client->Lookup( client_id => $clientID, );

    if ( defined $o && $o->client_id ) {
        my %data = (
            client_id    => 0 + $o->client_id,
            client_name  => $o->client_name,
            display_name => $o->display_name,
            email        => $o->email,
        );
        return $self->createResponse(
            status => HTTP_OK,
            data   => \%data
        );
    }

    return $self->createResponse(
        status => HTTP_NOT_FOUND,
        data   => { msg => "not found" }
    );
}

1;
