/* tslint:disable */
/* eslint-disable */
//----------------------
// <auto-generated>
//     Generated using the NSwag toolchain v13.7.0.0 (NJsonSchema v10.1.24.0 (Newtonsoft.Json v12.0.0.0)) (http://NSwag.org)
// </auto-generated>
//----------------------
// ReSharper disable InconsistentNaming

export class MembershipServiceClient {
  private http: {
    fetch(url: RequestInfo, init?: RequestInit): Promise<Response>;
  };
  private baseUrl: string;
  protected jsonParseReviver:
    | ((key: string, value: any) => any)
    | undefined = undefined;

  constructor(
    baseUrl?: string,
    http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }
  ) {
    this.http = http ? http : <any>window;
    this.baseUrl = baseUrl ? baseUrl : "https://localhost:44389";
  }

  /**
   * @return Success
   */
  getClientById(id: number): Promise<ClientApiResponse> {
    let url_ = this.baseUrl + "/api/v1/Client/{id}";
    if (id === undefined || id === null)
      throw new Error("The parameter 'id' must be defined.");
    url_ = url_.replace("{id}", encodeURIComponent("" + id));
    url_ = url_.replace(/[?&]$/, "");

    let options_ = <RequestInit>{
      method: "GET",
      headers: {
        Accept: "application/json",
      },
    };

    return this.http.fetch(url_, options_).then((_response: Response) => {
      return this.processGetClientById(_response);
    });
  }

  protected processGetClientById(
    response: Response
  ): Promise<ClientApiResponse> {
    const status = response.status;
    let _headers: any = {};
    if (response.headers && response.headers.forEach) {
      response.headers.forEach((v: any, k: any) => (_headers[k] = v));
    }
    if (status === 200) {
      return response.text().then((_responseText) => {
        let result200: any = null;
        let resultData200 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result200 = ClientApiResponse.fromJS(resultData200);
        return result200;
      });
    } else if (status === 404) {
      return response.text().then((_responseText) => {
        let result404: any = null;
        let resultData404 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result404 = ClientApiResponse.fromJS(resultData404);
        return throwException(
          "Not Found",
          status,
          _responseText,
          _headers,
          result404
        );
      });
    } else if (status === 500) {
      return response.text().then((_responseText) => {
        let result500: any = null;
        let resultData500 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result500 = ClientApiResponse.fromJS(resultData500);
        return throwException(
          "Server Error",
          status,
          _responseText,
          _headers,
          result500
        );
      });
    } else if (status !== 200 && status !== 204) {
      return response.text().then((_responseText) => {
        return throwException(
          "An unexpected server error occurred.",
          status,
          _responseText,
          _headers
        );
      });
    }
    return Promise.resolve<ClientApiResponse>(<any>null);
  }

  /**
   * @param clientNumber (optional)
   * @return Success
   */
  getClientByNumber(
    clientNumber: number | undefined
  ): Promise<ClientApiResponse> {
    let url_ = this.baseUrl + "/api/v1/Client?";
    if (clientNumber === null)
      throw new Error("The parameter 'clientNumber' cannot be null.");
    else if (clientNumber !== undefined)
      url_ += "clientNumber=" + encodeURIComponent("" + clientNumber) + "&";
    url_ = url_.replace(/[?&]$/, "");

    let options_ = <RequestInit>{
      method: "GET",
      headers: {
        Accept: "application/json",
      },
    };

    return this.http.fetch(url_, options_).then((_response: Response) => {
      return this.processGetClientByNumber(_response);
    });
  }

  protected processGetClientByNumber(
    response: Response
  ): Promise<ClientApiResponse> {
    const status = response.status;
    let _headers: any = {};
    if (response.headers && response.headers.forEach) {
      response.headers.forEach((v: any, k: any) => (_headers[k] = v));
    }
    if (status === 200) {
      return response.text().then((_responseText) => {
        let result200: any = null;
        let resultData200 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result200 = ClientApiResponse.fromJS(resultData200);
        return result200;
      });
    } else if (status === 404) {
      return response.text().then((_responseText) => {
        let result404: any = null;
        let resultData404 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result404 = ClientApiResponse.fromJS(resultData404);
        return throwException(
          "Not Found",
          status,
          _responseText,
          _headers,
          result404
        );
      });
    } else if (status === 500) {
      return response.text().then((_responseText) => {
        let result500: any = null;
        let resultData500 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result500 = ClientApiResponse.fromJS(resultData500);
        return throwException(
          "Server Error",
          status,
          _responseText,
          _headers,
          result500
        );
      });
    } else if (status !== 200 && status !== 204) {
      return response.text().then((_responseText) => {
        return throwException(
          "An unexpected server error occurred.",
          status,
          _responseText,
          _headers
        );
      });
    }
    return Promise.resolve<ClientApiResponse>(<any>null);
  }

  /**
   * @param body (optional)
   * @return Success
   */
  createClient(body: Client | undefined): Promise<ClientApiResponse> {
    let url_ = this.baseUrl + "/api/v1/Client";
    url_ = url_.replace(/[?&]$/, "");

    const content_ = JSON.stringify(body);

    let options_ = <RequestInit>{
      body: content_,
      method: "POST",
      headers: {
        "Content-Type":
          "application/json;odata.metadata=minimal;odata.streaming=true",
        Accept: "application/json",
      },
    };

    return this.http.fetch(url_, options_).then((_response: Response) => {
      return this.processCreateClient(_response);
    });
  }

  protected processCreateClient(
    response: Response
  ): Promise<ClientApiResponse> {
    const status = response.status;
    let _headers: any = {};
    if (response.headers && response.headers.forEach) {
      response.headers.forEach((v: any, k: any) => (_headers[k] = v));
    }
    if (status === 201) {
      return response.text().then((_responseText) => {
        let result201: any = null;
        let resultData201 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result201 = ClientApiResponse.fromJS(resultData201);
        return result201;
      });
    } else if (status === 400) {
      return response.text().then((_responseText) => {
        let result400: any = null;
        let resultData400 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result400 = ClientApiResponse.fromJS(resultData400);
        return throwException(
          "Bad Request",
          status,
          _responseText,
          _headers,
          result400
        );
      });
    } else if (status === 500) {
      return response.text().then((_responseText) => {
        let result500: any = null;
        let resultData500 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result500 = ClientApiResponse.fromJS(resultData500);
        return throwException(
          "Server Error",
          status,
          _responseText,
          _headers,
          result500
        );
      });
    } else if (status !== 200 && status !== 204) {
      return response.text().then((_responseText) => {
        return throwException(
          "An unexpected server error occurred.",
          status,
          _responseText,
          _headers
        );
      });
    }
    return Promise.resolve<ClientApiResponse>(<any>null);
  }

  /**
   * @param body (optional)
   * @return Success
   */
  updateClient(body: Client | undefined): Promise<ClientApiResponse> {
    let url_ = this.baseUrl + "/api/v1/Client";
    url_ = url_.replace(/[?&]$/, "");

    const content_ = JSON.stringify(body);

    let options_ = <RequestInit>{
      body: content_,
      method: "PUT",
      headers: {
        "Content-Type":
          "application/json;odata.metadata=minimal;odata.streaming=true",
        Accept: "application/json",
      },
    };

    return this.http.fetch(url_, options_).then((_response: Response) => {
      return this.processUpdateClient(_response);
    });
  }

  protected processUpdateClient(
    response: Response
  ): Promise<ClientApiResponse> {
    const status = response.status;
    let _headers: any = {};
    if (response.headers && response.headers.forEach) {
      response.headers.forEach((v: any, k: any) => (_headers[k] = v));
    }
    if (status === 200) {
      return response.text().then((_responseText) => {
        let result200: any = null;
        let resultData200 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result200 = ClientApiResponse.fromJS(resultData200);
        return result200;
      });
    } else if (status === 400) {
      return response.text().then((_responseText) => {
        let result400: any = null;
        let resultData400 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result400 = ClientApiResponse.fromJS(resultData400);
        return throwException(
          "Bad Request",
          status,
          _responseText,
          _headers,
          result400
        );
      });
    } else if (status === 500) {
      return response.text().then((_responseText) => {
        let result500: any = null;
        let resultData500 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result500 = ClientApiResponse.fromJS(resultData500);
        return throwException(
          "Server Error",
          status,
          _responseText,
          _headers,
          result500
        );
      });
    } else if (status !== 200 && status !== 204) {
      return response.text().then((_responseText) => {
        return throwException(
          "An unexpected server error occurred.",
          status,
          _responseText,
          _headers
        );
      });
    }
    return Promise.resolve<ClientApiResponse>(<any>null);
  }

  /**
   * @return Success
   */
  getEmployeeById(id: number): Promise<EmployeeApiResponse> {
    let url_ = this.baseUrl + "/api/v1/Employee/{id}";
    if (id === undefined || id === null)
      throw new Error("The parameter 'id' must be defined.");
    url_ = url_.replace("{id}", encodeURIComponent("" + id));
    url_ = url_.replace(/[?&]$/, "");

    let options_ = <RequestInit>{
      method: "GET",
      headers: {
        Accept: "application/json",
      },
    };

    return this.http.fetch(url_, options_).then((_response: Response) => {
      return this.processGetEmployeeById(_response);
    });
  }

  protected processGetEmployeeById(
    response: Response
  ): Promise<EmployeeApiResponse> {
    const status = response.status;
    let _headers: any = {};
    if (response.headers && response.headers.forEach) {
      response.headers.forEach((v: any, k: any) => (_headers[k] = v));
    }
    if (status === 200) {
      return response.text().then((_responseText) => {
        let result200: any = null;
        let resultData200 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result200 = EmployeeApiResponse.fromJS(resultData200);
        return result200;
      });
    } else if (status === 404) {
      return response.text().then((_responseText) => {
        let result404: any = null;
        let resultData404 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result404 = EmployeeApiResponse.fromJS(resultData404);
        return throwException(
          "Not Found",
          status,
          _responseText,
          _headers,
          result404
        );
      });
    } else if (status === 500) {
      return response.text().then((_responseText) => {
        let result500: any = null;
        let resultData500 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result500 = EmployeeApiResponse.fromJS(resultData500);
        return throwException(
          "Server Error",
          status,
          _responseText,
          _headers,
          result500
        );
      });
    } else if (status !== 200 && status !== 204) {
      return response.text().then((_responseText) => {
        return throwException(
          "An unexpected server error occurred.",
          status,
          _responseText,
          _headers
        );
      });
    }
    return Promise.resolve<EmployeeApiResponse>(<any>null);
  }

  /**
   * @param employeeId (optional)
   * @return Success
   */
  getEmployeeByEmployeeId(
    employeeId: string | null | undefined
  ): Promise<EmployeeApiResponse> {
    let url_ = this.baseUrl + "/api/v1/Employee?";
    if (employeeId !== undefined && employeeId !== null)
      url_ += "employeeId=" + encodeURIComponent("" + employeeId) + "&";
    url_ = url_.replace(/[?&]$/, "");

    let options_ = <RequestInit>{
      method: "GET",
      headers: {
        Accept: "application/json",
      },
    };

    return this.http.fetch(url_, options_).then((_response: Response) => {
      return this.processGetEmployeeByEmployeeId(_response);
    });
  }

  protected processGetEmployeeByEmployeeId(
    response: Response
  ): Promise<EmployeeApiResponse> {
    const status = response.status;
    let _headers: any = {};
    if (response.headers && response.headers.forEach) {
      response.headers.forEach((v: any, k: any) => (_headers[k] = v));
    }
    if (status === 200) {
      return response.text().then((_responseText) => {
        let result200: any = null;
        let resultData200 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result200 = EmployeeApiResponse.fromJS(resultData200);
        return result200;
      });
    } else if (status === 404) {
      return response.text().then((_responseText) => {
        let result404: any = null;
        let resultData404 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result404 = EmployeeApiResponse.fromJS(resultData404);
        return throwException(
          "Not Found",
          status,
          _responseText,
          _headers,
          result404
        );
      });
    } else if (status === 500) {
      return response.text().then((_responseText) => {
        let result500: any = null;
        let resultData500 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result500 = EmployeeApiResponse.fromJS(resultData500);
        return throwException(
          "Server Error",
          status,
          _responseText,
          _headers,
          result500
        );
      });
    } else if (status !== 200 && status !== 204) {
      return response.text().then((_responseText) => {
        return throwException(
          "An unexpected server error occurred.",
          status,
          _responseText,
          _headers
        );
      });
    }
    return Promise.resolve<EmployeeApiResponse>(<any>null);
  }

  /**
   * @param body (optional)
   * @return Success
   */
  createEmployee(body: Employee | undefined): Promise<EmployeeApiResponse> {
    let url_ = this.baseUrl + "/api/v1/Employee";
    url_ = url_.replace(/[?&]$/, "");

    const content_ = JSON.stringify(body);

    let options_ = <RequestInit>{
      body: content_,
      method: "POST",
      headers: {
        "Content-Type":
          "application/json;odata.metadata=minimal;odata.streaming=true",
        Accept: "application/json",
      },
    };

    return this.http.fetch(url_, options_).then((_response: Response) => {
      return this.processCreateEmployee(_response);
    });
  }

  protected processCreateEmployee(
    response: Response
  ): Promise<EmployeeApiResponse> {
    const status = response.status;
    let _headers: any = {};
    if (response.headers && response.headers.forEach) {
      response.headers.forEach((v: any, k: any) => (_headers[k] = v));
    }
    if (status === 201) {
      return response.text().then((_responseText) => {
        let result201: any = null;
        let resultData201 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result201 = EmployeeApiResponse.fromJS(resultData201);
        return result201;
      });
    } else if (status === 400) {
      return response.text().then((_responseText) => {
        let result400: any = null;
        let resultData400 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result400 = EmployeeApiResponse.fromJS(resultData400);
        return throwException(
          "Bad Request",
          status,
          _responseText,
          _headers,
          result400
        );
      });
    } else if (status === 500) {
      return response.text().then((_responseText) => {
        let result500: any = null;
        let resultData500 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result500 = EmployeeApiResponse.fromJS(resultData500);
        return throwException(
          "Server Error",
          status,
          _responseText,
          _headers,
          result500
        );
      });
    } else if (status !== 200 && status !== 204) {
      return response.text().then((_responseText) => {
        return throwException(
          "An unexpected server error occurred.",
          status,
          _responseText,
          _headers
        );
      });
    }
    return Promise.resolve<EmployeeApiResponse>(<any>null);
  }

  /**
   * @param body (optional)
   * @return Success
   */
  updateEmployee(body: Employee | undefined): Promise<EmployeeApiResponse> {
    let url_ = this.baseUrl + "/api/v1/Employee";
    url_ = url_.replace(/[?&]$/, "");

    const content_ = JSON.stringify(body);

    let options_ = <RequestInit>{
      body: content_,
      method: "PUT",
      headers: {
        "Content-Type":
          "application/json;odata.metadata=minimal;odata.streaming=true",
        Accept: "application/json",
      },
    };

    return this.http.fetch(url_, options_).then((_response: Response) => {
      return this.processUpdateEmployee(_response);
    });
  }

  protected processUpdateEmployee(
    response: Response
  ): Promise<EmployeeApiResponse> {
    const status = response.status;
    let _headers: any = {};
    if (response.headers && response.headers.forEach) {
      response.headers.forEach((v: any, k: any) => (_headers[k] = v));
    }
    if (status === 200) {
      return response.text().then((_responseText) => {
        let result200: any = null;
        let resultData200 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result200 = EmployeeApiResponse.fromJS(resultData200);
        return result200;
      });
    } else if (status === 400) {
      return response.text().then((_responseText) => {
        let result400: any = null;
        let resultData400 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result400 = EmployeeApiResponse.fromJS(resultData400);
        return throwException(
          "Bad Request",
          status,
          _responseText,
          _headers,
          result400
        );
      });
    } else if (status === 500) {
      return response.text().then((_responseText) => {
        let result500: any = null;
        let resultData500 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result500 = EmployeeApiResponse.fromJS(resultData500);
        return throwException(
          "Server Error",
          status,
          _responseText,
          _headers,
          result500
        );
      });
    } else if (status !== 200 && status !== 204) {
      return response.text().then((_responseText) => {
        return throwException(
          "An unexpected server error occurred.",
          status,
          _responseText,
          _headers
        );
      });
    }
    return Promise.resolve<EmployeeApiResponse>(<any>null);
  }

  /**
   * @return Success
   */
  searchClients(): Promise<ClientApiResponse> {
    let url_ = this.baseUrl + "/api/v1/Search/clients";
    url_ = url_.replace(/[?&]$/, "");

    let options_ = <RequestInit>{
      method: "GET",
      headers: {
        Accept: "application/json",
      },
    };

    return this.http.fetch(url_, options_).then((_response: Response) => {
      return this.processSearchClients(_response);
    });
  }

  protected processSearchClients(
    response: Response
  ): Promise<ClientApiResponse> {
    const status = response.status;
    let _headers: any = {};
    if (response.headers && response.headers.forEach) {
      response.headers.forEach((v: any, k: any) => (_headers[k] = v));
    }
    if (status === 200) {
      return response.text().then((_responseText) => {
        let result200: any = null;
        let resultData200 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result200 = ClientApiResponse.fromJS(resultData200);
        return result200;
      });
    } else if (status === 404) {
      return response.text().then((_responseText) => {
        let result404: any = null;
        let resultData404 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result404 = ClientApiResponse.fromJS(resultData404);
        return throwException(
          "Not Found",
          status,
          _responseText,
          _headers,
          result404
        );
      });
    } else if (status === 500) {
      return response.text().then((_responseText) => {
        let result500: any = null;
        let resultData500 =
          _responseText === ""
            ? null
            : JSON.parse(_responseText, this.jsonParseReviver);
        result500 = ClientApiResponse.fromJS(resultData500);
        return throwException(
          "Server Error",
          status,
          _responseText,
          _headers,
          result500
        );
      });
    } else if (status !== 200 && status !== 204) {
      return response.text().then((_responseText) => {
        return throwException(
          "An unexpected server error occurred.",
          status,
          _responseText,
          _headers
        );
      });
    }
    return Promise.resolve<ClientApiResponse>(<any>null);
  }
}

