Récupération des offres d'un bordereau

1. Récupération du token d'authentification

La première étape consiste à récupérer un token pour pouvoir accéder aux apis sécurisées. Pour celà, nous effectuons un appel au /token en mode client_credentials

GET /token

application/x-www-form-urlencoded

Exemple:
POST /token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: api-v3.tourinsoft.com
Connection: Keep-Alive
grant_type=client_credentials&client_secret=secret&client_id=%241%24cdt79.tourinsoft.com
                

Réponse :

On récupère ainsi l' access_token qui va nous permettre d'authentifier toutes nos requêtes.

application/json, text/json

Exemple:
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json;charset=UTF-8
Expires: -1
Server: Microsoft-IIS/10.0
Access-Control-Allow-Origin: *
X-Powered-By: ASP.NET
Date: Thu, 12 Dec 2019 15:00:12 GMT
{
    "access_token": "TOKEN",
    "token_type": "bearer",
    "expires_in": 86399
}                   

2. Récupération de l'identifiant du bordereau Hôtel

Maintenant que nous avons récupéré le token, nous allons rechercher l'identifiant du bordereau Hôtel. Pour cela, on va utiliser l'api Bordereaux en ne sélectionnant que les propriétés qui nous intéressent (id, title et code) comme suit et récupérer l'identifiant dans la réponse :

GET /api/bordereaux

application/json

Exemple:
GET /api/bordereaux?fields=id,title,code HTTP/1.1
Content-Type: application/json
Host: api-v3.tourinsoft.com
Accept-Encoding: gzip,deflate
Authorization: Bearer TOKEN
Connection: Keep-Alive
                

Réponse :

application/json, text/json

Exemple:
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json;charset=UTF-8
Expires: -1
Server: Microsoft-IIS/10.0
Access-Control-Allow-Origin: *
X-Powered-By: ASP.NET
Date: Thu, 12 Dec 2019 15:01:49 GMT
[
    
    {
        "id": "19E17AF0-4680-4B1B-886A-BC147C3DDAE1",
        "title": "Fêtes et manifestations",
        "code": "FMA"
    },
    {
        "id": "3FC42F0F-6AA1-43A6-B694-E4FFDC505ACE",
        "title": "Hébergements locatifs (meublés et chambres d'hôtes)",
        "code": "HLO"
    },
    {
        "id": "1E8DC626-51A5-4ADF-9637-8E14925C1B6F",
        "title": "Hôtels",
        "code": "HOT"
    },
    {
        "id": "19CF534C-C722-405A-8021-3007CA115CF6",
        "title": "Patrimoine culturel",
        "code": "PCU"
    },
    {
        "id": "06ABA3B8-E254-4933-9593-117F61236D78",
        "title": "Patrimoine naturel",
        "code": "PNA"
    }
]                   

3. Récupération du premier lot d'offres pour le bordereau

Nous connaissons l'identifiant du bordereau Hôtel ("1E8DC626-51A5-4ADF-9637-8E14925C1B6F"), nous allons donc à présent commencer à récupérer les offres du bordereau.

GET /api/offres?bordereauId={bordereauId}

application/json

Exemple:
GET /api/offres?bordereauId=1E8DC626-51A5-4ADF-9637-8E14925C1B6F HTTP/1.1
Content-Type: application/json
Host: api-v3.tourinsoft.com
Accept-Encoding: gzip,deflate
Authorization: Bearer TOKEN
Connection: Keep-Alive
                

Réponse :

application/json, text/json

Exemple:
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json;charset=UTF-8
Expires: -1
Server: Microsoft-IIS/10.0
Access-Control-Allow-Origin: *
X-Powered-By: ASP.NET
Date: Thu, 12 Dec 2019 15:05:49 GMT
{
    "scroll": "cXVlcnlBbmRGZXRjaDsxOzQ5NTI4OjJMQmd0Vi1IU1gtTjRabW5BQTNsaUE7MDs=",
    "results": [
        {
            "id": "HOTAQU000V501RBJ",
            "created": "2019-11-18T09:50:56",
            "lastUpdated": "2019-12-09T09:18:57",
            "rubriques": {
                "46c": {
                    "occurrences": {
                        "225909505400000066": {
                            "order": 0,
                            "champs": {
                                "2s": {
                                    "value": "44e4e652-17c7-4d9d-b650-4d391e09686f"
                                }
                            }
                        }
                    }
                }
            }
        },
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...
    ],
    "totalCount": 101
    }
                  

