Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Zasób Batch słuzy do tworzenia i podglądu wielu przesyłek. W trybie asynchronicznym po walidacji każda przesyłka procesuje sie się w osobnym wątku, a co za tym idzie informacje zwrotne sa wysyłane na WebHooki dla każdej przesyłki z osobna.


Panel
bgColor#f0f0f0
titleBGColor#f0f0f0
titleNa tej stronie
Table of Contents
minLevel2

 


Struktura

Zasób Batch

 posiada

 posiada następujące atrybuty:

Atrybut

Typ

Opis

id

Integer

Id obiektu

status

String

Status przetwarzania przesyłek

shipments

Array[Shipment]

Przesyłki

created_at

DateTime

Data utworzenia

updated_at

DateTime

 

Data aktualizacji

Przykład zasobu Batch w formacie JSON:

Code Block
languagejson
{
  "href": "https://api-shipx-pl.easypack24.net/v1/batches/16",
  "id": 16,
  "status": "done",
  "shipments": [
    {
      "href": "https://api-shipx-pl.easypack24.net/v1/shipments/151",
      "id": 151,
      "status": "confirmed",
      "tracking_number": "633100159730624319900067"
    },
    {
      "href": "https://api-shipx-pl.easypack24.net/v1/shipments/150",
      "id": 150,
      "status": "confirmed",
	  "tracking_number": "633100159730624319900068"
    }
  ],
  "created_at": "2017-06-08T14:17:25.675+02:00",
  "updated_at": "2017-06-08T14:17:25.675+02:00"
}

Uwierzytelnianie

Dostęp do zasobu wymaga podania prawidłowego i aktualnego access tokenu.


Po utworzeniu przesyłki,

Tworzenie wielu przesyłek

Info
titleUwaga! Klienci debetowi

Po utworzeniu przesyłki nie zwracamy cen dla klientów debetowych.
Atrybut rate przyjmuje wartość null

Tworzenie wielu przesyłek

code
Code Block
languagejson
POST /v1/organizations/:organization_id/batches

Parametry

Parametr

Typ

Opis

Walidacja

only_choice_of_offer

Boolean

Ustawienie parametru na true powoduje, że oferta we wszystkich przesyłkach zostanie wybrana dla podanego serwisu, ale nie zostanie automatycznie opłacona.
Taka przesyłkę trzeba opłacić przed końcem wygaśnięcia oferty wykonując operacje (Opłacanie przesyłki).
Parametr ten można ustawić również dla każdej przesyłki z osobna (w takim przypadku parametr ustawiony w przesyłce ma wyższy priorytet).

Atrybut nie jest wymagany.

  • Defoultowa wartość false

shipments

Array[Hash]

Atrybut nie jest wymagany.

  • Minimum 1

  • Maksimum 2500

Parametry zasobu shipments

Parametr

Type

Opis

id

String

Wymagany. Unikalny identyfikator danej przesyłki, który pozwala zwrócić użytkownikowi informację o błędach walidacji przypisanych do konkretnej przesyłki. Id nie jest zapisywany w bazie danych i nie jest zwracany jak atrybut utworzonej przesyłki.

...

...

Pozostałe parametry przesyłki uproszczonej opisane na

Uproszczone tworzenie przesyłki

Atrybut nie jest wymagany.

  • Minimum 1
  • Maksimum 2500

Przykład zapytania

code

Przykład zapytania

Code Block
languagejson
curl -X POST https://api-shipx-pl.easypack24.net/v1/organizations/1/batches -H 'Authorization: Bearer token' -H 'content-type: application/json' -d '{ 
  "only_choice_of_offer": false,
  "shipments": [
    {
      "id": 1,
      "service": "inpost_locker_standard",
  
"reference":
 
"Test",
   
"custom_attributes": {
        "target_point": "
KRA012
KRA010"
      },
      "parcels":{
        "template": "small"
      },
      "receiver": {
        "company_name": "Company name 1",
        "email": "sklep@inpost.pl",
        "phone": "888888888",
        "address": {
          "line1": "Zawila 65L",
          "city": "Krakow",
          "post_code": "30-390",
          "country_code": "PL"
        }
      },
      "sender": {
       "company_name": "Company name 2",
        "email": "sklep@inpost.pl",
        "phone": "999999999",
        "address": {
          "line1": "Zawila 65L",
          "city": "Krakow",
          "post_code": "30-390",
          "country_code": "PL"
        }
      },
      "cod": {
        "amount": 1,
        "currency": "PLN"
      },
      "insurance": {
        "amount": 23,
        "currency": "PLN"
      }
    },
    {
      "id": 2,
      "service": "inpost_locker_standard",
  
"reference":
 
"Test",
   
"custom_attributes": {
        "target_point": "
KRA012
KRA010"
      },
      "parcels":{
        "template": "small"
      },
      "receiver": {
        "company_name": "Company name 1",
        "email": "sklep@inpost.pl",
        "phone": "888888888",
        "address": {
          "line1": "Zawila 65L",
          "city": "Krakow",
          "post_code": "30-390",
          "country_code": "PL"
        }
      },
      "sender": {
       "company_name": "Company name 2",
        "email": "sklep@inpost.pl",
        "phone": "999999999",
        "address": {
          "line1": "Zawila 65L",
          "city": "Krakow",
          "post_code": "30-390",
          "country_code": "PL"
        }
      },
      "cod": {
        "amount": 1,
        "currency": "PLN"
      },
      "insurance": {
        "amount": 23,
        "currency": "PLN"
      }
    }
  ]
}'