export class Client implements IClient {
  id?: number;
  clientNumber?: number;
  name?: string | null;
  masterClientNumber?: number | null;
  masterClientName?: string | null;
  partnerNumber?: number | null;
  partnerName?: string | null;
  formOfOrganizationId?: number | null;
  formOfOrganizationDescription?: string | null;
  prefix?: string | null;
  firstName?: string | null;
  middleName?: string | null;
  lastName?: string | null;
  suffix?: string | null;
  statusId?: number | null;
  statusDescription?: string | null;
  officeName?: string | null;

  constructor(data?: IClient) {
    if (data) {
      for (var property in data) {
        if (data.hasOwnProperty(property))
          (<any>this)[property] = (<any>data)[property];
      }
    }
  }

  init(_data?: any) {
    if (_data) {
      this.id = _data["id"] !== undefined ? _data["id"] : <any>null;
      this.clientNumber =
        _data["clientNumber"] !== undefined ? _data["clientNumber"] : <any>null;
      this.name = _data["name"] !== undefined ? _data["name"] : <any>null;
      this.masterClientNumber =
        _data["masterClientNumber"] !== undefined
          ? _data["masterClientNumber"]
          : <any>null;
      this.masterClientName =
        _data["masterClientName"] !== undefined
          ? _data["masterClientName"]
          : <any>null;
      this.partnerNumber =
        _data["partnerNumber"] !== undefined
          ? _data["partnerNumber"]
          : <any>null;
      this.partnerName =
        _data["partnerName"] !== undefined ? _data["partnerName"] : <any>null;
      this.formOfOrganizationId =
        _data["formOfOrganizationId"] !== undefined
          ? _data["formOfOrganizationId"]
          : <any>null;
      this.formOfOrganizationDescription =
        _data["formOfOrganizationDescription"] !== undefined
          ? _data["formOfOrganizationDescription"]
          : <any>null;
      this.prefix = _data["prefix"] !== undefined ? _data["prefix"] : <any>null;
      this.firstName =
        _data["firstName"] !== undefined ? _data["firstName"] : <any>null;
      this.middleName =
        _data["middleName"] !== undefined ? _data["middleName"] : <any>null;
      this.lastName =
        _data["lastName"] !== undefined ? _data["lastName"] : <any>null;
      this.suffix = _data["suffix"] !== undefined ? _data["suffix"] : <any>null;
      this.statusId =
        _data["statusId"] !== undefined ? _data["statusId"] : <any>null;
      this.statusDescription =
        _data["statusDescription"] !== undefined
          ? _data["statusDescription"]
          : <any>null;
      this.officeName =
        _data["officeName"] !== undefined ? _data["officeName"] : <any>null;
    }
  }

