Menu

## WC_Shipping_Shipcloud_API_Adapter
in package

class-wc-shipping-shipcloud-api-adapter.php : 52

### Table of Contents

$api : ApiClient
  ApiClient instance
$api_key : string
  The shipcloud API key
$instance : object
  The Single instance of the class
$services : array<string|int, mixed>
  Services list
create_address() : array<string|int, mixed>
  This method is to create an address. It forces a validation against required fields before sending the request to API.
create_label() : array<string|int, mixed>|WP_Error
  Creating a shipping label
create_pickup_request() : array<string|int, mixed>|WP_Error
  There are two ways you can request shipments to be picked up by a specific carrier. By simply stating that all shipments that haven't been picked up already should be picked up or by specifying which shipments should by picked up.
create_shipment() : array<string|int, mixed>|WP_Error
  This method is to create a shipment.
create_tracker() : array<string|int, mixed>|bool
  If you want to create a tracker, this is the way to go.
delete_shipment() : array<string|int, mixed>|bool|WP_Error
  This method is to delete an existing shipment.
get_address() : array<string|int, mixed>|WP_Error
  If you want to obtain a certain address, this is the way to go.
get_address_by_pakadoo_id() : array<string|int, mixed>|WP_Error
  If you want to request a pakadoo point address, this is the way to go.
get_addresses() : array<string|int, mixed>|WP_Error
  If you want to obtain a list of addresses, this is the way to go.
get_carrier_list() : array<string|int, mixed>
  Get a list of carriers available for your account.
get_carriers() : array<string|int, mixed>|false
  Get all carriers available for your shipcloud account.
get_current_shipment_status() : array<string|int, mixed>|WP_Error
  Getting the get current status of a certain shipment.
get_default_returns_address() : array<string|int, mixed>|WP_Error
  This is the default address that will be used for returns shipments when no address was specified using the 'to' attribute.
get_default_shipping_address() : array<string|int, mixed>
  This is the default address that will be used for shipments when no address was specified using the 'from' attribute.
get_instance() : object
  Main Instance
get_invoice_address() : array<string|int, mixed>|WP_Error
  This is the address that a user has specified as being their invoice address.
get_pickup_request() : array<string|int, mixed>|bool
  Getting information about a certain pickup request.
get_pickup_requests() : array<string|int, mixed>
  Getting a list of pickup requests.
get_price() : float|WP_Error
  Getting the price for a shipment
get_shipment() : array<string|int, mixed>|WP_Error
  If you want to obtain a certain shipment, this is the way to go.
get_shipments() : array<string|int, mixed>|WP_Error
  If you want to obtain a list of shipments, this is the way to go.
get_tracker() : array<string|int, mixed>|bool
  Getting information about a certain tracker.
get_trackers() : array<string|int, mixed>
  Getting a list of trackers.
get_webhook_id() : mixed
update_shipment() : array<string|int, mixed>|WP_Error
  This method is to update an existing shipment.
__construct() : void
  Constructor.
add_admin_notice() : void
  Output an admin notice.
convert_data_array_to_address_api_object() : Address
  Converts address data array to Address.
convert_data_array_to_pickup_api_object() : Pickup
  Converts pickup data array to Pickup.
convert_data_array_to_shipment_api_object() : Shipment
  Converts shipment data array to Shipment.
convert_data_array_to_tracker_api_object() : Tracker
  Converts tracker data array to Tracker.
create_shipment_quote() : float|WP_Error
  With this call you can find out how much we will charge you for a specific shipment.
create_webhook() : string|bool
  If you want to create a webhook, this is the way to go.
get_api() : WP_Error|ApiClient
  Getting shipcloud API.
get_latest_tracking_status() : array<string|int, mixed>|bool
  Extracting latest tracking information of a certain shipment.
get_service_display_name() : string
  Getting service display name by service id.
handle_exception() : WP_Error
  Handles Exception and converts it to WP_Error.
init() : void
  Initialization.
log() : void
  Output a debug message.

### Properties

#### $api

class-wc-shipping-shipcloud-api-adapter.php : 74

ApiClient instance

`private ApiClient $api`

##### Tags

see
  ApiClient

#### $api_key

class-wc-shipping-shipcloud-api-adapter.php : 66

