Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.
Sommaire

Introduction

Les webhooks Métier permettent de manipuler une entité (client, contact, ...) à partir de l'extérieur via un appel de type http.
Les webhooks Métier implémentent une structure commune de leur contrat JSON.

Entête

Structure

Le JSON lors de l'appel au webHook devra contenir les éléments suivants :

Bloc de code
languagejson
{
  "header": 
    {
       "caller": how called the webhook ie.: infinity
       "callerVersion": version of the caller ie. 1.2.3.4
       "languageCode": FR, EN, DE, PT, ES, IT, FR-CA, EN-CA
       "userCode": user how called the webhook
       "callDateTime": initial call date/time, usefull when retries or whatever network issue
       "markForExport": value for srvExport of the table, can be 0, 1, 2 (optional, default is 1)
       "webhookVersion": version of the webhook for top-down compatibility, can be 1 or 2 (optional, default is 2). Today is used for webhook intervention, equipment and contract.
    },
    "action":
    {
       "verb": "value", // GET, PUT, DELETE, LIST, DEFINITION
       "parameters": 
        {
            // depends on the verb
        }
   },
   "data":
   {
       // depends on the webhook (used for verb = PUT to insert/update the data)      
   }
}

verb

...

PUT

Généralités

Permet d'écrire un enregistrement (Ajout/Mise à jour).

Bloc de code
languagejson
"action":
{
    "verb": "PUT"
    "parameters":
    {
      // for webhook file
      "entity": "value",
      "extension": "value"
    }
}

Le bloc data contient les données à créer/mettre à jour. Ce bloc est différent pour chaque webhook. Consultez la fiche expert de chaque webhook pour le détail.

Bloc de code
languagejson
"data":
{
    "xxxxx":
    {
        "codexxxxx": "value", // optional
        "field1": "value",
        "field2": "value",
        ....
    }
}

La possibilité est donné de faire des PUT par LOT en passant un tableau de data.
La variable Webhook.PUT.MaxElementAtOnce défini le nombre maximum d'éléments qui peuvent être passés à la fois (par défaut : 10). Ceci permet de tenir compte du timeout réseau.

Bloc de code
language
Info

L'initialisation du code d'un enregistrement se fera par ordre de priorité de la manière suivante lors de la création :

  1. Code fourni dans le json (et s'il n'existe pas encore, sinon on sera en modification)

  2. Utilisation du numbering si existant sur le code de l'entité.

  3. Code = ID de l'enregistrement (codexxxxx = xxxxx_ID)

PUT par lot

La possibilité est donné de faire des PUT par LOT en passant un tableau de data.
La variable Webhook.PUT.MaxElementAtOnce défini le nombre maximum d'éléments qui peuvent être passés à la fois (par défaut : 10). Ceci permet de tenir compte du timeout réseau.

Bloc de code
languagejson
"data":   
[{
    "xxxxx":
    {
        "codexxxxx": "value", // optional
        "field1": "value",
        "field2": "value",
        ....
    }
},
{
    "xxxxx":
    {
        "codexxxxx": "value", // optional
        "field1": "value",
        "field2": "value",
        ....
    }
},
{
    ....
}]

L'initialisation du code d'un enregistrement se fera par ordre de priorité de la manière suivante lors de la création :

  1. Code fourni dans le json (et s'il n'existe pas encore, sinon on sera en modification)

  2. Utilisation du numbering si existant sur le code de l'entité.

  3. Code = ID de l'enregistrement (codexxxxx = xxxxx_ID)

verb “DELETE”

...

Transcodage

Le champ mémoire “internalcodexxxxx” peut être alimenté lors du passage des données.

Ce champ représente le code original de weavy avant éventuel transcodage.

Il permet donc d’effectuer du transcodage dynamique directement par le webhook.

Syntaxe :

Bloc de code
"data":
{
    "xxxxx":
    {
        "codexxxxx": "value",
        "field1": "value",
        "field2": "value",        
        ....
        "internalcodexxxxx" : "value" 
    }
}

