// 
// Created by the DataSnap proxy generator.
// 2012/05/01 17:52:38
// 

unit DSProxy;

interface
  uses
    Classes,
    DB,
    DSAdmin,
    DSRESTParameterMetaData,
    DBXFPCJson,
    DBXValue,
    DBXFPCCommon,
    DSRESTConnection, DSRestTypes;

  type
    TServerMethods1 = class(TDSAdmin)
    private
      FTServerMethods1_EchoString: TDSRESTParameterMetaDataArray;
      FTServerMethods1_ReverseString: TDSRESTParameterMetaDataArray;
      FTServerMethods1_GetEmployees: TDSRESTParameterMetaDataArray;
    protected
      procedure TServerMethods1_EchoString;
      procedure TServerMethods1_ReverseString;
      procedure TServerMethods1_GetEmployees;
    public
      destructor Destroy;override;

      (*
       * @param Value [in] - Type on server: string
       * @return result - Type on server: string
       *)
      function EchoString(Value: string):string;

      (*
       * @param Value [in] - Type on server: string
       * @return result - Type on server: string
       *)
      function ReverseString(Value: string):string;

      (*
       * @return result - Type on server: TDataSet
       *)
      function GetEmployees():TDataSet;
    end;

implementation


{TServerMethods1}

procedure TServerMethods1.TServerMethods1_EchoString;
begin
  if Length(FTServerMethods1_EchoString) = 0 then
  begin
    SetLength(FTServerMethods1_EchoString, 2);
    FTServerMethods1_EchoString[0] := TDSRESTParameterMetaData.CreateParam( 'Value',Input,WideStringType,'string');
    FTServerMethods1_EchoString[1] := TDSRESTParameterMetaData.CreateParam( '',ReturnValue,WideStringType,'string');
  end;
end;

procedure TServerMethods1.TServerMethods1_ReverseString;
begin
  if Length(FTServerMethods1_ReverseString) = 0 then
  begin
    SetLength(FTServerMethods1_ReverseString, 2);
    FTServerMethods1_ReverseString[0] := TDSRESTParameterMetaData.CreateParam( 'Value',Input,WideStringType,'string');
    FTServerMethods1_ReverseString[1] := TDSRESTParameterMetaData.CreateParam( '',ReturnValue,WideStringType,'string');
  end;
end;

procedure TServerMethods1.TServerMethods1_GetEmployees;
begin
  if Length(FTServerMethods1_GetEmployees) = 0 then
  begin
    SetLength(FTServerMethods1_GetEmployees, 1);
    FTServerMethods1_GetEmployees[0] := TDSRESTParameterMetaData.CreateParam( '',ReturnValue,TableType,'TDataSet');
  end;
end;
destructor TServerMethods1.Destroy;
begin
   TDSRESTParameterMetaData.releaseArray(FTServerMethods1_EchoString);
   TDSRESTParameterMetaData.releaseArray(FTServerMethods1_ReverseString);
   TDSRESTParameterMetaData.releaseArray(FTServerMethods1_GetEmployees);
  inherited;
end;

(*
 * @param Value [in] - Type on server: string
 * @return result - Type on server: string
 *)
function TServerMethods1.EchoString( value:string):string;
var
  cmd: TDSRestCommand;
begin
  cmd := Connection.createCommand;
  try
    cmd.RequestType := GET;
    cmd.text := 'TServerMethods1.EchoString';
    TServerMethods1_EchoString;
    cmd.prepare(FTServerMethods1_EchoString);
    cmd.parameters.items[0].Value.AsString:=value;
    Connection.execute(cmd);
    
    result:= cmd.parameters.items[1].Value.AsString;
  finally
    cmd.free;
  end;
end;

(*
 * @param Value [in] - Type on server: string
 * @return result - Type on server: string
 *)
function TServerMethods1.ReverseString( value:string):string;
var
  cmd: TDSRestCommand;
begin
  cmd := Connection.createCommand;
  try
    cmd.RequestType := GET;
    cmd.text := 'TServerMethods1.ReverseString';
    TServerMethods1_ReverseString;
    cmd.prepare(FTServerMethods1_ReverseString);
    cmd.parameters.items[0].Value.AsString:=value;
    Connection.execute(cmd);
    
    result:= cmd.parameters.items[1].Value.AsString;
  finally
    cmd.free;
  end;
end;

(*
 * @return result - Type on server: TDataSet
 *)
function TServerMethods1.GetEmployees():TDataSet;
var
  cmd: TDSRestCommand;
begin
  cmd := Connection.createCommand;
  try
    cmd.RequestType := GET;
    cmd.text := 'TServerMethods1.GetEmployees';
    TServerMethods1_GetEmployees;
    cmd.prepare(FTServerMethods1_GetEmployees);
    Connection.execute(cmd);
    
    result:= cmd.parameters.items[0].Value.AsTable as TDataSet;
  finally
    cmd.free;
  end;
end;
end.