The shipcloud API key

`private string $api_key`

#### $instance

class-wc-shipping-shipcloud-api-adapter.php : 59

The Single instance of the class

`private static object $instance`

#### $services

class-wc-shipping-shipcloud-api-adapter.php : 81

Services list

`private array<string|int, mixed> $services`

### Methods

#### create_address()

class-wc-shipping-shipcloud-api-adapter.php : 147

This method is to create an address. It forces a validation against required fields before sending the request to API.

`public create_address([array<string|int, mixed> $data = [] ]) : array<string|int, mixed>`

##### Parameters

$data : array<string|int, mixed> = []

  The address to be created.

##### Return values

array<string|int, mixed> —

The created address including ID.

#### create_label()

class-wc-shipping-shipcloud-api-adapter.php : 854

Creating a shipping label

`public create_label([array<string|int, mixed> $shipment = [] ]) : array<string|int, mixed>|WP_Error`

##### Parameters

$shipment : array<string|int, mixed> = []

##### Return values

array<string|int, mixed>|WP_Error —

#### create_pickup_request()

class-wc-shipping-shipcloud-api-adapter.php : 976

There are two ways you can request shipments to be picked up by a specific carrier. By simply stating that all shipments that haven't been picked up already should be picked up or by specifying which shipments should by picked up.

`public create_pickup_request([array<string|int, mixed> $data = [] ]) : array<string|int, mixed>|WP_Error`

Notice: If you don't supply a pickup_address in your request, we're using the default from address that's being defined in the shipcloud profile for requesting a pickup by the carrier. Please keep in mind there are carrier specific field lengths you have to take into account.

##### Parameters

$data : array<string|int, mixed> = []

  The pickup data.

##### Return values

array<string|int, mixed>|WP_Error —

An array with pickup information if succeeded, false otherwise.

#### create_shipment()

class-wc-shipping-shipcloud-api-adapter.php : 457

This method is to create a shipment.

`public create_shipment([mixed $data = [] ]) : array<string|int, mixed>|WP_Error`

    Response:
    {
      "id": "3a186c51d4281acbecf5ed38805b1db92a9d668b",
      "carrier_tracking_no": "84168117830018",
      "tracking_url": "https://track.shipcloud.io/3a186c51d4",
      "label_url": "https://shipping-labels.shipcloud.io/shipments/01370b4d/199f803bf8/label/shipping_label_199f803bf8.pdf",
      "price": 3.4
    }

##### Parameters

$data : mixed = []

##### Return values

array<string|int, mixed>|WP_Error —

The shipment labeling, tracking and pricing information.

#### create_tracker()

class-wc-shipping-shipcloud-api-adapter.php : 1172

If you want to create a tracker, this is the way to go.

`public create_tracker([array<string|int, mixed> $data = [] ]) : array<string|int, mixed>|bool`

##### Parameters

$data : array<string|int, mixed> = []

  The tracker data.

##### Return values

array<string|int, mixed>|bool —

An array with tracker information if succeeded, false otherwise.

#### delete_shipment()

class-wc-shipping-shipcloud-api-adapter.php : 733

This method is to delete an existing shipment.

`public delete_shipment([ $id = '' ]) : array<string|int, mixed>|bool|WP_Error`

    NOTE:
    Prepared shipments (create_shipping_label is false) can be deleted
    at any time, because no transaction with the carrier has happened
    until this point and no actual shipping label has been created. In
    case you've created a shipping label you can delete it before the
    cutoff time of the carrier. Cutoff times differ from carrier to
    carrier and are some time between 5pm and 8pm.

##### Parameters

$id : = ''

  The id attribute that was returned when creating the shipment.

##### Return values

array<string|int, mixed>|bool|WP_Error —

An empty array if succeeded, false otherwise.

#### get_address()

class-wc-shipping-shipcloud-api-adapter.php : 191

If you want to obtain a certain address, this is the way to go.

`public get_address([string $id = '' ]) : array<string|int, mixed>|WP_Error`

##### Parameters

$id : string = ''

  The id attribute that was returned when creating the address.

##### Return values

array<string|int, mixed>|WP_Error —

The address if existing.

#### get_address_by_pakadoo_id()

class-wc-shipping-shipcloud-api-adapter.php : 234