Tableau des possibilités :

"codexxxxx" = "A"

"internalcodexxxxx" = "B"

Résultat

"codexxxxx" = "A" existe en base

"codexxxxx" = "B" n’existe pas en base

Mise à jour de l'enregistrement dont "codexxxxx" = "A"

"codexxxxx" = "A" existe en base

"codexxxxx" = "B" existe en base

Mise à jour de l’enregistrement dont "codexxxxx" = "A"

"codexxxxx" = "A" n'existe pas en base

"codexxxxx" = "B" n’existe pas en base

Création de l’enregistrement avec "codexxxxx" = "A"

"codexxxxx" = ""

"codexxxxx" = "B" n’existe pas en base

Création de l’enregistrement avec "codexxxxx" = xxxxx_ID

"codexxxxx" = "A" n'existe pas en base

"codexxxxx" = "B" existe en base

Recodification de l’enregistrement "codexxxxx" = "B" en "codexxxxx" = "A" + mise à jour

"codexxxxx" = ""

"codexxxxx" = "B" existe en base

Mise à jour de l’enregistrement dont "codexxxxx" = "B"

verb DELETE

Permet de supprimer un enregistrement.

Bloc de code
languagejson
"action":
{
    "verb": "DELETE"
    "parameters": 
    {
        "code": code of the record to delete (mandatory)
        "deleteType": 
          "logical": no real delete in db (by default - not implemented at time)
          "physical": real delete, possible if record is not referred to elsewhere
          "simulation": simulate the delete (can be used to know in advance if a record can be deleted)
    }
} 

verb GET

Permet de lire un enregistrement.

Bloc de code
languagejson
"action":
{
    "verb": "GET"
    "parameters": 
    {
        "code": code of the record to get (mandatory)
        "resultType":
          "simple" : main info of the record (by default)
          "extended": all columns of the record 
          "extendedRelated": all columns of the record + given context (one entity per foreign key)
        "settings": 
        {
            // depends of the webhook (optional)
        }
    }
}

verb LIST

Permet de lister plusieurs enregistrements.

Bloc de code
languagejson
"action":
{
    "verb": "LIST" 
    "parameters": 
    {
        "listType": 
          "simple": main info of the record (by default), the columns are determined by each webhook
          "extended": all columns of the record 
          "extendedRelated": not used for verb="LIST"  
        "pageNumber": "xx" // used to read the page of the records list, 1 page = 10 records (optional, default pageNumber is 1)
                          You can read the list page per page until maxPageNumber (result of maxPageNumber given in the "response")   
        "settings": 
        {
            // depends of the webhook (optional)
        }
        "filters":              
        {
            // depends of the webhook (optional), each filter added will result is an AND in the query
            // For a filter operator "equal" it is possible to give more values separated by "|" (ie "email": "email1|email2|email3")
        }
        "orderBy" : "value" // depends of the webhook (optional), order the returned records (for example webhook event, the value can be "eventDateDesc" to order the records by event date descending)
        "topRows": "xx" // limit the returned records (optional)
    }
}

verb DEFINITION

Permet d’obtenir les propriétés de l'objet métier ainsi que les listes de valeurs possibles associées.

Bloc de code
languagejson
"verbaction":
DELETE
"parameters": 
{{
    "codeverb": code of the record to delete (mandatory)
   "deleteType": 
"DEFINITION"
     "logicalparameters":
no real delete in db (by default - not implemented at time){
           "physical"baseculture_id": real delete, possible if record is not referred"value" // (optional) Culture to use to elsewherereturn labels. If not given, the  "simulation": simulateLanguageCode of the deleteheader (canwill be used toby knowdefault.
in advance if a record can be deleted)
}
}

verb “GET”

...

Réponse

Structure

