[1.6.4] Address book

List of addresses in address book


The AddressBook resource represents an address book.

The address book for the Organization is available at

GET /v1/organizations/:id_organizacji/address_books

A single entry can be collected

GET /v1/organizations/:id_organizacji/address_books/:id_adresu
On this page

 

Authentication

Access to the resource requires provision of the correct and valid access token.

Structure

The AddressBook resource has the following attributes::

AttributeType

Description

idinteger

unique identifier

namestring

name of entry, unique in the context of the organization.

first_namestring

First name

last_namestring

Last name

phonestring

Phone

emailstring

E-mail address

organization_idinteger

ID of the organization which owns this entry

main_addressobject

Addressee's main address

delivery_addressobject

Shipment delivery address

sender_parcelboolean

Paczkomat parcel station shipment sender

sender_courierboolean

Courier shipment sender

sender_letterboolean

Letter shipment sender

kindstring

Type of entry

company_namestring

Company name

preferred_dropoff_pointstring

Preferred shipping point

created_atDateTimeData utworzenia
updated_atDateTimeData ostatniej aktualizacji

Sample AddressBook resource in the JSON format:



List of addresses in address book

List of all addresses the user has access to

GET /v1/organizations/:id_organizacji/address_books


Rights

To collect the list of dispatch points for a particular organization the user needs to be a member thereof.

Sample request

GET /v1/organizations/12345/address_books?sort_order=asc&sort_by=last_name&sender_letter=true HTTP/1.1
Host: api-shipx-pl.easypack24.net
Content-Type: application/json
Authorization: Bearer lkfjasd9f70y43ohriw...[ommited for brevity]...


Response

HTTP/1.1 200 OK
Content-Type: application/json
 
{  
   "href":"https://api-shipx-pl.easypack24.net/v1/address_books?sender_letter=true\u0026sort_by=last_name\u0026sort_order=asc",
   "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"
         }
      }
   ]
}

Collecting information about address

Information about the address can be collected based on its ID

Parameters

ParameterTypeDescription
idintegerAddress ID

Sample request

GET /v1/address_books/123


Sample response

HTTP/1.1  
Content-Type: application/json; charset=utf-8

{
  "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"
  }
}

Adding a new address

With this method a new address can be added to the organization.

Parameters

ParameterType

Description

namestring

The attribute is required.

• Maximum 255 characters  

• Unique in the context of the organization      

first_namestring

The attribute is required.

• Maximum 255 characters

last_namestring

The attribute is required.

• Maximum 255 characters

phonestring

The attribute is required.

• Maximum 255 characters  

• 9 characters        

• Digits only          

emailstring

The attribute is required.

• Maximum 255 characters  

• Format consistent with RFC 5322 and RFC 5321            

kindstring

The attribute is required.

• Maximum 255 characters  

• Acceptable values              (sender, receiver)

company_namestring

The attribute is not required. • Maximum 255 characters

preferred_dropoff_pointstring

The attribute is not required. • Maximum 255 characters

main_address

Create Address Form

The attribute is required.

delivery_addressCreate Address Form

The attribute is required.

sender_parcelboolean

The attribute is not required. • Default value false

sender_courierboolean

The attribute is not required. • Default value false

sender_letterboolean

The attribute is not required. • Default value false


Sample request

POST http://localhost:3000/v1/organizations/:id_organizacji/address_books HTTP/1.1
Accept: application/json
Content-Length: 517
Content-Type: application/json

{
  "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"
  }
}

Sample response

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": "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"
  }
}

Updating address

With this method you can update the address. It is important to remember that the id parameter is provided as a GET parameter.

Parameters

ParameterType

Description

idinteger

The attribute is not required.

• Address ID

namestring

The attribute is required.

• Maximum 255 characters  

• Unique in the context of the organization      

first_namestring

The attribute is required.

• Maximum 255 characters

last_namestring

The attribute is required.

• Maximum 255 characters

phonestring

The attribute is required.

• Maximum 255 characters  

• 9 characters        

• Digits only          

emailstring

The attribute is required.

• Maximum 255 characters  

• Format consistent with RFC 5322 and RFC 5321            

kindstring

The attribute is required.

• maximum 255 characters  

• Acceptable string values (sender, receiver)

company_namestring

The attribute is not required.

• Maximum 255 characters

preferred_dropoff_pointstring

The attribute is not required.

• Maximum 255 characters

main_addressCreate Address Form

The attribute is required.

delivery_addressCreate Address Form

The attribute is required.

sender_parcelboolean

The attribute is not required.

• Default value false

sender_courierboolean

The attribute is not required.

• Default value false

sender_letterboolean

The attribute is not required.

• Default value false


Sample request

PUT /v1/address_books/1 HTTP/1.1
Content-Type: application/json

{
  "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"
  }
}

Sample response

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"
  }
}

Removing address

With this method it is possible to remove the selected address from the database.

Parameters

ParameterTypeDescription
idintegerAddress ID

Sample request

DELETE /v1/address_books/123