Ferramentas do usuário

Ferramentas do site


manual_usuario:studio:fluxo:designer:scripts

Diferenças

Aqui você vê as diferenças entre duas revisões dessa página.

Link para esta página de comparações

Ambos lados da revisão anterior Revisão anterior
Próxima revisão
Revisão anterior
manual_usuario:studio:fluxo:designer:scripts [2016/01/19 15:05]
administrador [Ord]
manual_usuario:studio:fluxo:designer:scripts [2017/05/31 11:41] (atual)
administrador Aprovado
Linha 176: Linha 176:
  
 ### ###
-Os procedimentos entre Repeat e until é executado ​na seqüência enquanto uma condição seja satisfeita.+Os procedimentos entre Repeat e until são executados ​na seqüência enquanto uma condição seja satisfeita.
 ### ###
  
Linha 342: Linha 342:
 Listagem das funções específicas do WFS. Listagem das funções específicas do WFS.
  
 +====ConectarDBSistema====
 +----
 +
 +###
 +A função estabelece uma conexão com um [[manual_usuario:​studio:​studio_objetivo_sistemas | sistema]] cadastrado e que possua uma conexão válida. O parâmetro passado deverá ser exatamente o nome do sistema.
 +###
 +
 +//Sintaxe//
 +
 +  ConectarDBSistema('​RH3'​);​
 +
 +//Exemplo//
 +
 +  conexao := ConectarDBSistema('​RH3'​);​
 =====Funções nativas===== =====Funções nativas=====
 ---- ----
Linha 1792: Linha 1806:
     fred := 'Good name';     fred := 'Good name';
     jim  := '​Badname ​ ';     jim  := '​Badname ​ ';
 +  ​
     try     try
       sMensagem := fred+' swapped = '​+SwapNames(fred);​       sMensagem := fred+' swapped = '​+SwapNames(fred);​
Linha 1808: Linha 1822:
   begin   begin
     Result := '';​     Result := '';​
 +  ​
     blankPos := Pos(' ', name);     blankPos := Pos(' ', name);
 +  ​
     nameLen := Length(name);​     nameLen := Length(name);​
     if (blankPos > 0) and (blankPos < nameLen)     if (blankPos > 0) and (blankPos < nameLen)
Linha 1820: Linha 1834:
         then Result := Copy(name, i, nameLen-i+1) + ' ' +         then Result := Copy(name, i, nameLen-i+1) + ' ' +
                        ​Copy(name,​ 1, blankPos-1)                        ​Copy(name,​ 1, blankPos-1)
 +  ​
         else Inc(i);         else Inc(i);
       until (i > nameLen) or (Length(Result) > 0);       until (i > nameLen) or (Length(Result) > 0);
     end;     end;
 +  ​
     if Length(Result) = 0     if Length(Result) = 0
     then Raise Exception.CreateFmt('​Invalid name : ''​%s''',​ [name]);     then Raise Exception.CreateFmt('​Invalid name : ''​%s''',​ [name]);
Linha 1840: Linha 1854:
     begin     begin
       exc := EBadAge.CreateFmt('​Bad age : %d',​[age]);​       exc := EBadAge.CreateFmt('​Bad age : %d',​[age]);​
 +  ​
       Raise exc;       Raise exc;
     end;     end;
Linha 1863: Linha 1877:
     int   : Integer;     int   : Integer;
     i     : Integer;     i     : Integer;
 +  ​
   begin   begin
     for i := 1 to 5 do     for i := 1 to 5 do
Linha 1870: Linha 1884:
       sMensagem := 'float = '​+FloatToStr(float);​       sMensagem := 'float = '​+FloatToStr(float);​
     end;     end;
 +  ​
     for i := 1 to 5 do     for i := 1 to 5 do
     begin     begin
