# UPS Shiping

### Contents

* [1 Business Brixx UPS Shipping](https://brixxbox.gitbook.io/brixxbox-documentation/client-api-reference/functions/businessbrixx/broken-reference)
* [2 Business Brixx UPS Shipping -> CreateShipment](https://brixxbox.gitbook.io/brixxbox-documentation/client-api-reference/functions/businessbrixx/broken-reference)
  * [2.1 Incomming Information](https://brixxbox.gitbook.io/brixxbox-documentation/client-api-reference/functions/businessbrixx/broken-reference)
  * [2.2 Returning Information](https://brixxbox.gitbook.io/brixxbox-documentation/client-api-reference/functions/businessbrixx/broken-reference)
  * [2.3 Example Usages](https://brixxbox.gitbook.io/brixxbox-documentation/client-api-reference/functions/businessbrixx/broken-reference)
* [3 CancelShipment](https://brixxbox.gitbook.io/brixxbox-documentation/client-api-reference/functions/businessbrixx/broken-reference)
* [4 GetLabel](https://brixxbox.gitbook.io/brixxbox-documentation/client-api-reference/functions/businessbrixx/broken-reference)

### Business Brixx UPS Shipping

For accessing the UPS-Shipping brixxbox interface the UPS services need the following setup values (configuration -> settings).

* **UPSCustomerID** Your customer number with UPS
* **UPSUsername** A valid User for accessing the services
* **UPSPassword** The corresponding password
* **UPSAccessLicenseNumber** A license/access key provided by UPS on this page <https://www.ups.com/upsdeveloperkit>

If no settings are available, a sample label will be generated.

### Business Brixx UPS Shipping -> CreateShipment

Creates a UPS shipping label

### Incomming Information

To create labels four groups of information are available:

* **1. Settings** with the following fields (If the group/field is not present default values will be assumed)
  * **ServiceCode:** default value "11" UPS Standard. Valid values according to UPS service codes.
  * **MetricMeasurements:** "1" sets to true. This is the default. Measurements will be metric e.g. kg, cm or nonmetric for lbs, inch
  * **Language:** Language code according to UPS. e.g. deu, eng, spa. this field will be set to user language by default. If the user language is not available for UPS, "eng" will be used.
* **2. Shipper:**
  * Name
  * Street
  * HouseNo
  * ZipCode
  * City
  * CountryCode
  * StateProvinceCode
  * AttentionName
  * Phone
  * EMail
  * FaxNumber
  * TaxIdentificationNumber
* **3. ShipAddress:**
  * Name
  * Street
  * HouseNo
  * ZipCode
  * City
  * CountryCode
  * StateProvinceCode
  * AttentionName
  * Phone
  * EMail
  * FaxNumber
  * TaxIdentificationNumber
* **4. ParcelData:**
  * Description
  * **PackageType:** Package type according to UPS. If no value is given, the default will be set to: "02" Customer Supplied Package
  * Weight
  * Height
  * Length
  * Width

### Returning Information

* In case of **success (status 200)** the following fields are returned
  * **TrackingNumber:** The UPS generated ID. This will be used for further references to this shipment.
  * **LabelData:** this is a blob response. It contains the actual label in GIF format and can directly be used for further processing. E.g. “brixxApi.printBlob(LabelData);”
* In case of **error (status 400)** the following fields are returned:
  * **error:** a text showing the first error. E.g. “console.log(result.error);”

### Example Usages

```javascript
var result = await brixxApi.businessBrixx({
      functionName:"UPSShipping",
      methodName: "CreateShipment",
			Settings : {
				Language: 'deu',
				MetricMeasurements: 1,
				ServiceCode: "11"
			  },
			Shipper : {
				Name: 'Brixxbox GmbH',
				Street: 'Husarenstraße',
				HouseNo: '34a',
				ZipCode: '41836',
				City: 'Hückelhoven',
				CountryCode: 'DE'
			  },
			ShipAddress : {
				Name: 'Brixxbox GmbH',
				Street: 'Husarenstraße',
				HouseNo: '34b',
				ZipCode: '41836',
				City: 'Hückelhoven',
				CountryCode: 'DE',
				Phone: '+49 1234 5678-9',
				Mail: 'm.mustermann@mustermann.com'			  
			  },
			ParcelData : {
				Description: 'Product name',
				Height : 10,
				Length : 20,
				Width  : 15,
				Weight: '4.5',
				ServiceCode: '9'			  
			  }
      });
	  
console.log("Tracking Number: " + result.TrackingNumber);
brixxApi.printBlob(result.LabelData);
```

### CancelShipment

To cancel an existing shipment only the **TrackingNumber** is needed.

```javascript
var result = await brixxApi.businessBrixx({
      functionName:"UPSShipping",
      methodName: "CancelShipment",
	 TrackingNumber: app.getFieldValue("ExistingTrackingNumber")
      });
```

### GetLabel

In case the label is needed again it can be retrieved with an existing **TrackingNumber**. The result will show LabelData (see **CreateShipment results** [#Returning\_Information](https://brixxbox.gitbook.io/brixxbox-documentation/client-api-reference/functions/businessbrixx/broken-reference) for details)

```javascript
var result = await brixxApi.businessBrixx({
      functionName:"UPSShipping",
      methodName: "GetLabel",
	 TrackingNumber: app.getFieldValue("ExistingTrackingNumber")
      });
```