If you want to request a pakadoo point address, this is the way to go.

`public get_address_by_pakadoo_id([string $pakadoo_id = '' ]) : array<string|int, mixed>|WP_Error`

##### Parameters

$pakadoo_id : string = ''

  The pakadoo point id.

##### Return values

array<string|int, mixed>|WP_Error —

The pakadoo point address if existing.

#### get_addresses()

class-wc-shipping-shipcloud-api-adapter.php : 293

If you want to obtain a list of addresses, this is the way to go.

`public get_addresses([array<string|int, mixed> $filter = [] ]) : array<string|int, mixed>|WP_Error`

You can filter the addresses list using one or more of the following URL parameters:

first_name, e.g. 'first_name=Max' last_name, e.g. 'last_name=Mustermann' company, e.g. 'company=Example%20Company' care_of, e.g. 'care_of=Roger%20Receiver' street, e.g. 'street_no=Musterstraße' street_no, e.g. 'street_no=42' zip_code, e.g. 'zip_code=12345' state, e.g. 'state=CA' city, e.g. 'city=Musterstadt' country, e.g. 'country=DE' phone, e.g. 'phone=555-555' page, show page number x, e.g. 'page=2' per_page, show x number of shipments on a page (default & max: 100), e.g. 'per_page=25'

##### Parameters

$filter : array<string|int, mixed> = []

  A list of filter criteria.

##### Return values

array<string|int, mixed>|WP_Error —

A list of all created addresses.

#### get_carrier_list()

class-wc-shipping-shipcloud-api-adapter.php : 871

Get a list of carriers available for your account.

`public get_carrier_list() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

A list of all carriers available for your account.

#### get_carriers()

class-wc-shipping-shipcloud-api-adapter.php : 913

Get all carriers available for your shipcloud account.

`public get_carriers() : array<string|int, mixed>|false`

##### Return values

array<string|int, mixed>|false —

#### get_current_shipment_status()

class-wc-shipping-shipcloud-api-adapter.php : 560

Getting the get current status of a certain shipment.

`public get_current_shipment_status( $shipment_id) : array<string|int, mixed>|WP_Error`

    Response:
    {
      "timestamp": "2021-10-14T15:56:39+02:00",
      "location": "Paderborn",
      "status": "package_delivered",
      "details": "Es wurde eine Sendung angelegt",
      "id": "4bff7566-33f4-4baa-84aa-9fda2d02b77c"
    }

##### Parameters

$shipment_id :

  The ID of the shipment asked for

##### Return values

array<string|int, mixed>|WP_Error —

$tracking_status The tracking status of the given shipment

#### get_default_returns_address()

class-wc-shipping-shipcloud-api-adapter.php : 330

This is the default address that will be used for returns shipments when no address was specified using the 'to' attribute.

`public get_default_returns_address() : array<string|int, mixed>|WP_Error`

##### Return values

array<string|int, mixed>|WP_Error —

The default returns address.

#### get_default_shipping_address()

class-wc-shipping-shipcloud-api-adapter.php : 367

This is the default address that will be used for shipments when no address was specified using the 'from' attribute.

`public get_default_shipping_address() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

The default shipping address.

#### get_instance()

class-wc-shipping-shipcloud-api-adapter.php : 126

Main Instance

`public static get_instance() : object`

##### Return values

object —

#### get_invoice_address()

class-wc-shipping-shipcloud-api-adapter.php : 403

This is the address that a user has specified as being their invoice address.

`public get_invoice_address() : array<string|int, mixed>|WP_Error`

##### Return values

array<string|int, mixed>|WP_Error —

The invoice address.

#### get_pickup_request()

class-wc-shipping-shipcloud-api-adapter.php : 1065

Getting information about a certain pickup request.

`public get_pickup_request([string $id = '' ]) : array<string|int, mixed>|bool`

##### Parameters

$id : string = ''

  The id attribute that was returned when creating the pickup request.

##### Return values

array<string|int, mixed>|bool —

The pickup request if existing, false otherwise.

#### get_pickup_requests()

class-wc-shipping-shipcloud-api-adapter.php : 1028

Getting a list of pickup requests.