Linha 1895: Linha 1909:
     myFile : TextFile;     myFile : TextFile;
     n1, n2, n3 : Integer;     n1, n2, n3 : Integer;
 +  ​
   begin   begin
     AssignFile(myFile,​ '​Test.txt'​);​     AssignFile(myFile,​ '​Test.txt'​);​
     ReWrite(myFile);​     ReWrite(myFile);​
 +  ​
     WriteLn(myFile,​ '1 2 3 4'​); ​  // Note that the 4 will be ignored     WriteLn(myFile,​ '1 2 3 4'​); ​  // Note that the 4 will be ignored
 +  ​
     WriteLn(myFile,​ 5, ' ', 6, ' ', 7);     WriteLn(myFile,​ 5, ' ', 6, ' ', 7);
 +  ​
     WriteLn(myFile,​ '8 9'​); ​      // Missing numbers will be seen as 0     WriteLn(myFile,​ '8 9'​); ​      // Missing numbers will be seen as 0
 +  ​
     CloseFile(myFile);​     CloseFile(myFile);​
 +  ​
     Reset(myFile);​     Reset(myFile);​
 +  ​
     while not Eof(myFile) do     while not Eof(myFile) do
     begin     begin
Linha 1917: Linha 1931:
                    ​IntToStr(n3);​                    ​IntToStr(n3);​
     end;     end;
 +  ​
     CloseFile(myFile);​     CloseFile(myFile);​
   end;   end;
Linha 1938: Linha 1952:
     myFile : TextFile;     myFile : TextFile;
     text   : string;     text   : string;
 +  ​
   begin   begin
     AssignFile(myFile,​ '​Test.txt'​);​     AssignFile(myFile,​ '​Test.txt'​);​
     ReWrite(myFile);​     ReWrite(myFile);​
 +  ​
     WriteLn(myFile,​ '​Hello'​);​     WriteLn(myFile,​ '​Hello'​);​
     WriteLn(myFile,​ '​World'​);​     WriteLn(myFile,​ '​World'​);​
 +  ​
     CloseFile(myFile);​     CloseFile(myFile);​
 +  ​
     FileMode := fmOpenRead;     FileMode := fmOpenRead;
     Reset(myFile);​     Reset(myFile);​
 +  ​
     while not Eof(myFile) do     while not Eof(myFile) do
     begin     begin
Linha 1956: Linha 1970:
       sMensagem := text;       sMensagem := text;
     end;     end;
 +  ​
     CloseFile(myFile);​     CloseFile(myFile);​
   end;   end;
Linha 1977: Linha 1991:
     myFile : TextFile;     myFile : TextFile;
     text   : string;     text   : string;
 +  ​
   begin   begin
     AssignFile(myFile,​ '​Test.txt'​);​     AssignFile(myFile,​ '​Test.txt'​);​
     Rewrite(myFile);​     Rewrite(myFile);​
 +  ​
     WriteLn(myFile,​ '​Hello'​);​     WriteLn(myFile,​ '​Hello'​);​
     WriteLn(myFile,​ '​World'​);​     WriteLn(myFile,​ '​World'​);​
 +  ​
     CloseFile(myFile);​     CloseFile(myFile);​
 +  ​
     Reset(myFile);​     Reset(myFile);​
 +  ​
     while not Eof(myFile) do     while not Eof(myFile) do
     begin     begin
Linha 1994: Linha 2008:
       sMensagem := text;       sMensagem := text;
     end;     end;
 +  ​
     CloseFile(myFile);​     CloseFile(myFile);​
   end;   end;
Linha 2088: Linha 2102:
   var   var
     number, squareRoot : Extended;     number, squareRoot : Extended;
 +  ​
   begin   begin
     number ​ := 225;     number ​ := 225;
     squareRoot := Sqrt(number);​     squareRoot := Sqrt(number);​
     sMensagem := '​Square root of ' + number + ' = ' squareRoot;     sMensagem := '​Square root of ' + number + ' = ' squareRoot;
 +  ​
     number ​ := 3.456;     number ​ := 3.456;
     squareRoot := Sqrt(number);​     squareRoot := Sqrt(number);​
     sMensagem := '​Square root of ' + number + ' = ' squareRoot;     sMensagem := '​Square root of ' + number + ' = ' squareRoot;
 +  ​
     number := Infinity;     number := Infinity;
     number := Sqrt(number);​     number := Sqrt(number);​
