public static function batchDeliveryReport($json)
    {
        $fields = Deserialize::_fromJson($json);

        if (!isset($fields->type) || $fields->type != 'delivery_report_sms') {
            throw new UnexpectedResponseException(
                "Expected delivery report", $json
            );
        }

        $result = new Api\BatchDeliveryReport();
        $result->setBatchId($fields->batch_id);
        $result->setTotalMessageCount($fields->total_message_count);
        $result->setStatuses(
            array_map(
                function ($s) {
                    $r = new Api\BatchDeliveryReportStatus();
                    $r->setCode($s->code);
                    $r->setStatus($s->status);
                    $r->setCount($s->count);
                    if (isset($s->recipients)) {
                        $r->setRecipients($s->recipients);
                    }
                    return $r;
                },
                $fields->statuses
            )
        );

        return $result;
    }