manual_usuario:studio:fluxo:designer:scripts
Diferenças
Aqui você vê as diferenças entre duas revisões dessa página.
| manual_usuario:studio:fluxo:designer:scripts [2016/05/17 14:00] – [ConectarDBSistema] administrador | manual_usuario:studio:fluxo:designer:scripts [Data desconhecida] (atual) – edição externa (Data desconhecida) 127.0.0.1 | ||
|---|---|---|---|
| Linha 176: | Linha 176: | ||
| ### | ### | ||
| - | Os procedimentos entre Repeat e until é executado | + | Os procedimentos entre Repeat e until são executados |
| ### | ### | ||
| Linha 2646: | Linha 2646: | ||
| CloseFile(myFile); | CloseFile(myFile); | ||
| end; | end; | ||
| + | |||
| + | ======Biblioteca de Classes====== | ||
| + | ---- | ||
| + | |||
| + | Este tópico descreve e exemplifica o uso de classes utilizadas pelo WFS. | ||
| + | |||
| + | =====HTTP/ | ||
| + | ---- | ||
| + | |||
| + | **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( ' | ||
| + | channel := http.encodeParameter( ' | ||
| + | text := http.encodeParameter( 'Teste de *integração*' | ||
| + | username := http.encodeParameter( ' | ||
| + | // Precisa de SSL. | ||
| + | http.setSSL( true ); | ||
| + | response := http.doGet( ' | ||
| + | jsonObject := response.GetResponseJson(response.GetResponseString()); | ||
| + | except | ||
| + | showMessage( ' | ||
| + | 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( ' | ||
| + | channel := http.encodeParameter( ' | ||
| + | text := http.encodeParameter( 'Teste de *integração*' | ||
| + | username := http.encodeParameter( ' | ||
| + | // Precisa de SSL. | ||
| + | http.setSSL( true ); | ||
| + | response := http.doGet( ' | ||
| + | // Convertendo o retorno em JsonObject. | ||
| + | jsonObject := response.GetResponseJson(response.GetResponseString()); | ||
| + | except | ||
| + | showMessage( ' | ||
| + | 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( ' | ||
| + | // Precisa de SSL. | ||
| + | http.setSSL( true ); | ||
| + | url := ' | ||
| + | response := http.doGet( url ); | ||
| + | // Convertendo o retorno em JsonObject. | ||
| + | jsonObject := response.GetResponseJson(response.GetResponseString()); | ||
| + | jsonPair := response.getByName( jsonObject, ' | ||
| + | jsonArray := jsonPair.jsonValue; | ||
| + | for i := 0 to jsonArray.size - 1 do | ||
| + | begin | ||
| + | showMessage( TJsonObject( jsonArray.get(i) ).get(2).jsonValue.value ); | ||
| + | end; | ||
| + | | ||
| + | except | ||
| + | showMessage( ' | ||
| + | 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( ' | ||
| + | http.setPassWord( ' | ||
| + | // Será passado um Json. | ||
| + | http.setContentType( ' | ||
| + | // Default charset. | ||
| + | http.setCharset( ' | ||
| + | // Precisa de SSL. | ||
| + | http.setSSL( true ); | ||
| + | // Json em forma de string para ser passado como data para o doPost. | ||
| + | paramJson := '{ | ||
| + | " | ||
| + | " | ||
| + | | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | | ||
| + | } | ||
| + | }'; | ||
| + | // URL | ||
| + | url := ' | ||
| + | // 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, ' | ||
| + | | ||
| + | | ||
| + | showMessage( ' | ||
| + | | ||
| + | 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( ' | ||
| + | http.setPassWord( ' | ||
| + | // Será passado um Json. | ||
| + | http.setContentType( ' | ||
| + | // Default charset. | ||
| + | http.setCharset( ' | ||
| + | // Precisa de SSL. | ||
| + | http.setSSL( true ); | ||
| + | // Json em forma de string para ser passado como data para o doPost. | ||
| + | paramJson := '{ | ||
| + | " | ||
| + | " | ||
| + | | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | | ||
| + | } | ||
| + | }'; | ||
| + | // URL | ||
| + | url := ' | ||
| + | // 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, ' | ||
| + | | ||
| + | | ||
| + | showMessage( ' | ||
| + | | ||
| + | finally | ||
| + | http.Free(); | ||
| + | response.Free(); | ||
| + | end; | ||
| + | | ||
| + | end; | ||
| + | |||
manual_usuario/studio/fluxo/designer/scripts.1463493607.txt.gz · Última modificação: (edição externa)