`public get_pickup_requests() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

A list of pickup requests.

#### get_price()

class-wc-shipping-shipcloud-api-adapter.php : 828

Getting the price for a shipment

`public get_price(string $carrier, array<string|int, mixed> $from, array<string|int, mixed> $to[, array<string|int, mixed> $package = [] ][, mixed $service = '' ]) : float|WP_Error`

##### Parameters

$carrier : string
$from : array<string|int, mixed>
$to : array<string|int, mixed>
$package : array<string|int, mixed> = []
$service : mixed = ''

##### Return values

float|WP_Error —

#### get_shipment()

class-wc-shipping-shipcloud-api-adapter.php : 507

If you want to obtain a certain shipment, this is the way to go.

`public get_shipment([string $id = '' ]) : array<string|int, mixed>|WP_Error`

##### Parameters

$id : string = ''

  The id attribute that was returned when creating the shipment.

##### Return values

array<string|int, mixed>|WP_Error —

The shipment if existing.

#### get_shipments()

class-wc-shipping-shipcloud-api-adapter.php : 633

If you want to obtain a list of shipments, this is the way to go.

`public get_shipments([array<string|int, mixed> $filter = [] ]) : array<string|int, mixed>|WP_Error`

You can filter the shipments list using one or more of the following URL parameters:

    carrier, e.g. 'carrier=dhl'
    carrier_tracking_no, e.g. 'carrier_tracking_no=43128000105'
    created_at_gt, e.g. 'created_at_gt=20180712T1300Z'
    created_at_lt, e.g. 'created_at_lt=20180712T1400Z'
    page, show page number x, e.g. 'page=2'
    per_page, show x number of shipments on a page (default & max: 100), e.g. 'per_page=25'
    reference_number, e.g. 'reference_number=ref123456'
    service, e.g. 'service=returns'
    shipcloud_tracking_no, e.g. 'shipcloud_tracking_no=86afb143f9c9c0cfd4eb7a7c26a5c616585a6271'
    shipment_type, e.g. 'shipment_type=prepared'
    source, e.g. 'source=api'
    tracking_status, e.g. 'tracking_status=out_for_delivery'
    tracking_status_not, e.g. 'tracking_status_not=delivered'

    shipment_type: Specifies the type of a shipment. The following types are available:

    prepared: a shipment which was saved in shipcloud but doesn't have a shipping label yet
    label_created: a shipment containing a shipping label.
    tracking_only: a shipment that was imported via its carrier tracking number (see trackers for more details)

    created_at_gt / created_at_lt: You can filter the list by using these parameters to specify a timerange to
    find the shipments that were created during this time. The timestamp will be evaluated as ISO 8601 using the
    following format: YYYYMMDDThhmmZ.

    source: Filter shipments by platform they were created through. The following keys can be used:

    api: a shipment created through our api
    webui: a shipment created using the shipcloud ui
    return_portal: a shipment created using the shipcloud return portal

##### Parameters

$filter : array<string|int, mixed> = []

  A list of filter criteria.

##### Return values

array<string|int, mixed>|WP_Error —

A list of all created shipments.

#### get_tracker()

class-wc-shipping-shipcloud-api-adapter.php : 1252

Getting information about a certain tracker.

`public get_tracker([string $id = '' ]) : array<string|int, mixed>|bool`

##### Parameters

$id : string = ''

  The id attribute that was returned when creating the tracker.

##### Return values

array<string|int, mixed>|bool —

The tracker if existing, false otherwise.

#### get_trackers()

class-wc-shipping-shipcloud-api-adapter.php : 1215

Getting a list of trackers.

`public get_trackers() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

A list of trackers.

#### get_webhook_id()

class-wc-shipping-shipcloud-api-adapter.php : 1109
`public get_webhook_id() : mixed`

##### Return values

mixed —

#### update_shipment()

class-wc-shipping-shipcloud-api-adapter.php : 670

This method is to update an existing shipment.

`public update_shipment([array<string|int, mixed> $data = [] ]) : array<string|int, mixed>|WP_Error`

##### Parameters

$data : array<string|int, mixed> = []

  The shipment to edit.

##### Return values

array<string|int, mixed>|WP_Error —

Shipment labeling, tracking and pricing information.

#### __construct()

class-wc-shipping-shipcloud-api-adapter.php : 88

Constructor.

`private __construct() : void`

##### Return values