  static fromJS(data: any): Client {
    data = typeof data === "object" ? data : {};
    let result = new Client();
    result.init(data);
    return result;
  }

  toJSON(data?: any) {
    data = typeof data === "object" ? data : {};
    data["id"] = this.id !== undefined ? this.id : <any>null;
    data["clientNumber"] =
      this.clientNumber !== undefined ? this.clientNumber : <any>null;
    data["name"] = this.name !== undefined ? this.name : <any>null;
    data["masterClientNumber"] =
      this.masterClientNumber !== undefined
        ? this.masterClientNumber
        : <any>null;
    data["masterClientName"] =
      this.masterClientName !== undefined ? this.masterClientName : <any>null;
    data["partnerNumber"] =
      this.partnerNumber !== undefined ? this.partnerNumber : <any>null;
    data["partnerName"] =
      this.partnerName !== undefined ? this.partnerName : <any>null;
    data["formOfOrganizationId"] =
      this.formOfOrganizationId !== undefined
        ? this.formOfOrganizationId
        : <any>null;
    data["formOfOrganizationDescription"] =
      this.formOfOrganizationDescription !== undefined
        ? this.formOfOrganizationDescription
        : <any>null;
    data["prefix"] = this.prefix !== undefined ? this.prefix : <any>null;
    data["firstName"] =
      this.firstName !== undefined ? this.firstName : <any>null;
    data["middleName"] =
      this.middleName !== undefined ? this.middleName : <any>null;
    data["lastName"] = this.lastName !== undefined ? this.lastName : <any>null;
    data["suffix"] = this.suffix !== undefined ? this.suffix : <any>null;
    data["statusId"] = this.statusId !== undefined ? this.statusId : <any>null;
    data["statusDescription"] =
      this.statusDescription !== undefined ? this.statusDescription : <any>null;
    data["officeName"] =
      this.officeName !== undefined ? this.officeName : <any>null;
    return data;
  }
}

