public function build(array $data)
    {
        $this->validateArrayKeys(
            array('id', 'create_time', 'update_time', 'state', 'intent', 'payer', 'transactions', 'links'),
            $data
        );

        if (empty($data['id'])) {
            throw new BuilderException('id is mandatory and should not be empty');
        }

        $payer = $this->payerBuilder->build($data['payer']);
        $transactions = $this->transactionsBuilder->build($data['transactions']);

        $links = array();
        foreach ($data['links'] as $link) {
            $links[] = $this->linkBuilder->build($link);
        }

        if ($data['payer']['payment_method'] === 'paypal') {
            $authorization = new PaypalPaymentAuthorization(
                $data['id'],
                $data['create_time'],
                $data['state'],
                $data['intent'],
                $payer,
                $transactions,
                $links,
                $data['update_time']
            );
            $authorization->setPaypalData($data);

            return $authorization;
        }

        $authorization = new CreditCardPaymentAuthorization(
            $data['id'],
            $data['create_time'],
            $data['state'],
            $data['intent'],
            $payer,
            $transactions,
            $links,
            $data['update_time']
        );
        $authorization->setPaypalData($data);

        return $authorization;
    }