Bloc de code
languagejson
"verb": GET{
    "parameterslabel": 
{
   "code": code"Webhook xxx", //name of the recordcalled towebhook
get (mandatory)    "resultTypecodeScript":
      "simpleWebhookxxx", //script :called mainby infothe ofwebhook
the record (by default) "resultType": "JSON",
    "extendedresult":
all  columns of the{
record        "extendedRelatedcommon":
all columns of the record + given context (one entity per foreign key)  {
 "settings":     {      "resultCode": "0", // depends 0 if ok otherwise specific error of the webhook (optional)

  } }

verb “LIST”

Permet de lister plusieurs enregistrements.

Bloc de code
languagejson
"verb": LIST  "parameters":  {    "listTypeerrorMessage": "" // if resultCode <> 0, text of "simple": main info of the record (by default), the columns are determined by each webhookthe error in english
        },
        "extendedresponse":
all columns of the record      {
 "extendedRelated": not used for verb="LIST"      "pageNumber": "xx" // useddepends toof read the pagewebhook
of the records list, 1 page = 10 records}
(optional, default pageNumber is 1)},
    "statistics": 
    {
        "durationMs": xx, // duration of execution time
You can read the list page per page until maxPageNumber (result of maxPageNumber given in the "response")"consumedTimeOnDatabaseMs": xx, // DB time used
        "settingsselectQueryCount": xx, // number of {select query done
     // depends of the webhook (optional)
   }
   "filters":"insertQueryCount": xx, // number of insert query done
        "updateQueryCount": xx, // number of update query done
  {      "deleteQueryCount": xx, // dependsnumber of thedelete webhook (optional), each filter added will result is an AND in the queryquery done
        "readTokenCount": xx, 
      // For a filter operator "equal" it is possible to give more values separated by "|" (ie "email": "email1|email2|email3")
   }"executedFunctionCount": xx, // number of function called
        "translatorHitCount": xx, // number of translations done
        "orderBylanguageHitCount" : "value"xx //
depends of the webhook (optional),} order the returned records (for example webhook event, the value can be "eventDateDesc" to order the records by event date descending)
}

verb PUT

La réponse aura 1 section.

Bloc de code
languagejson
"response": 
{
    "maxElementAtOnce": "10" // max elements that can be passed at once
    "topRowsdata": "xx" // limit
the returned records (optional)
}

verb “DEFINITION”

Permet d’obtenir les propriétés de l'objet métier ainsi que les listes de valeurs possibles associées.

Bloc de code
languagejson
"verb": DEFINITION
"parameters":
{ [{
        "baseculture_idaction": "value", // (optional) Culture to use to return labels. If not given, the LanguageCode of the header will be used by default.
}

Réponse

Structure

Bloc de code
languagejson
{ inserted or updated
        "xxxxx_ID": "value", // with xxxxx = table and value is ID created/updated
        "labelcodexxxxx": "Webhook xxxvalue", //name ofwith thexxxx called= webhooktable and value is  "codeScript": "Webhookxxx", //script called by the webhook
    "resultType": "JSON",code created/updated
    }]
}

S'il s'agit d'un PUT par lot, le détail du résultat sera un tableau dimensionné selon la section "data" passée en entrée.