Le résultat de l'api va vous retourner un lot de 20 offres. La propriété totalCount vous indique le nombre d'offres totales pour le bordereau. Pour récupérer la totalité des offres, vous allez devoir effectuer plusieurs appels, en ajoutant dans l'URI la propriété scroll.

4. Récupération de la totalité des offres pour le bordereau

Nous avons effectué un premier appel afin de récupérer le premier lot d'offres et récupérer la propriété scroll. Vous pouvez maintenant effectuer un autre appel avec la propriété scroll, afin d'obtenir le lot d'offres suivant.

GET /api/offres?bordereauId={bordereauId}&scroll={scroll}

application/json

Exemple:
GET /api/offres?bordereauId=1E8DC626-51A5-4ADF-9637-8E14925C1B6F&scroll=cXVlcnlBbmRGZXRjaDsxOzQ5NTI4OjJMQmd0Vi1IU1gtTjRabW5BQTNsaUE7MDs= HTTP/1.1
Content-Type: application/json
Host: api-v3.tourinsoft.com
Accept-Encoding: gzip,deflate
Authorization: Bearer TOKEN
Connection: Keep-Alive
                

Réponse :

application/json, text/json

Exemple:
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json;charset=UTF-8
Expires: -1
Server: Microsoft-IIS/10.0
Access-Control-Allow-Origin: *
X-Powered-By: ASP.NET
Date: Thu, 12 Dec 2019 15:06:09 GMT
{
    "scroll": "cXVlcnlBbmRGZXRjaDsxOzQ5NTI4OjJMQmd0Vi1IU1gtTjRabW5BQTNsaUE7MDs=",
    "results": [
        {
            "id": "HOTAQU000V501RBL",
            "created": "2019-11-18T10:01:16",
            "lastUpdated": "2019-11-18T10:02:56",
            "rubriques": {
                "46c": {
                    "occurrences": {
                        "225910011600000066": {
                            "order": 0,
                            "champs": {
                                "2s": {
                                    "value": "44e4e652-17c7-4d9d-b650-4d391e09686f"
                                }
                            }
                        }
                    }
                }
            }
        },
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...
    ],
    "totalCount": 101
    }
                  

Vous devez continuer les appels jusqu'à ce que la propriété results soit vide, cela voudra dire que vous avez terminé de récupérer l'intégralité des offres du bordereau.

5. Récupération des offres en langue étrangère

Vous devez procéder de la même façon que pour la langue FR, il faut juste ajouter le paramétre de la langue dans l'URI

GET /api/offres?bordereauId={bordereauId}&langue={langue}

application/json

Exemple:
GET /api/offres?bordereauId=1E8DC626-51A5-4ADF-9637-8E14925C1B6F&langue=en-GB HTTP/1.1
Content-Type: application/json
Host: api-v3.tourinsoft.com
Accept-Encoding: gzip,deflate
Authorization: Bearer TOKEN
Connection: Keep-Alive
                

Réponse :

application/json, text/json

Exemple:
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json;charset=UTF-8
Expires: -1
Server: Microsoft-IIS/10.0
Access-Control-Allow-Origin: *
X-Powered-By: ASP.NET
Date: Thu, 12 Dec 2019 15:05:49 GMT
{
    "scroll": "cXVlcnlBbmRGZXRjaDsxOzQ5NTI4OjJMQmd0Vi1IU1gtTjRabW5BQTNsaUE7MDs=",
    "results": [
        {
            "id": "HOTAQU024FS0000C",
            "created": "2019-11-18T09:50:56",
            "lastUpdated": "2019-12-09T09:18:57",
            "rubriques": {
                "496": {
                    "occurrences": {
                        "8790040277470023998": {
                            "order": 0,
                            "champs": {
                                "5mz": {
                                    "value": "Corinne and Bruno welcome you to their authentic residence which they have transformed into a relaxing, family hotel in the Vézère valley in the Dordogne.\nBook an attractive, comfortable room in this large bourgeois house for a romantic weekend or family holiday.  You can enjoy a gourmet meal in the restaurant prepared using local produce.  In the dining room, on the terrace or under the veranda, you can try our traditional cuisine which is a way of life in the Périgord.\nThe Périgord Noir is the ideal destination for discovering the authentic tourist sites - caves, chateaux, medieval villages, gardens and outstanding prehistoric sites."
                                },
                                "8ji": {
                                    "value": null
                                }
                            }
                        }
                    }
                }
            }
        },
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...,
        ...
    ],
    "totalCount": 101
    }
                  

Le résultat de l'api va vous retourner un lot de 20 offres comme pour la langue FR. Vous devez ensuite utiliser le scroll pour récupérer l'intégralité des offres dans la langue souhaitée.