Linha 2117: Linha 2131:
   var   var
     myDate : TDateTime;     myDate : TDateTime;
 +  ​
   begin   begin
     myDate := StrToDate('​15/​03/​75'​);​     myDate := StrToDate('​15/​03/​75'​);​
Linha 2139: Linha 2153:
   var   var
     myDateTime : TDateTime;     myDateTime : TDateTime;
 +  ​
   begin   begin
     myDateTime := StrToDateTime('​23/​02/​75 ​  ​12'​);​     myDateTime := StrToDateTime('​23/​02/​75 ​  ​12'​);​
     sMensagem := '​23/​02/​75 ​  ​12 ​     = '​+DateTimeToStr(myDateTime);​     sMensagem := '​23/​02/​75 ​  ​12 ​     = '​+DateTimeToStr(myDateTime);​
 +  ​
     myDateTime := StrToDateTime('​23/​02/​2075 12:​34:​56'​);​     myDateTime := StrToDateTime('​23/​02/​2075 12:​34:​56'​);​
     sMensagem := '​23/​02/​2075 12:34:56 = '​+DateTimeToStr(myDateTime);​     sMensagem := '​23/​02/​2075 12:34:56 = '​+DateTimeToStr(myDateTime);​
Linha 2163: Linha 2177:
     stringValue : string;     stringValue : string;
     floatValue ​ : Extended;     floatValue ​ : Extended;
 +  ​
   begin   begin
     stringValue := '​123.456E+002';​     stringValue := '​123.456E+002';​
 +  ​
     floatValue ​ := StrToFloat(stringValue);​     floatValue ​ := StrToFloat(stringValue);​
 +  ​
     sMensagem := stringValue+'​ = '​+FloatToStr(floatValue);​     sMensagem := stringValue+'​ = '​+FloatToStr(floatValue);​
   end;   end;
Linha 2176: Linha 2190:
   var   var
     A : Extended;     A : Extended;
 +  ​
   begin   begin
     try     try
Linha 2183: Linha 2197:
       sMensagem := 'Erro de conversão';​       sMensagem := 'Erro de conversão';​
     end;     end;
 +  ​
     try     try
      A := StrToFloat('​$FF'​); ​   // Hexadecimal values are not supported      A := StrToFloat('​$FF'​); ​   // Hexadecimal values are not supported
Linha 2204: Linha 2218:
   var   var
     A, B, C, D, E, F : Integer;     A, B, C, D, E, F : Integer;
 +  ​
   begin   begin
     A := 32;     A := 32;
Linha 2212: Linha 2226:
     E := StrToInt('​-0x1E'​);​     E := StrToInt('​-0x1E'​);​
     F := A + B + C + D + E;     F := A + B + C + D + E;
 +  ​
     sMensagem := 'A : '​+IntToStr(A);​     sMensagem := 'A : '​+IntToStr(A);​
     sMensagem := 'B : '​+IntToStr(B);​     sMensagem := 'B : '​+IntToStr(B);​
Linha 2236: Linha 2250:
   var   var
     A, B, C, D, E, F : Integer;     A, B, C, D, E, F : Integer;
 +  ​
   begin   begin
     A := 32;     A := 32;
Linha 2244: Linha 2258:
     E := StrToIntDef('​-0x1E',​ 0);     E := StrToIntDef('​-0x1E',​ 0);
     F := A + B + C + D + E;     F := A + B + C + D + E;
 +  ​
     sMensagem := 'A : '​+IntToStr(A);​     sMensagem := 'A : '​+IntToStr(A);​
     sMensagem := 'B : '​+IntToStr(B);​     sMensagem := 'B : '​+IntToStr(B);​