export interface IClient {
  id?: number;
  clientNumber?: number;
  name?: string | null;
  masterClientNumber?: number | null;
  masterClientName?: string | null;
  partnerNumber?: number | null;
  partnerName?: string | null;
  formOfOrganizationId?: number | null;
  formOfOrganizationDescription?: string | null;
  prefix?: string | null;
  firstName?: string | null;
  middleName?: string | null;
  lastName?: string | null;
  suffix?: string | null;
  statusId?: number | null;
  statusDescription?: string | null;
  officeName?: string | null;
}

export class ApiError implements IApiError {
  isError?: boolean;
  exceptionMessage?: string | null;
  details?: string | null;

  constructor(data?: IApiError) {
    if (data) {
      for (var property in data) {
        if (data.hasOwnProperty(property))
          (<any>this)[property] = (<any>data)[property];
      }
    }
  }

  init(_data?: any) {
    if (_data) {
      this.isError =
        _data["isError"] !== undefined ? _data["isError"] : <any>null;
      this.exceptionMessage =
        _data["exceptionMessage"] !== undefined
          ? _data["exceptionMessage"]
          : <any>null;
      this.details =
        _data["details"] !== undefined ? _data["details"] : <any>null;
    }
  }

  static fromJS(data: any): ApiError {
    data = typeof data === "object" ? data : {};
    let result = new ApiError();
    result.init(data);
    return result;
  }