Bloc de code
languagejson
"result": 
{
    "resultresults": 
    [{
        "common": 
        {
            "resultCode": "0", // 0 if ok otherwise specific error of the webhook
            "errorMessage": "" // if resultCode <> 0, text of the error in english
        },
        "response":
        {
            // depends of the webhook
     of the error in english
   }     },
    "statistics":    "response": 
{        {
"durationMs": xx, // duration of execution time         "consumedTimeOnDatabaseMsmaxElementAtOnce": xx,"10" // DBmax timeelements usedthat can be passed at once
   "selectQueryCount": xx, // number of select query done
        "insertQueryCountdata": xx, //
number of insert query done        [{
"updateQueryCount": xx, // number of update query done         "deleteQueryCountaction": xx"value", // number of delete query doneinserted or updated
                "readTokenCountxxxxx_ID": xx"value", // with xxxxx = table and value is  "executedFunctionCount": xx, // number of function calledID created/updated
                "translatorHitCountcodexxxxx": xx,"value" /// number of translations done
   with xxxx = table and value is code created/updated
     "languageHitCount": xx      }]
    }

verb “PUT”

La réponse aura 1 section.

Bloc de code
languagejson
  "response":   }
{    },
"data":    {
 [{       "actioncommon": "value",
// inserted or updated
      "xxxxx_ID": "value", // with xxxxx ={
table and value is ID created/updated       "codexxxxxresultCode": "value0" // with xxxx = table and value is code created/updated,
            "errorMessage": ""
     }]   }

S'il s'agit d'un PUT par lot, le détail du résultat sera un tableau dimensionné selon la section "data" passée en entrée.

Bloc de code
languagejson
"result": 
,
        "response": 
        {
    "results": 
    [{        "maxElementAtOnce": "10" // max elements that can be passed at once
            "commondata": 
            [{
                "resultCodeaction": "0value", // 0 if ok otherwise
specific error of the webhook             "errorMessagexxxxx_ID": "value",
//  if resultCode <> 0, text of the error in english     "codexxxxx": "value"
  },         "response": }]
        {}
    },
    {
  "data":      ...
    }]
}

verb DELETE

La réponse aura 1 section.

Bloc de code
languagejson
"response": 
[{
    "data": 
    [{
        "action": "value", // inserted or updateddeleted"
    }]
}

verb GET

La réponse aura 2 sections.

Bloc de code
languagejson
"response":
{
    "data":
    [{ 
      "xxxxx_ID": "value", // with xxxxx = table and value is ID created/updated
  depends of the webhook
    }],
    "fieldList": 
    [{
        "codexxxxxentityName": "value", // with xxxx = table and value is code created/updated name of the entity (ie intervention)
        "fields":
        [{
       }]     "fieldName": "value", // name }of the field (ie codeintervention, }customer_ID, …)
   {         "commonfieldType": "value", // type of the field : varchar, text, int, double, bool, datetime, timestamp, {foreignkey
            "resultCodefieldLength": "0value", // length of the field : informed for varchar, text
   "errorMessage": ""         },
        "response": 
        {"fieldLabel": "value" // label of the field : depends on the value of the languageCode from the header (default : FR)
        },
   "data":     {
        [{    "fieldName": "value",
            "actionfieldType": "value",
 
              "xxxxx_IDfieldLength": "value",
   
            "codexxxxxfieldLabel": "value"
        },
        }]{
        }    ...
},     {   }],
     ...   "related": // }]
}

verb “DELETE”

La réponse aura 1 section.

Bloc de code
languagejson
  "response":for listType = "extendedRelated"
   {     "data":[{
     [{       "actionentityName": "deletedvalue",
     }]       }

verb “GET”

La réponse aura 2 sections.

Bloc de code
languagejson
"response"fields":
  {     "data":     [{
         // depends of the webhook   ...
 }],     "fieldList":      [{}]
      "entityName": "value", // name of the entity (ie intervention) },
     "fields":   {
   [{         "fieldNameentityName": "value",
// name of the field (ie codeintervention, customer_ID, …)            "fields":
            [{
"fieldType": "value", // type of the field : varchar, text, int, double, bool, datetime, timestamp, foreignkey ...
       "fieldLength": "value", // length of the}]
field : informed for varchar, text   },
     "fieldLabel": "value" // label{
of the field : depends on the value of the languageCode from the... header (default
: FR)       },]
    }] 
{
        "fieldName": "value",
   }  

verb LIST

La réponse aura 2 sections.

Bloc de code
languagejson
"response":
{
    "fieldTypemaxPageNumber": "value",
   xx, // number of pages of records
    "fieldLengthpageSize": "value",
   10, // number of records per page
    "fieldLabeldata":
"value"    [{ 
 },       {// depends of the webhook
    ...
      }],
      "related": // for listType = "extendedRelated"}],
    "fieldList": 
     [{
        "entityName": "value", // name of the entity (ie intervention)
        "fields":
        [{
          ...  "fieldName": "value", // name of the field }](ie       },
  codeintervention, customer_ID, …)
   {         "entityNamefieldType": "value",
        "fields":
        [{
    // type of the field : varchar, text, int, double, bool, datetime, timestamp, foreignkey
      ...      "fieldLength": "value", // }]length of the field : informed for }varchar, text
     {       "fieldLabel":  ...  
      }]
    }]    

verb “LIST”

La réponse aura 2 sections.

Bloc de code
languagejson
  "response":
  {"value" // label of the field : depends on the value of the languageCode from the header (default : FR)
       "maxPageNumber": xx}, //
number of pages of records    {
"pageSize": 10, // number of records per page     "datafieldName": "value",
   [{          // depends of the webhook"fieldType": "value",
      }],      "fieldListfieldLength": "value",
    [{        "entityNamefieldLabel": "value",
  // name of the entity (ie intervention)},
      "fields":  {
    [{         "fieldName": "value", // name of the field (ie codeintervention, customer_ID, …)
        "fieldType": "value", // type of the field : varchar, text, int, double, bool, datetime, timestamp, foreignkey...
        }],
    }]
}    

verb DEFINITION

La réponse aura 2 sections.

Bloc de code
languagejson
"response":
{
    "data":
    [{ 
        "fieldLengthfieldName1":
  "value", // length of the field :[{
informed for varchar, text         "fieldLabelcode": "value",
    // label of the field : depends on the"label": "value"
of the languageCode from the header (default : FR)},
      },   {
   {         "fieldNamecode": "value",
            "fieldTypelabel": "value"
        },
        {
       "fieldLength": "value",     ...
        "fieldLabel": "value"}
        }],
        {"fieldName2":
        ...[{
      }],     }] "code": "value",
  

verb “DEFINITION”

La réponse aura 2 sections.

Bloc de code
languagejson
  "response":   {     "datalabel": "value"
    [{    },
     // depends of the{
webhook         }],   "code": "value",
 As   an example for contact     "label": "generictype_ID_civility":value"
       [{ },
       "code": "CIVILITY-MR", {
       "label": "Monsieur"    ...
 },      { }
       "code": "CIVILITY-MME" }],
       "label": "Madame" ...
     }],
     "fieldList": 
    [{
        "entityName": "value", // name of the entity (ie intervention)
        "fields":
        [{
            "fieldName": "value", // name of the field (ie codeintervention, customer_ID, …)
            "fieldType": "value", // type of the field : varchar, text, int, double, bool, datetime, timestamp, foreignkey
            "fieldLength": "value", // length of the field : informed for varchar, text
            "fieldLabel": "value", // label of the field : depends on the value of the languageCode from the header (default : FR)
  : FR)         "fieldNameToShow": "value", // field alias for GET and LIST
            "alias": "value", // field alias for PUT
            "canGet": "value", // field can be read (0, 1)
            "canInsert": "value", // field can be updated for a new record (0, 1)
            "canUpdate": "value", // field can be updated for a existing record (0, 1)
            "mandatory": "value", // field is mandatory in sent json (0, 1)
            "canotBeNullcannotBeNull": "value", // field cannot be null or empty in sent json (0, 1)
            "dataType": "value" // data type for generictype foreignkey field
        },
        {
            "fieldName": "value",
            "fieldType": "value",
            "fieldLength": "value",
            "fieldLabel": "value",
            "fieldNameToShow": "value",
            "alias": "value",
            "canGet": "value",
            "canInsert": "value",
            "canUpdate": "value",
            "mandatory": "value",
            "canotBeNullcannotBeNull": "value",
            "dataType": "value"
        },
        {
            ...
        }],
        "related":
        [{
            "entityName": "value",
            "fields":
            [{
                ...
            }]
        },
        {
            "entityName": "value",
            "fields":
            [{
                ...
            }]
        },
        {
            ...  
        }]
    }]
    }