Linha 2257: Linha 2271:
   var   var
     A : Integer;     A : Integer;
 +  ​
   begin   begin
     A := StrToIntDef('​100 ', 55);     A := StrToIntDef('​100 ', 55);
     sMensagem := 'Value = '​+IntToStr(A);​     sMensagem := 'Value = '​+IntToStr(A);​
 +  ​
     A := StrToIntDef('​$FG'​ , 66);     A := StrToIntDef('​$FG'​ , 66);
     sMensagem := 'Value = '​+IntToStr(A);​     sMensagem := 'Value = '​+IntToStr(A);​
Linha 2280: Linha 2294:
   var   var
     myTime : TDateTime;     myTime : TDateTime;
 +  ​
   begin   begin
     myTime := StrToTime('​3PM'​);​     myTime := StrToTime('​3PM'​);​
Linha 2325: Linha 2339:
   var   var
     myTime : TDateTime;     myTime : TDateTime;
 +  ​
   begin   begin
     myTime := StrToTime('​15:​22:​35'​);​     myTime := StrToTime('​15:​22:​35'​);​
Linha 2486: Linha 2500:
     text   : string;     text   : string;
     i      : Integer;     i      : Integer;
 +  ​
   begin   begin
     AssignFile(myFile,​ '​Test.txt'​);​     AssignFile(myFile,​ '​Test.txt'​);​
     ReWrite(myFile);​     ReWrite(myFile);​
 +  ​
     Write(myFile,​ 'Hello ');     Write(myFile,​ 'Hello ');
     Write(myFile,​ '​World'​);​     Write(myFile,​ '​World'​);​
 +  ​
     WriteLn(myFile);​     WriteLn(myFile);​
 +  ​
     for i := 2 to 4 do     for i := 2 to 4 do
       Write(myFile,​ i/2, ' ​ ');       Write(myFile,​ i/2, ' ​ ');
 +  ​
    ​WriteLn(myFile);​    ​WriteLn(myFile);​
 +  ​
     for i := 2 to 4 do     for i := 2 to 4 do
       Write(myFile,​ i/2:5:1);       Write(myFile,​ i/2:5:1);
 +  ​
     WriteLn(myFile);​     WriteLn(myFile);​
 +  ​
     CloseFile(myFile);​     CloseFile(myFile);​
 +  ​
     Reset(myFile);​     Reset(myFile);​
 +  ​
     while not Eof(myFile) do     while not Eof(myFile) do
     begin     begin
Linha 2515: Linha 2529:
       sMensagem := text;       sMensagem := text;
     end;     end;
 +  ​
     CloseFile(myFile);​     CloseFile(myFile);​
   end;   end;
Linha 2527: Linha 2541:
       male : Boolean;       male : Boolean;
     end;     end;
 +  ​
   var   var
     myFile ​  : File of TCustomer;     myFile ​  : File of TCustomer;
     customer : TCustomer;     customer : TCustomer;
 +  ​
   begin   begin
     AssignFile(myFile,​ '​Test.cus'​);​     AssignFile(myFile,​ '​Test.cus'​);​
     ReWrite(myFile);​     ReWrite(myFile);​
 +  ​
     customer.name := 'Fred Bloggs';​     customer.name := 'Fred Bloggs';​
     customer.age ​ := 21;     customer.age ​ := 21;
     customer.male := true;     customer.male := true;
     Write(myFile,​ customer);     Write(myFile,​ customer);
 +  ​
     customer.name := 'Jane Turner';​     customer.name := 'Jane Turner';​
     customer.age ​ := 45;     customer.age ​ := 45;
     customer.male := false;     customer.male := false;
     Write(myFile,​ customer);     Write(myFile,​ customer);
 +  ​
     CloseFile(myFile);​     CloseFile(myFile);​
 +  ​
     FileMode := fmOpenRead;     FileMode := fmOpenRead;
     Reset(myFile);​     Reset(myFile);​
 +  ​
     while not Eof(myFile) do     while not Eof(myFile) do
     begin     begin