  toJSON(data?: any) {
    data = typeof data === "object" ? data : {};
    data["isError"] = this.isError !== undefined ? this.isError : <any>null;
    data["exceptionMessage"] =
      this.exceptionMessage !== undefined ? this.exceptionMessage : <any>null;
    data["details"] = this.details !== undefined ? this.details : <any>null;
    return data;
  }
}

export interface IApiError {
  isError?: boolean;
  exceptionMessage?: string | null;
  details?: string | null;
}

export class ClientApiResponse implements IClientApiResponse {
  statusCode?: number;
  message?: string | null;
  data?: Client;
  error?: ApiError;

  constructor(data?: IClientApiResponse) {
    if (data) {
      for (var property in data) {
        if (data.hasOwnProperty(property))
          (<any>this)[property] = (<any>data)[property];
      }
    }
  }

  init(_data?: any) {
    if (_data) {
      this.statusCode =
        _data["statusCode"] !== undefined ? _data["statusCode"] : <any>null;
      this.message =
        _data["message"] !== undefined ? _data["message"] : <any>null;
      this.data = _data["data"] ? Client.fromJS(_data["data"]) : <any>null;
      this.error = _data["error"] ? ApiError.fromJS(_data["error"]) : <any>null;
    }
  }

  static fromJS(data: any): ClientApiResponse {
    data = typeof data === "object" ? data : {};
    let result = new ClientApiResponse();
    result.init(data);
    return result;
  }

