/*
 * Copyright 2015-2017 Atomist Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import * as herokuAppApi from "../HerokuApp";
import { Commit } from "./Commit";
export { HerokuApp };

/**
 * Type HerokuApp
 * Generated class exposing Atomist Cortex.
 * Fluent builder style class for use in testing and query by example.
 */
class HerokuApp implements herokuAppApi.HerokuApp {

    private _app: string;
    private _appId: string;
    private _commits: Commit[];
    private _release: string;
    private _timestamp: string;
    private _url: string;
    private _user: string;

    private _nodeName = "HerokuApp";
    private _nodeTags = [ "HerokuApp", "-dynamic" ];

    /**
     * Implementation of GraphNode interface method.
     * For infrastructure, not user use
     */
    public nodeName(): string {
        return this._nodeName;
    }

    /**
     * Implementation of GraphNode interface method.
     * For infrastructure, not user use
     */
    public nodeTags(): string[] {
        return this._nodeTags;
    }

    /**
     * app
     *
     * @property {string} app
     */
    get app(): string {
        if (this._app === undefined) {
            throw new Error(`Please use the relevant builder method to set property [app] on stub ` +
                `[HerokuApp] before accessing it. It's probably called [withApp]`);
        }
        return this._app;
    }

    /**
     * Fluent builder method to set the app property
     */
    public withApp(app_: string) {
        this._app = app_;
        return this;
    }

    /**
     * appId
     *
     * @property {string} appId
     */
    get appId(): string {
        if (this._appId === undefined) {
            throw new Error(`Please use the relevant builder method to set property [appId] on stub ` +
                `[HerokuApp] before accessing it. It's probably called [withAppId]`);
        }
        return this._appId;
    }

    /**
     * Fluent builder method to set the appId property
     */
    public withAppId(appId_: string) {
        this._appId = appId_;
        return this;
    }

    /**
     * commits - HerokuApp -> Commit
     *
     * @property {Commit[]} commits
     */
    get commits(): Commit[] {
        if (this._commits === undefined) {
            throw new Error(`Please use the relevant builder method to set property [commits] on stub ` +
                `[HerokuApp] before accessing it. It's probably called [withCommits]`);
        }
        return this._commits;
    }

    /**
     * Fluent builder method to add an element to the commits array
     */
    public addCommits(...commits_: Commit[]) {
        if (this._commits === undefined) {
            this._commits = [];
        }
        this._commits = this._commits.concat(commits_);
        return this;
    }

    /**
     * release
     *
     * @property {string} release
     */
    get release(): string {
        if (this._release === undefined) {
            throw new Error(`Please use the relevant builder method to set property [release] on stub ` +
                `[HerokuApp] before accessing it. It's probably called [withRelease]`);
        }
        return this._release;
    }

    /**
     * Fluent builder method to set the release property
     */
    public withRelease(release_: string) {
        this._release = release_;
        return this;
    }

    /**
     * timestamp
     *
     * @property {string} timestamp
     */
    get timestamp(): string {
        if (this._timestamp === undefined) {
            throw new Error(`Please use the relevant builder method to set property [timestamp] on stub ` +
                `[HerokuApp] before accessing it. It's probably called [withTimestamp]`);
        }
        return this._timestamp;
    }

    /**
     * Fluent builder method to set the timestamp property
     */
    public withTimestamp(timestamp_: string) {
        this._timestamp = timestamp_;
        return this;
    }

    /**
     * url
     *
     * @property {string} url
     */
    get url(): string {
        if (this._url === undefined) {
            throw new Error(`Please use the relevant builder method to set property [url] on stub ` +
                `[HerokuApp] before accessing it. It's probably called [withUrl]`);
        }
        return this._url;
    }

    /**
     * Fluent builder method to set the url property
     */
    public withUrl(url_: string) {
        this._url = url_;
        return this;
    }

    /**
     * user
     *
     * @property {string} user
     */
    get user(): string {
        if (this._user === undefined) {
            throw new Error(`Please use the relevant builder method to set property [user] on stub ` +
                `[HerokuApp] before accessing it. It's probably called [withUser]`);
        }
        return this._user;
    }

    /**
     * Fluent builder method to set the user property
     */
    public withUser(user_: string) {
        this._user = user_;
        return this;
    }

}