Linha 2560: Linha 2574:
                         ' is '​+IntToStr(customer.age);​                         ' is '​+IntToStr(customer.age);​
     end;     end;
 +  ​
     CloseFile(myFile);​     CloseFile(myFile);​
   end;   end;
Linha 2569: Linha 2583:
     myWord, myWord1, myWord2 : Word;     myWord, myWord1, myWord2 : Word;
     myFile : File of Word;     myFile : File of Word;
 +  ​
   begin   begin
     AssignFile(myFile,​ '​Test.bin'​);​     AssignFile(myFile,​ '​Test.bin'​);​
     ReWrite(myFile);​     ReWrite(myFile);​
 +  ​
     myWord1 := 234;     myWord1 := 234;
     myWord2 := 567;     myWord2 := 567;
     Write(myFile,​ myWord1, myWord2);     Write(myFile,​ myWord1, myWord2);
 +  ​
     CloseFile(myFile);​     CloseFile(myFile);​
 +  ​
     FileMode := fmOpenRead;     FileMode := fmOpenRead;
     Reset(myFile);​     Reset(myFile);​
 +  ​
     while not Eof(myFile) do     while not Eof(myFile) do
     begin     begin
Linha 2588: Linha 2602:
       sMensagem := IntToStr(myWord);​       sMensagem := IntToStr(myWord);​
     end;     end;
 +  ​
     CloseFile(myFile);​     CloseFile(myFile);​
   end;   end;
Linha 2607: Linha 2621:
     myFile : TextFile;     myFile : TextFile;
     text   : string;     text   : string;
 +  ​
   begin   begin
     AssignFile(myFile,​ '​Test.txt'​);​     AssignFile(myFile,​ '​Test.txt'​);​
     ReWrite(myFile);​     ReWrite(myFile);​
 +  ​
     WriteLn(myFile,​ 'Hello World'​);​     WriteLn(myFile,​ 'Hello World'​);​
 +  ​
     WriteLn(myFile);​     WriteLn(myFile);​
 +  ​
     WriteLn(myFile,​ '22/7 = ' , 22/7);     WriteLn(myFile,​ '22/7 = ' , 22/7);
 +  ​
     WriteLn(myFile,​ '22/7 = ' , 22/7:12:6);     WriteLn(myFile,​ '22/7 = ' , 22/7:12:6);
 +  ​
     CloseFile(myFile);​     CloseFile(myFile);​
 +  ​
     Reset(myFile);​     Reset(myFile);​
 +  ​
     while not Eof(myFile) do     while not Eof(myFile) do
     begin     begin
