[1.6.4] Książka adresowa
Zasób AddressBook
reprezentuję książkę adresową.
Na tej stronie
Struktura
Zasób AddressBook
posiada następujące atrybuty:
id | Integer | unikalny identyfikator |
| String | nazwa wpisu, unikalna w kontekście organizacji |
| String | Imię |
| String | Nazwisko |
| String | Telefon |
| String | Adres e-mail |
| Integer | identyfikator organizacji, która jest właścicielem tego wpisu |
| Address | Adres główny adresata |
| Address | Adres dostarczenia przesyłki |
| Boolean | Nadawca przesyłek paczkomatowych |
| Boolean | Nadawca przesyłek kurierskich |
| Boolean | Nadawca przesyłek listowych |
| String | Rodzaj wpisu |
| String | Nazwa firmy |
| String | Preferowany punkt nadawczy |
| DateTime | Data utworzenia |
| DateTime | Data ostatniej aktualizacji |
Przykład zasobu AddressBook w formacie JSON:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
"id":5,
"first_name":"Jan",
"last_name":"Nowak",
"email":"jan@nowak.pl",
"phone":"123456789",
"created_at":"2016-02-24T09:22:27.212+01:00",
"updated_at":"2016-02-24T09:22:27.212+01:00",
"organization_id":1,
"name":"Nowak Corp",
"sender_parcel":false,
"sender_courier":false,
"sender_letter":true,
"kind": "sender",
"company_name": "MyCompanyName",
"preferred_dropoff_point": "KRA120",
"main_address":{
"id": "123",
"street": "Malborska",
"building_number": "130",
"city":"Warsaw","id": "123",
"post_code":"33-666",
"country_code":"PO"
},
"delivery_address":{
"id": "123",
"street": "Malborska",
"building_number": "140",
"city":"Cracow",
"post_code":"66-666",
"country_code":"AZ"
}
} |
Lista adresów
Lista wszystkich adresów, do których użytkownik ma dostęp.
Aby, pobrać listę punktów odbioru dla określonej organizacji użytkownik musi być jej członkiem.
1
GET /v1/organizations/:organization_id/address_books |
Przykładowe zapytanie
1
curl -X GET https://api-shipx-pl.easypack24.net/v1/organizations/1/address_books -H "Authorization: Bearer token" -H "Content-Type: application/json"
|
Odpowiedź
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
HTTP/1.1 200 OK
Content-Type: application/json
{
"href":"https://api-shipx-pl.easypack24.net/v1/address_books",
"count":1,
"page":1,
"per_page":30,
"items":[
{
"id":5,
"first_name":"Jan",
"last_name":"Nowak",
"email":"jan@nowak.pl",
"phone":"123456789",
"created_at":"2016-02-24T09:22:27.212+01:00",
"updated_at":"2016-02-24T09:22:27.212+01:00",
"organization_id":1,
"name":"Nowak Corp",
"sender_parcel":false,
"sender_courier":false,
"sender_letter":true,
"kind": "sender",
"company_name": "MyCompanyName",
"preferred_dropoff_point": "KRA120",
"main_address":{
"id": "123",
"street": "Malborska",
"building_number": "130",
"city":"Warsaw","id": "123",
"post_code":"33-666",
"country_code":"PO"
},
"delivery_address":{
"id": "123",
"street": "Malborska",
"building_number": "140",
"city":"Cracow",
"post_code":"66-666",
"country_code":"AZ"
}
}
]
} |
Szczegóły adresu
Można pobrać informacje o adresie na podstawie jego ID
1
GET /v1/address_books/:id |
Przykład zapytania
1
curl -X GET https://api-shipx-pl.easypack24.net/v1/address_books/1 -H 'Authorization: Bearer token' -H 'Content-Type: application/json' |
Przykładowa odpowiedź
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
HTTP/1.1
Content-Type: application/json
{
"id": 6,
"first_name": "Jan",
"last_name": "nowak",
"email": "jan@nowak.pl",
"phone": "123456789",
"created_at": "2016-02-24T09:22:35.032+01:00",
"updated_at": "2016-02-24T09:22:35.032+01:00",
"organization_id": 1,
"name": "Nowak Corp",
"sender_parcel": true,
"sender_courier": false,
"sender_letter": true,
"kind": "receiver",
"company_name": "MyCompanyName",
"preferred_dropoff_point": "KRA120",
"main_address": {
"id": "123",
"street": "Malborska",
"building_number": "130",
"city": "Cracow",
"post_code": "33-666",
"country_code": "PO"
},
"delivery_address": {
"id": "123",
"street": "Malborska",
"building_number": "130",
"city": "Warsow",
"post_code": "66-666",
"country_code": "AZ"
}
} |
Tworzenie adresu
Za pomocą tej metody można dodać nowy adres do organizacji.
1
POST v1/organizations/:organization_id/address_books |
Parametry
| String | Atrybut jest wymagany.
|
| String | Atrybut jest wymagany.
|
| String | Atrybut jest wymagany.
|
| String | Atrybut jest wymagany.
|
| String | Atrybut jest wymagany.
|
| String | Atrybut jest wymagany.
|
| String | Atrybut nie jest wymagany.
|
| String | Atrybut nie jest wymagany.
|
| Address | Atrybut jest wymagany. |
| Address | Atrybut jest wymagany. |
| Boolean | Atrybut nie jest wymagany.
|
| Boolean | Atrybut nie jest wymagany.
|
| Boolean | Atrybut nie jest wymagany.
|
Przykład zapytania
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
curl -X POST https://api-shipx-pl.easypack24.net/v1/organizations/1/address_books -H 'Authorization: Bearer token' -H 'Content-Type: application/json' -d '{
"name": "Nowak Corp",
"first_name": "Jan",
"last_name": "Nowak",
"email": "jan@nowak.com",
"phone": "123456789",
"sender_parcel": true,
"sender_letter": true,
"kind": "sender",
"company_name": "MyCompanyName",
"preferred_dropoff_point": "KRA120",
"main_address": {
"street": "Malborska",
"building_number": "130",
"city": "Warsaw",
"post_code": "33-666",
"country_code": "PO"
},
"delivery_address": {
"street": "Malborska",
"building_number": "130",
"city": "Cracow",
"post_code": "66-666",
"country_code": "AZ"
}
}' |
Odpowiedź
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
HTTP/1.1
Content-Type: application/json
{
"id": 7,
"first_name": "Jan",
"last_name": "Nowak",
"email": "jan@nowak.com",
"phone": "123456789",
"created_at": "2016-02-24T10:38:03.835+01:00",
"updated_at": "2016-02-24T10:38:03.835+01:00",
"organization_id": 1,
"name": "Nowak Corp",
"sender_parcel": true,
"sender_courier": false,
"sender_letter": true,
"kind": "sender",
"company_name": "MyCompanyName",
"preferred_dropoff_point": "KRA120",
"main_address": {
"id": "123",
"street": "Malborska",
"building_number": "130",
"city": "Warsaw",
"post_code": "33-666",
"country_code": "PO"
},
"delivery_address": {
"id": "123",
"street": "Malborska",
"building_number": "130",
"city": "Cracow",
"post_code": "66-666",
"country_code": "AZ"
}
} |
Aktualizowanie adresu
Za pomocą tej metody możesz zaktualizować adres. Należy pamiętać, że parametr id
jest podawany jako parametr GET.
1
PUT /v1/address_books/:id |
Parametry
| String | Atrybut jest wymagany.
|
| String | Atrybut jest wymagany.
|
| String | Atrybut jest wymagany.
|
| String | Atrybut jest wymagany.
|
| String | Atrybut jest wymagany.
|
| String | Atrybut jest wymagany.
|
| String | Atrybut nie jest wymagany.
|
| String | Atrybut nie jest wymagany.
|
| Address | Atrybut jest wymagany. |
| Address | Atrybut jest wymagany. |
| Boolean | Atrybut nie jest wymagany.
|
| Boolean | Atrybut nie jest wymagany.
|
| Boolean | Atrybut nie jest wymagany.
|
Przykład zapytania
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
curl -X POST https://api-shipx-pl.easypack24.net/v1/address_books/1 -H 'Authorization: Bearer token' -H 'Content-Type: application/json' -d '{
"name": "New name",
"first_name": "John",
"last_name": "Smith",
"email": "some@email.pl",
"phone": "123456798",
"sender_courier": true,
"kind": "receiver",
"company_name": "MyCompanyName",
"preferred_dropoff_point": "KRA120",
"main_address": {
"id": "123",
"street": "Malborska",
"building_number": "130",
"city": "Warsaw",
"post_code": "33-333",
"country_code": "PL"
},
"delivery_address": {
"id": "123",
"street": "Malborska",
"building_number": "134",
"city": "Warsaw",
"post_code": "33-333",
"country_code": "PL"
}
}' |
Odpowiedź
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
HTTP/1.1
Content-Type: application/json; charset=utf-8
{
"id": 7,
"first_name": "Jan",
"last_name": "Nowak",
"email": "jan@nowak.com",
"phone": "123456789",
"created_at": "2016-02-24T10:38:03.835+01:00",
"updated_at": "2016-02-24T10:38:03.835+01:00",
"organization_id": 1,
"name": "Nowak Corp",
"sender_parcel": true,
"sender_courier": false,
"sender_letter": true,
"kind": "receiver",
"company_name": "MyCompanyName",
"preferred_dropoff_point": "KRA120",
"main_address": {
"id": "123",
"street": "Malborska",
"building_number": "130",
"city": "Warsaw",
"post_code": "33-666",
"country_code": "PO"
},
"delivery_address": {
"id": "123",
"street": "Malborska",
"building_number": "140",
"city": "Cracow",
"post_code": "66-666",
"country_code": "AZ"
}
} |
Usuwanie adresu
Za pomocą tej metody można usunąć wybrany adres z bazy danych.
1
DELETE /v1/address_books/:id |
Przykład zapytania
1
DELETE /v1/address_books/123 |
Odpowiedź
1
2
HTTP/1.1 204 NO_CONTENT
Content-Type: application/json |