public reportStatusDeploy()

in src/script/acquisition-sdk.ts [149:207]


    public reportStatusDeploy(deployedPackage?: Package, status?: string, previousLabelOrAppVersion?: string, previousDeploymentKey?: string, callback?: Callback<void>): void {
        var url: string = this._serverUrl + this._publicPrefixUrl + "report_status/deploy";
        var body: DeploymentStatusReport = {
            app_version: this._appVersion,
            deployment_key: this._deploymentKey
        };

        if (this._clientUniqueId) {
            body.client_unique_id = this._clientUniqueId;
        }

        if (deployedPackage) {
            body.label = deployedPackage.label;
            body.app_version = deployedPackage.appVersion;

            switch (status) {
                case AcquisitionStatus.DeploymentSucceeded:
                case AcquisitionStatus.DeploymentFailed:
                    body.status = status;
                    break;

                default:
                    if (callback) {
                        if (!status) {
                            callback(new CodePushDeployStatusError("Missing status argument."), /*not used*/ null);
                        } else {
                            callback(new CodePushDeployStatusError("Unrecognized status \"" + status + "\"."), /*not used*/ null);
                        }
                    }
                    return;
            }
        }

        if (previousLabelOrAppVersion) {
            body.previous_label_or_app_version = previousLabelOrAppVersion;
        }

        if (previousDeploymentKey) {
            body.previous_deployment_key = previousDeploymentKey;
        }

        callback = typeof arguments[arguments.length - 1] === "function" && arguments[arguments.length - 1];

        this._httpRequester.request(Http.Verb.POST, url, JSON.stringify(body), (error: Error, response: Http.Response): void => {
            if (callback) {
                if (error) {
                    callback(error, /*not used*/ null);
                    return;
                }

                if (response.statusCode !== 200) {
                    callback(new CodePushHttpError(response.statusCode + ": " + response.body), /*not used*/ null);
                    return;
                }

                callback(/*error*/ null, /*not used*/ null);
            }
        });
    }