# ShipmentsList

## ShipmentsList

Questo endpoint permette di ottenere l'elenco delle spedizioni.&#x20;

{% hint style="info" %}
L'utilizzo delle url **previousPageUrl** e **nextPageUrl** presenti nella risposta non è obbligatorio ma è consigliato perché permette di velocizzare notevolmente la chiamata.
{% endhint %}

## ShipmentsList

<mark style="color:blue;">`GET`</mark> `https://api.gsped.it/[ISTANZA]/ShipmentsList`

Recupera un elenco di spedizioni&#x20;

#### Query Parameters

| Name                                       | Type         | Description                                                                                                                                                                                                                |
| ------------------------------------------ | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| data\_da<mark style="color:red;">\*</mark> | Y-m-d H:i:s  | seleziona se data\_*created >= data\_da*                                                                                                                                                                                   |
| data\_a<mark style="color:red;">\*</mark>  | Y-m-d H:i:s  | seleziona se data*created < data\_da*                                                                                                                                                                                      |
| corriere                                   | int \| array | seleziona se corriere IN \[id, id...]                                                                                                                                                                                      |
| servizio                                   | int \| array | seleziona se servizio IN \[id, id...]                                                                                                                                                                                      |
| cliente                                    | int \| array | seleziona se client\_id IN \[id, id...]                                                                                                                                                                                    |
| fatt\_cliente                              | int \| array | seleziona invoiced\_*client\_*&#x69;d IN \[id, id...]                                                                                                                                                                      |
| nazionale                                  | 1/0          | <p><strong>1</strong> seleziona se <code>rcpt\_country\_code</code> = <code>sender\_country\_code</code><br><strong>0</strong> seleziona se <code>rcpt\_country\_code</code> != <code>sender\_country\_code</code><br></p> |
| contrassegno                               | 1/0          | <p><strong>1</strong> seleziona se contrassegno > 0<br><strong>0</strong> seleziona se contrassegno <= 0</p>                                                                                                               |
| assicurazione                              | 1/0          | <p><strong>1</strong> seleziona se assicurazione > 0<br><strong>0</strong> seleziona se assicurazione <= 0 OR NULL</p>                                                                                                     |
| confermato                                 | 1/0          | <p><strong>1</strong> seleziona se confermato = 1<br><strong>0</strong> seleziona se confermato = 0</p>                                                                                                                    |
| documenti                                  | 1/0          | <p><strong>1</strong> seleziona se documenti = 1<br><strong>0</strong> seleziona se documenti = 0</p>                                                                                                                      |
| reso                                       | 1/0          | <p><strong>1</strong> seleziona le spedizioni di reso<br><strong>0</strong> seleziona le spedizioni normali</p>                                                                                                            |
| tipo                                       | 1/0          | <p><strong>1</strong> seleziona le spedizioni<br><strong>0</strong> seleziona i ritiri</p>                                                                                                                                 |
| perPage                                    | 1...200      | Numero di elementi per pagina. Default: 200                                                                                                                                                                                |
| page                                       | int          | Numero della pagina richiesta                                                                                                                                                                                              |
| order                                      | ASC\|DESC    | Verso dell'ordinamento. Default: DESC                                                                                                                                                                                      |
| orderBy                                    | string       | <p>Nome del campo su cui ordinare i risultati. Default: id</p><p></p><p>Valori possibili:</p><p>id,</p><p>corriere,</p><p>client\_id,</p><p>date\_created,</p><p>invoiced\_client\_id</p>                                  |
| status                                     | float        | Indica lo stato della spedizione. Deve essere maggiore o uguale a zero                                                                                                                                                     |

#### Headers

| Name                                        | Type   | Description             |
| ------------------------------------------- | ------ | ----------------------- |
| x-api-key<mark style="color:red;">\*</mark> | String | Apikey fornita da GSPED |

{% tabs %}
{% tab title="200: OK elenco spedizioni" %}

```javascript
{
    "status": 200,
    "page": 1,
    "totPages": 3,
    "totEntries": 6,
    "entries": 2,
    "payload": [
        {...},
        {...},
    ],
    "previousPageUrl": null,
    "nextPageUrl": "http://apistaging.gsped.it/testbed/shipments?corriere%5B0%5D=1&corriere%5B1%5D=104&perPage=2&page=2&totEntries=6"
}
```

{% endtab %}

{% tab title="400: Bad Request Errore input" %}

```javascript
{
    "status": 400,
    "error" => "Testo descrittivo dell'errore",
}
```

{% endtab %}

{% tab title="403: Forbidden Apikey invalida" %}

```javascript
{
    "status": false,
    "error": "Invalid API key "
}
```

{% endtab %}
{% endtabs %}

### Snippets codice di esempio

{% tabs %}
{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.gsped.it/sandbox/ShipmentsList",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => [
    "x-api-key: YOUR-API-KEY"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

{% endtab %}

{% tab title="PYTHON" %}

```python
import http.client

conn = http.client.HTTPSConnection("api.gsped.it")

payload = ""

headers = { 'x-api-key': "YOUR-API-KEY" }

conn.request("GET", "/sandbox/ShipmentsList", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
```

{% endtab %}

{% tab title="GO" %}

```go
package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://api.gsped.it/sandbox/ShipmentsList"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("x-api-key", "YOUR-API-KEY")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

{% endtab %}

{% tab title="C#" %}

```csharp
// Some codevar client = new HttpClient();
var request = new HttpRequestMessage
{
    Method = HttpMethod.Get,
    RequestUri = new Uri("https://api.gsped.it/sandbox/ShipmentsList"),
    Headers =
    {
        { "x-api-key", "YOUR-API-KEY" },
    },
};
using (var response = await client.SendAsync(request))
{
    response.EnsureSuccessStatusCode();
    var body = await response.Content.ReadAsStringAsync();
    Console.WriteLine(body);
}
```

{% endtab %}

{% tab title="cURL" %}

```shell
curl --request GET \
  --url 'https://api.gsped.it/sandbox/ShipmentsList' \
  --header 'x-api-key: YOUR-API-KEY'
```

{% endtab %}
{% endtabs %}