  toJSON(data?: any) {
    data = typeof data === "object" ? data : {};
    data["statusCode"] =
      this.statusCode !== undefined ? this.statusCode : <any>null;
    data["message"] = this.message !== undefined ? this.message : <any>null;
    data["data"] = this.data ? this.data.toJSON() : <any>null;
    data["error"] = this.error ? this.error.toJSON() : <any>null;
    return data;
  }
}

export interface IClientApiResponse {
  statusCode?: number;
  message?: string | null;
  data?: Client;
  error?: ApiError;
}

export class Employee implements IEmployee {
  id?: number;
  employeeId?: string | null;
  empId?: number | null;
  firstName?: string | null;
  lastName?: string | null;
  lineOfBusinessId?: number | null;
  emplStatus?: string | null;
  jobfunctionDescr?: string | null;
  workEmail?: string | null;

  constructor(data?: IEmployee) {
    if (data) {
      for (var property in data) {
        if (data.hasOwnProperty(property))
          (<any>this)[property] = (<any>data)[property];
      }
    }
  }

  init(_data?: any) {
    if (_data) {
      this.id = _data["id"] !== undefined ? _data["id"] : <any>null;
      this.employeeId =
        _data["employeeId"] !== undefined ? _data["employeeId"] : <any>null;
      this.empId = _data["empId"] !== undefined ? _data["empId"] : <any>null;
      this.firstName =
        _data["firstName"] !== undefined ? _data["firstName"] : <any>null;
      this.lastName =
        _data["lastName"] !== undefined ? _data["lastName"] : <any>null;
      this.lineOfBusinessId =
        _data["lineOfBusinessId"] !== undefined
          ? _data["lineOfBusinessId"]
          : <any>null;
      this.emplStatus =
        _data["emplStatus"] !== undefined ? _data["emplStatus"] : <any>null;
      this.jobfunctionDescr =
        _data["jobfunctionDescr"] !== undefined
          ? _data["jobfunctionDescr"]
          : <any>null;
      this.workEmail =
        _data["workEmail"] !== undefined ? _data["workEmail"] : <any>null;
    }
  }