Linha 2629: Linha 2643:
       sMensagem := text;       sMensagem := text;
     end;     end;
 +  ​
     CloseFile(myFile);​     CloseFile(myFile);​
   end;   end;
 +
 +======Biblioteca de Classes======
 +----
 +
 +Este tópico descreve e exemplifica o uso de classes utilizadas pelo WFS.
 +
 +=====HTTP/​REST via script=====
 +----
 +
 +**Exemplo 1: ** Testes de envio (SLACK) para uma pessoa especifica passando o nome de outras pessoa no username;
 +
 +  var
 +    http: TWHTTP;
 +    response: THTTResponse;​
 +    jsonObject: TJsonObject; ​
 +    token, channel, text, username: String;
 +    ​
 +  begin
 +             
 +    try
 +      try
 +        // Criando a conexão ​
 +        http := TWHTTP.create();​
 +        // Parâmetros necessários para o método GET.
 +        token := http.encodeParameter( '​xoxb-179556611860-ZhO1pl49DXlJOmbDp6nKU9jd'​ );
 +        channel := http.encodeParameter( '​@juliano.rafael'​ );
 +        text := http.encodeParameter( 'Teste de *integração*'​ );
 +        username := http.encodeParameter( '​@juliano.rafael'​ ); 
 +        // Precisa de SSL.
 +        http.setSSL( true );
 +        response :=  http.doGet( '​https://​slack.com/​api/​chat.postMessage?​token='​ + token + '&​channel='​ + channel + '&​text='​ + text + '&​username='​ + username );
 +        jsonObject := response.GetResponseJson(response.GetResponseString());​
 +      except
 +        showMessage( '​ocorreu erro' );  ​
 +      end;  ​
 +    finally
 +      http.Free();​
 +      response.Free();​
 +    end;
 +                            ​
 +  end;                       
 +
 +**Exemplo 2: ** Teste de envio para um canal se passando por um usuário;
 +
 +  var
 +    http: TWHTTP;
 +    response: THTTResponse;​
 +    jsonObject: TJsonObject; ​
 +    token, channel, text, username: String;
 +    ​
 +  begin
 +             
 +    try
 +      try
 +        // Criando a conexão ​
 +        http := TWHTTP.create();​
 +        // Parâmetros necessários para o método GET.
 +        token := http.encodeParameter( '​xoxb-179556611860-ZhO1pl49DXlJOmbDp6nKU9jd'​ );
 +        channel := http.encodeParameter( '​channel'​ );
 +        text := http.encodeParameter( 'Teste de *integração*'​ );
 +        username := http.encodeParameter( '​@juliano.rafael'​ ); 
 +        // Precisa de SSL.
 +        http.setSSL( true );
 +        response :=  http.doGet( '​https://​slack.com/​api/​chat.postMessage?​token='​ + token + '&​channel='​ + channel + '&​text='​ + text + '&​username='​ + username );
 +        // Convertendo o retorno em JsonObject.
 +        jsonObject := response.GetResponseJson(response.GetResponseString());​
 +      except
 +        showMessage( '​ocorreu erro' );  ​
 +      end;  ​
 +    finally
 +      http.Free();​
 +      response.Free();​
 +    end;
 +                            ​
 +  end;                       
 +
 +**Exemplo 3: ** Carregando lista de usuários do Slack;
 +
 +  var
 +    http: TWHTTP;
 +    response: THTTResponse;​
 +    jsonObject: TJsonObject; ​
 +    jsonPair: TJSonPair;
 +    jsonArray: TJsonArray;
 +    token, url: String;
 +    i: Integer; ​    
 +    ​
 +  begin              ​
 +             
 +    try
 +      try
 +        // Criando a conexão ​
 +        http := TWHTTP.create();​
 +        // Parâmetros necessários para o método GET.
 +        token := http.encodeParameter( '​xoxb-179556611860-ZhO1pl49DXlJOmbDp6nKU9jd'​ );
 +        // Precisa de SSL.
 +        http.setSSL( true );   
 +        url := '​https://​slack.com/​api/​users.list?​token='​ + token; ​
 +        response :=  http.doGet( url );
 +        // Convertendo o retorno em JsonObject.
 +        jsonObject := response.GetResponseJson(response.GetResponseString());​
 +        jsonPair := response.getByName( jsonObject, '​members'​ );
 +        jsonArray := jsonPair.jsonValue;​
 +        for i := 0 to jsonArray.size - 1 do
 +        begin 
 +          showMessage( TJsonObject( jsonArray.get(i) ).get(2).jsonValue.value );
 +        end;                            ​
 +        ​
 +      except
 +        showMessage( '​ocorreu erro' );  ​
 +      end;  ​
 +    finally
 +      http.Free();​
 +      response.Free();​
 +    end;
 +                            ​
 +  end;   
 +
 +**Exemplo 4: ** Inserindo Issue no Jira via basic authentication;​
 +
 +  var
 +    http: TWHTTP;
 +    response: THTTResponse;​
 +    jsonObject: TJsonObject; ​
 +    url, paramJson: String;
 +    ​
 +  begin              ​
 +             
 +    try
 +      try
 +        // Criando a conexão ​
 +        http := TWHTTP.create();​
 +        // Neste caso necessario autenticação básica
 +        http.setBasicAuthentication( true );
 +        http.setUser( '​board-jira@rh3software.com'​ );
 +        http.setPassWord( '​Rh3@1593576482'​ );
 +        // Será passado um Json.
 +        http.setContentType( '​application/​json'​ );
 +        // Default charset.
 +        http.setCharset( '​utf-8'​ );
 +        // Precisa de SSL.
 +        http.setSSL( true );
 +        // Json em forma de string para ser passado como data para o doPost.
 +        paramJson := '{
 +                      "​fields":​ {
 +                      "​project": ​                                    
 +                             ​{ ​  
 +                                "​key":​ "​RH3"​
 +                             },
 +                      "​summary":​ "​Segundo testes da API.",
 +                      "​description":​ "​Creating of an issue using project keys and issue type names using the REST API",
 +                      "​issuetype":​ {      ​
 +                          "​name":​ "​Bug" ​                
 +                         ​} ​                  
 +                     }
 +                  }'; ​                 ​
 +        // URL 
 +        url := '​https://​rh3software.atlassian.net/​rest/​api/​2/​issue'; ​
 +        // Response do doPost
 +        response :=  http.doPost( url, paramJson );                        ​
 +        // Convertendo o retorno em JsonObject.
 +        jsonObject := response.GetResponseJson(response.GetResponseString()); ​
 +        // Pegando o objeto retornado para mostrar a chave que foi incluída.
 +        showMessage( response.getByName( jsonObject, '​key'​ ).jsonValue.value );
 +        ​
 +       ​except
 +          showMessage( '​ocorreu erro' );  ​
 +       ​end;  ​
 +    finally
 +      http.Free();​
 +      response.Free();​
 +    end;
 +                    ​
 +  end;                                                                   
 +
 +**Exemplo 5: ** Retornando um statuscode >= 400 da api.
 +
 +  var
 +    http: TWHTTP;
 +    response: THTTResponse;​
 +    jsonObject: TJsonObject; ​
 +    url, paramJson: String;
 +    ​
 +  begin              ​
 +             
 +    try
 +      try
 +        // Criando a conexão ​
 +        http := TWHTTP.create();​
 +        // Neste caso necessario autenticação básica
 +        http.setBasicAuthentication( true );
 +        http.setUser( '​board-jira@rh3software.com'​ );
 +        http.setPassWord( '​Rh3@1593576482'​ );
 +        // Será passado um Json.
 +        http.setContentType( '​application/​json'​ );
 +        // Default charset. ​                                        
 +        http.setCharset( '​utf-8'​ );        ​
 +        // Precisa de SSL.
 +        http.setSSL( true );
 +        // Json em forma de string para ser passado como data para o doPost.
 +        paramJson := '{
 +                      "​fields":​ {
 +                      "​project": ​                                    
 +                             ​{ ​  
 +                                "​key":​ "​fdsafdas"​
 +                             },
 +                      "​summary":​ "REST ye merry gentlemen.",​
 +                      "​description":​ "​Creating of an issue using project keys and issue type names using the REST API",
 +                      "​issuetype":​ {                 
 +                          "​name":​ "​Bug" ​                
 +                         ​} ​                  
 +                     }
 +                  }'; ​                 ​
 +        // URL 
 +        url := '​https://​rh3software.atlassian.net/​rest/​api/​2/​issue'; ​
 +        // Response do doPost
 +        response :=  http.doPost( url, paramJson );                        ​
 +        // Convertendo o retorno em JsonObject.
 +        jsonObject := response.GetResponseJson(response.GetResponseString()); ​
 +        // Pegando o objeto retornado porem o statuscode > 400
 +        if response.getStatusCode() >= 400 then
 +          showMessage( TJsonObject( response.getByName( jsonObject, '​errors'​ ).jsonValue ).get(0).jsonValue.value );
 +        ​
 +       ​except
 +          showMessage( '​ocorreu erro' );  ​
 +       ​end;  ​
 +    finally
 +      http.Free();​
 +      response.Free();​
 +    end;
 +                    ​
 +  end;
 +
manual_usuario/studio/fluxo/designer/scripts.1453215931.txt.gz · Última modificação: 2016/01/19 15:05 (edição externa)