Créer un client

Un client peut être une personne (particulier) ou une organisation (entreprise), pour créer une personne vous devez utiliser /apps/:appId/persons et pour une organisation /apps/:appId/organizations.

Pour créer une personne (particulier)

var myHeaders = new Headers();

myHeaders.append("Authorization", "Bearer <token>");

var formdata = new FormData();

formdata.append("civility", "Mr.");
formdata.append("firstname", "John");
formdata.append("lastname", "Doe");
formdata.append("picture", fileInput.files[0], "image.png");

var requestOptions = {
		method: 'POST',
		headers: myHeaders,
		body: formdata,
		redirect: 'follow'
};

fetch("https://api.sinao.app/v1/apps/:appId/persons?expand[]=relationship", requestOptions)
		.then(response => response.text())
		.then(result => console.log(result))
		.catch(error => console.log('error', error));

Pour créer une organisation (entreprise)

var myHeaders = new Headers();

myHeaders.append("Authorization", "Bearer <token>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "name": "SINAO",
  "billing_name": "SINAO",
  "national_id": "811340728",
  "vat_id": null,
  "legal_form": "SAS",
  "closeaccounting_period": "31/12",
  "establishments": [
    {
      "nic": "00047",
      "phone": "0600000000",
      "email": "[email protected]",
      "place": {
        "formatted_address": "29 CHE DE L EGLISE, GRENOBLE 38100"
      }
    }
  ],
  "code_naf": "6201Z"
});

var requestOptions = {
		method: 'POST',
		headers: myHeaders,
		body: raw,
		redirect: 'follow'
};

fetch("https://api.sinao.app/v1/apps/:appId/organizations", requestOptions)
		.then(response => response.text())
		.then(result => console.log(result))
		.catch(error => console.log('error', error));