  static fromJS(data: any): Employee {
    data = typeof data === "object" ? data : {};
    let result = new Employee();
    result.init(data);
    return result;
  }

  toJSON(data?: any) {
    data = typeof data === "object" ? data : {};
    data["id"] = this.id !== undefined ? this.id : <any>null;
    data["employeeId"] =
      this.employeeId !== undefined ? this.employeeId : <any>null;
    data["empId"] = this.empId !== undefined ? this.empId : <any>null;
    data["firstName"] =
      this.firstName !== undefined ? this.firstName : <any>null;
    data["lastName"] = this.lastName !== undefined ? this.lastName : <any>null;
    data["lineOfBusinessId"] =
      this.lineOfBusinessId !== undefined ? this.lineOfBusinessId : <any>null;
    data["emplStatus"] =
      this.emplStatus !== undefined ? this.emplStatus : <any>null;
    data["jobfunctionDescr"] =
      this.jobfunctionDescr !== undefined ? this.jobfunctionDescr : <any>null;
    data["workEmail"] =
      this.workEmail !== undefined ? this.workEmail : <any>null;
    return data;
  }
}

export interface IEmployee {
  id?: number;
  employeeId?: string | null;
  empId?: number | null;
  firstName?: string | null;
  lastName?: string | null;
  lineOfBusinessId?: number | null;
  emplStatus?: string | null;
  jobfunctionDescr?: string | null;
  workEmail?: string | null;
}