Odpowiedź

Code Block
curl -X POST https:/
languagejson
HTTP/1.1 201 Created
Content-Type: application/json
{
  "href": "https://api-shipx-pl.easypack24.net/v1/
organizations/1/batches -H 'Authorization: Bearer token' -H 'content-type: application/json' -d '{ "only_choice_of_offer": false, "shipments": [ { "id": 1, "service": "inpost_locker_standard", "reference": "Test", "custom_attributes": { "target_point": "KRA012" }, "parcels":{ "template": "small" }, "receiver": { "name": "Name", "company_name": "Company name", "first_name": "Jan", "last_name": "Kowalski", "email": "receiver@example.com", "phone": "888000000", "address": { "street": "Cybernetyki", "building_number": "10", "city": "Warszawa", "post_code": "02-677", "country_code": "PL" } }, "sender": { "name": "Nazwa", "company_name": "InPost S.A.", "first_name": "Jan", "last_name": "Nowak", "email": "sender@email.com", "phone": "888000000", "address": { "street": "Malborska", "building_number": "130", "city": "Kraków", "post_code": "30-624", "country_code": "PL" } } }, { "id": 2, "service": "inpost_locker_standard", "reference": "Test", "custom_attributes": { "target_point": "KRA012" }, "parcels":{ "template": "small" }, "receiver": { "name": "Name", "company_name": "Company name", "first_name": "Jan", "last_name": "Kowalski", "email": "receiver@example.com", "phone": "888000000", "address": { "street": "Cybernetyki", "building_number": "10", "city": "Warszawa", "post_code": "02-677", "country_code": "PL" } }, "sender": { "name": "Nazwa", "company_name": "InPost S.A.", "first_name": "Jan", "last_name": "Nowak", "email": "sender@email.com", "phone": "888000000", "address": { "street": "Malborska", "building_number": "130", "city": "Kraków", "post_code": "30-624", "country_code": "PL" } } } ] }'

Odpowiedź

Code BlockHTTP/1.1 201 Created Content-Type: application/json {
batches/35",
  "id": 35,
  "status": "in_progress",
  "shipments": [
    {
      "href": "https://api-shipx-pl.easypack24.net/v1/shipments/195",
      "id": 195,
      "status": "confirmed",
      "tracking_number": "520000017830390003337439"
    },
    {
      "href": "https://api-shipx-pl.easypack24.net/v1/shipments/195",
      "id": 195,
      "status": "offer_selected",
      "tracking_number": "520000017830390003337439"
    },
    {
      "href": "https://api-shipx-pl.easypack24.net/v1/
batches
shipments/
1672413
196",
      "id": 
1672413
196,
      "status": "create",
      "tracking_number":
"in_progress", "shipments": [
 null
    }
  ],
  "created_at": "
2021
2017-
08
06-
11T13
12T14:
12
19:
50
20.
325
432+02:00",
  "updated_at": "
2021
2017-
08
06-
11T13
12T14:
12
19:
50
20.
325
432+02:00"
}
Warning

Informacje o błędach

 Serwer może zwrócić następujące błędy

  • validation_failed - błąd walidacji 

    forbidden - akcja jest niedostępna dla podanego tokenu

  • token_invalid - użytkownik nie ma praw dostępu do określonej organizacji


Podgląd wielu przesyłek

Code Block
languagejson
GET /v1/batches/:id

Przykład zapytania

Code Block
languagejson
curl -X GET https://api-shipx-pl.easypack24.net/v1/batches/16 -H 'Authorization: Bearer token' -H 'content-type: application/json' 

Odpowiedź

Code Block
languagejson
HTTP/1.1 200 OK
Content-Type: application/json
{
  "href": "https://api-shipx-pl.easypack24.net/v1/batches/16",
  "id": 16,
  "status": "done",
  "shipments": [
    {
      "href": "https://api-shipx-pl.easypack24.net/v1/shipments/151",
      "id": 151,
      "status": "confirmed",
      "tracking_number": "633100159730624319900067"
    },
    {
      "href": "https://api-shipx-pl.easypack24.net/v1/shipments/150",
      "id": 150,
      "status": "confirmed",
      "tracking_number": "633100159730624319900068"
    }
  ],
  "created_at": "2017-06-08T14:17:25.675+02:00",
  "updated_at": "2017-06-08T14:17:25.675+02:00"
}
Warning

Informacje o błędach

 

Serwer może zwrócić następujące błędy

  • resource_not_found - w przypadku gdy batch nie istnieje

  • token_invalid - użytkownik nie ma praw dostępu do określonej organizacji