void —

#### add_admin_notice()

class-wc-shipping-shipcloud-api-adapter.php : 1644

Output an admin notice.

`private add_admin_notice(string $message[, string $type = 'info' ][, bool $dismissible = true ]) : void`

##### Parameters

$message : string

  Debug message.

$type : string = 'info'

  Message type.

$dismissible : bool = true

  Message type.

##### Return values

void —

#### convert_data_array_to_address_api_object()

class-wc-shipping-shipcloud-api-adapter.php : 1372

Converts address data array to Address.

`private convert_data_array_to_address_api_object([array<string|int, mixed> $data = [] ]) : Address`

##### Parameters

$data : array<string|int, mixed> = []

  The address data

##### Return values

Address —

#### convert_data_array_to_pickup_api_object()

class-wc-shipping-shipcloud-api-adapter.php : 1571

Converts pickup data array to Pickup.

`private convert_data_array_to_pickup_api_object([array<string|int, mixed> $data = [] ]) : Pickup`

##### Parameters

$data : array<string|int, mixed> = []

  The pickup data

##### Return values

Pickup —

#### convert_data_array_to_shipment_api_object()

class-wc-shipping-shipcloud-api-adapter.php : 1415

Converts shipment data array to Shipment.

`private convert_data_array_to_shipment_api_object([array<string|int, mixed> $data = [] ]) : Shipment`

##### Parameters

$data : array<string|int, mixed> = []

  The shipment data

##### Return values

Shipment —

#### convert_data_array_to_tracker_api_object()

class-wc-shipping-shipcloud-api-adapter.php : 1607

Converts tracker data array to Tracker.

`private convert_data_array_to_tracker_api_object([array<string|int, mixed> $data = [] ]) : Tracker`

##### Parameters

$data : array<string|int, mixed> = []

  The tracker data

##### Return values

Tracker —

#### create_shipment_quote()

class-wc-shipping-shipcloud-api-adapter.php : 777

With this call you can find out how much we will charge you for a specific shipment.

`private create_shipment_quote([array<string|int, mixed> $data = [] ]) : float|WP_Error`

##### Parameters

$data : array<string|int, mixed> = []

  The shipment data to get quote for.

##### Return values

float|WP_Error —

An array with shipment quote if succeeded, false otherwise.

#### create_webhook()

class-wc-shipping-shipcloud-api-adapter.php : 1124

If you want to create a webhook, this is the way to go.

`private create_webhook() : string|bool`

##### Return values

string|bool —

The id of the created webhook, false otherwise.

#### get_api()

class-wc-shipping-shipcloud-api-adapter.php : 1302

Getting shipcloud API.

`private get_api() : WP_Error|ApiClient`

##### Tags

see
  ApiClient

##### Return values

WP_Error|ApiClient —

$api

#### get_latest_tracking_status()

class-wc-shipping-shipcloud-api-adapter.php : 1346

Extracting latest tracking information of a certain shipment.

`private get_latest_tracking_status([array<string|int, mixed> $tracking_events = [] ]) : array<string|int, mixed>|bool`

##### Parameters

$tracking_events : array<string|int, mixed> = []

  The tracking events of a certain shipment

##### Return values

array<string|int, mixed>|bool —

The latest tracking information if available

#### get_service_display_name()

class-wc-shipping-shipcloud-api-adapter.php : 1332

Getting service display name by service id.

`private get_service_display_name(int $service_id) : string`

##### Parameters

$service_id : int

##### Return values

string —

#### handle_exception()

class-wc-shipping-shipcloud-api-adapter.php : 1632

Handles Exception and converts it to WP_Error.

`private handle_exception(Exception $e) : WP_Error`

##### Parameters

$e : Exception

  The exception thrown

##### Return values

WP_Error —

#### init()

class-wc-shipping-shipcloud-api-adapter.php : 117

Initialization.

`private init() : void`

##### Return values

void —

#### log()

class-wc-shipping-shipcloud-api-adapter.php : 1656

Output a debug message.

`private log(string $message[, string $level = 'info' ][, mixed $context = [] ]) : void`

##### Parameters

$message : string

  Debug message.

$level : string = 'info'

  Debug level.

$context : mixed = []

  The Debug context.

##### Return values

void —

## Search results