export class EmployeeApiResponse implements IEmployeeApiResponse {
  statusCode?: number;
  message?: string | null;
  data?: Employee;
  error?: ApiError;

  constructor(data?: IEmployeeApiResponse) {
    if (data) {
      for (var property in data) {
        if (data.hasOwnProperty(property))
          (<any>this)[property] = (<any>data)[property];
      }
    }
  }

  init(_data?: any) {
    if (_data) {
      this.statusCode =
        _data["statusCode"] !== undefined ? _data["statusCode"] : <any>null;
      this.message =
        _data["message"] !== undefined ? _data["message"] : <any>null;
      this.data = _data["data"] ? Employee.fromJS(_data["data"]) : <any>null;
      this.error = _data["error"] ? ApiError.fromJS(_data["error"]) : <any>null;
    }
  }

  static fromJS(data: any): EmployeeApiResponse {
    data = typeof data === "object" ? data : {};
    let result = new EmployeeApiResponse();
    result.init(data);
    return result;
  }

  toJSON(data?: any) {
    data = typeof data === "object" ? data : {};
    data["statusCode"] =
      this.statusCode !== undefined ? this.statusCode : <any>null;
    data["message"] = this.message !== undefined ? this.message : <any>null;
    data["data"] = this.data ? this.data.toJSON() : <any>null;
    data["error"] = this.error ? this.error.toJSON() : <any>null;
    return data;
  }
}

export interface IEmployeeApiResponse {
  statusCode?: number;
  message?: string | null;
  data?: Employee;
  error?: ApiError;
}

export class ApiException extends Error {
  message: string;
  status: number;
  response: string;
  headers: { [key: string]: any };
  result: any;

  constructor(
    message: string,
    status: number,
    response: string,
    headers: { [key: string]: any },
    result: any
  ) {
    super();

    this.message = message;
    this.status = status;
    this.response = response;
    this.headers = headers;
    this.result = result;
  }

  protected isApiException = true;

  static isApiException(obj: any): obj is ApiException {
    return obj.isApiException === true;
  }
}

function throwException(
  message: string,
  status: number,
  response: string,
  headers: { [key: string]: any },
  result?: any
): any {
  if (result !== null && result !== undefined) throw result;
  else throw new ApiException(message, status, response, headers, null);
}
