{
  "info": {
    "name": "API Melkal V1",
    "description": "Collection de l'API Melkal (clients). Renseignez les variables adresse_api et cle_api de la collection. Documentation : https://melkal.com/manuel/api-sommaire.html",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "adresse_api",
      "value": "https://app00api.exemple.fr",
      "description": "Votre adresse API, sans barre oblique finale."
    },
    {
      "key": "cle_api",
      "value": "VOTRE_CLE",
      "description": "Votre clé API."
    }
  ],
  "item": [
    {
      "name": "Test",
      "item": [
        {
          "name": "hello : tester la connexion",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{adresse_api}}/api/V1/hello?api_key={{cle_api}}",
              "host": [
                "{{adresse_api}}"
              ],
              "path": [
                "api",
                "V1",
                "hello"
              ],
              "query": [
                {
                  "key": "api_key",
                  "value": "{{cle_api}}"
                }
              ]
            },
            "description": "Vérifie la clé et l'activation de l'API."
          },
          "response": []
        }
      ]
    },
    {
      "name": "Clients",
      "item": [
        {
          "name": "Rechercher un client",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{adresse_api}}/api/V1/client?api_key={{cle_api}}&rechercheType=lienSocial&recherche=achats@dupont-sarl.fr",
              "host": [
                "{{adresse_api}}"
              ],
              "path": [
                "api",
                "V1",
                "client"
              ],
              "query": [
                {
                  "key": "api_key",
                  "value": "{{cle_api}}"
                },
                {
                  "key": "rechercheType",
                  "value": "lienSocial"
                },
                {
                  "key": "recherche",
                  "value": "achats@dupont-sarl.fr"
                }
              ]
            },
            "description": "rechercheType : code, id, uuid, idExterne, barcode ou lienSocial."
          },
          "response": []
        },
        {
          "name": "Lister, étape 1 : clients_initial",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{adresse_api}}/api/V1/clients_initial?api_key={{cle_api}}&nbParPage=50&filtreParDateModif=xJoursModif&dateModif=7",
              "host": [
                "{{adresse_api}}"
              ],
              "path": [
                "api",
                "V1",
                "clients_initial"
              ],
              "query": [
                {
                  "key": "api_key",
                  "value": "{{cle_api}}"
                },
                {
                  "key": "nbParPage",
                  "value": "50"
                },
                {
                  "key": "filtreParDateModif",
                  "value": "xJoursModif"
                },
                {
                  "key": "dateModif",
                  "value": "7"
                }
              ]
            },
            "description": "Renvoie un token. nbParPage est obligatoire (1 à 100)."
          },
          "response": []
        },
        {
          "name": "Lister, étape 2 : clients_token",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{adresse_api}}/api/V1/clients_token?api_key={{cle_api}}&token=COLLEZ_LE_TOKEN&page=1",
              "host": [
                "{{adresse_api}}"
              ],
              "path": [
                "api",
                "V1",
                "clients_token"
              ],
              "query": [
                {
                  "key": "api_key",
                  "value": "{{cle_api}}"
                },
                {
                  "key": "token",
                  "value": "COLLEZ_LE_TOKEN"
                },
                {
                  "key": "page",
                  "value": "1"
                }
              ]
            },
            "description": "Les pages commencent à 1. Une page au-delà de la dernière renvoie 404."
          },
          "response": []
        },
        {
          "name": "Créer un client",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{adresse_api}}/api/V1/client?api_key={{cle_api}}",
              "host": [
                "{{adresse_api}}"
              ],
              "path": [
                "api",
                "V1",
                "client"
              ],
              "query": [
                {
                  "key": "api_key",
                  "value": "{{cle_api}}"
                }
              ]
            },
            "description": "Avec clientModif à true, un client existant est mis à jour au lieu d'être refusé.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"clientModif\": false,\n  \"nom\": \"Dupont\",\n  \"prenom\": \"Martin\",\n  \"idExterne\": \"CRM-4821\",\n  \"sectionEntreprise\": {\n    \"entreprise\": \"Dupont Services\"\n  },\n  \"sectionSocial\": {\n    \"email\": \"achats@dupont-sarl.fr\",\n    \"emailPub\": true,\n    \"mobile\": \"0612345678\"\n  },\n  \"sectionAdresse\": {\n    \"adresse1\": \"3 rue des Écoles\",\n    \"cp\": \"29000\",\n    \"ville\": \"Quimper\"\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "response": []
        },
        {
          "name": "Modifier un client",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{adresse_api}}/api/V1/client?api_key={{cle_api}}",
              "host": [
                "{{adresse_api}}"
              ],
              "path": [
                "api",
                "V1",
                "client"
              ],
              "query": [
                {
                  "key": "api_key",
                  "value": "{{cle_api}}"
                }
              ]
            },
            "description": "Seul ce qui est envoyé est changé. La valeur ----- (cinq tirets) vide une valeur.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"sectionRecherche\": {\n    \"rechercheType\": \"lienSocial\",\n    \"recherche\": \"achats@dupont-sarl.fr\"\n  },\n  \"sectionModif\": {\n    \"nom\": \"Durand\",\n    \"sectionSocial\": {\n      \"sectionMobile\": {\n        \"mobile\": \"0698765432\"\n      }\n    }\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "response": []
        }
      ]
    }
  ]
}
