Sample code for 30+ languages & platforms
Swift

UPS Rate Request

See more UPS Examples

Simple UPS Rate Example

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let http = CkoHttp()!

    // Use this online tool to generate code from sample JSON:
    // Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "RateRequest": {
    //     "Request": {
    //       "TransactionReference": {
    //         "CustomerContext": "CustomerContext"
    //       }
    //     },
    //     "Shipment": {
    //       "Shipper": {
    //         "Name": "ShipperName",
    //         "ShipperNumber": "ShipperNumber",
    //         "Address": {
    //           "AddressLine": [
    //             "ShipperAddressLine",
    //             "ShipperAddressLine",
    //             "ShipperAddressLine"
    //           ],
    //           "City": "TIMONIUM",
    //           "StateProvinceCode": "MD",
    //           "PostalCode": "21093",
    //           "CountryCode": "US"
    //         }
    //       },
    //       "ShipTo": {
    //         "Name": "ShipToName",
    //         "Address": {
    //           "AddressLine": [
    //             "ShipToAddressLine",
    //             "ShipToAddressLine",
    //             "ShipToAddressLine"
    //           ],
    //           "City": "Alpharetta",
    //           "StateProvinceCode": "GA",
    //           "PostalCode": "30005",
    //           "CountryCode": "US"
    //         }
    //       },
    //       "ShipFrom": {
    //         "Name": "ShipFromName",
    //         "Address": {
    //           "AddressLine": [
    //             "ShipFromAddressLine",
    //             "ShipFromAddressLine",
    //             "ShipFromAddressLine"
    //           ],
    //           "City": "TIMONIUM",
    //           "StateProvinceCode": "MD",
    //           "PostalCode": "21093",
    //           "CountryCode": "US"
    //         }
    //       },
    //       "PaymentDetails": {
    //         "ShipmentCharge": {
    //           "Type": "01",
    //           "BillShipper": {
    //             "AccountNumber": "ShipperNumber"
    //           }
    //         }
    //       },
    //       "Service": {
    //         "Code": "03",
    //         "Description": "Ground"
    //       },
    //       "NumOfPieces": "1",
    //       "Package": {
    //         "PackagingType": {
    //           "Code": "02",
    //           "Description": "Packaging"
    //         },
    //         "Dimensions": {
    //           "UnitOfMeasurement": {
    //             "Code": "IN",
    //             "Description": "Inches"
    //           },
    //           "Length": "5",
    //           "Width": "5",
    //           "Height": "5"
    //         },
    //         "PackageWeight": {
    //           "UnitOfMeasurement": {
    //             "Code": "LBS",
    //             "Description": "Pounds"
    //           },
    //           "Weight": "1"
    //         }
    //       }
    //     }
    //   }
    // }

    let json = CkoJsonObject()!
    json.updateString(jsonPath: "RateRequest.Request.TransactionReference.CustomerContext", value: "CustomerContext")
    json.updateString(jsonPath: "RateRequest.Shipment.Shipper.Name", value: "ShipperName")
    json.updateString(jsonPath: "RateRequest.Shipment.Shipper.ShipperNumber", value: "ShipperNumber")
    json.updateString(jsonPath: "RateRequest.Shipment.Shipper.Address.AddressLine[0]", value: "ShipperAddressLine")
    json.updateString(jsonPath: "RateRequest.Shipment.Shipper.Address.AddressLine[1]", value: "ShipperAddressLine")
    json.updateString(jsonPath: "RateRequest.Shipment.Shipper.Address.AddressLine[2]", value: "ShipperAddressLine")
    json.updateString(jsonPath: "RateRequest.Shipment.Shipper.Address.City", value: "TIMONIUM")
    json.updateString(jsonPath: "RateRequest.Shipment.Shipper.Address.StateProvinceCode", value: "MD")
    json.updateString(jsonPath: "RateRequest.Shipment.Shipper.Address.PostalCode", value: "21093")
    json.updateString(jsonPath: "RateRequest.Shipment.Shipper.Address.CountryCode", value: "US")
    json.updateString(jsonPath: "RateRequest.Shipment.ShipTo.Name", value: "ShipToName")
    json.updateString(jsonPath: "RateRequest.Shipment.ShipTo.Address.AddressLine[0]", value: "ShipToAddressLine")
    json.updateString(jsonPath: "RateRequest.Shipment.ShipTo.Address.AddressLine[1]", value: "ShipToAddressLine")
    json.updateString(jsonPath: "RateRequest.Shipment.ShipTo.Address.AddressLine[2]", value: "ShipToAddressLine")
    json.updateString(jsonPath: "RateRequest.Shipment.ShipTo.Address.City", value: "Alpharetta")
    json.updateString(jsonPath: "RateRequest.Shipment.ShipTo.Address.StateProvinceCode", value: "GA")
    json.updateString(jsonPath: "RateRequest.Shipment.ShipTo.Address.PostalCode", value: "30005")
    json.updateString(jsonPath: "RateRequest.Shipment.ShipTo.Address.CountryCode", value: "US")
    json.updateString(jsonPath: "RateRequest.Shipment.ShipFrom.Name", value: "ShipFromName")
    json.updateString(jsonPath: "RateRequest.Shipment.ShipFrom.Address.AddressLine[0]", value: "ShipFromAddressLine")
    json.updateString(jsonPath: "RateRequest.Shipment.ShipFrom.Address.AddressLine[1]", value: "ShipFromAddressLine")
    json.updateString(jsonPath: "RateRequest.Shipment.ShipFrom.Address.AddressLine[2]", value: "ShipFromAddressLine")
    json.updateString(jsonPath: "RateRequest.Shipment.ShipFrom.Address.City", value: "TIMONIUM")
    json.updateString(jsonPath: "RateRequest.Shipment.ShipFrom.Address.StateProvinceCode", value: "MD")
    json.updateString(jsonPath: "RateRequest.Shipment.ShipFrom.Address.PostalCode", value: "21093")
    json.updateString(jsonPath: "RateRequest.Shipment.ShipFrom.Address.CountryCode", value: "US")
    json.updateString(jsonPath: "RateRequest.Shipment.PaymentDetails.ShipmentCharge.Type", value: "01")
    json.updateString(jsonPath: "RateRequest.Shipment.PaymentDetails.ShipmentCharge.BillShipper.AccountNumber", value: "ShipperNumber")
    json.updateString(jsonPath: "RateRequest.Shipment.Service.Code", value: "03")
    json.updateString(jsonPath: "RateRequest.Shipment.Service.Description", value: "Ground")
    json.updateString(jsonPath: "RateRequest.Shipment.NumOfPieces", value: "1")
    json.updateString(jsonPath: "RateRequest.Shipment.Package.PackagingType.Code", value: "02")
    json.updateString(jsonPath: "RateRequest.Shipment.Package.PackagingType.Description", value: "Packaging")
    json.updateString(jsonPath: "RateRequest.Shipment.Package.Dimensions.UnitOfMeasurement.Code", value: "IN")
    json.updateString(jsonPath: "RateRequest.Shipment.Package.Dimensions.UnitOfMeasurement.Description", value: "Inches")
    json.updateString(jsonPath: "RateRequest.Shipment.Package.Dimensions.Length", value: "5")
    json.updateString(jsonPath: "RateRequest.Shipment.Package.Dimensions.Width", value: "5")
    json.updateString(jsonPath: "RateRequest.Shipment.Package.Dimensions.Height", value: "5")
    json.updateString(jsonPath: "RateRequest.Shipment.Package.PackageWeight.UnitOfMeasurement.Code", value: "LBS")
    json.updateString(jsonPath: "RateRequest.Shipment.Package.PackageWeight.UnitOfMeasurement.Description", value: "Pounds")
    json.updateString(jsonPath: "RateRequest.Shipment.Package.PackageWeight.Weight", value: "1")

    // Load the OAuth2 access token obtained via client credentials as shown 
    // in this UPS OAuth2 Client Credentials example.

    let jsonToken = CkoJsonObject()!
    success = jsonToken.loadFile(path: "qa_data/tokens/ups_oauth2_token.json")
    if success != true {
        print("Failed to load ups_oauth2_token.json")
        return
    }

    // The access token JSON looks something like this:

    // {
    //   "token_type": "Bearer",
    //   "issued_at": "1686911985606",
    //   "client_id": "2498righ8wr6aihe98rt8rhowirtyw9er6twe80rtywrehrt",
    //   "access_token": "eyJraW......R2sbqrY",
    //   "expires_in": "14399",
    //   "status": "approved"
    // }

    // Adds the "Authorization: Bearer <YOUR_TOKEN_HERE>" header.
    http.authToken = jsonToken.string(of: "access_token")
    http.setRequestHeader(name: "Content-Type", value: "application/json")
    http.setRequestHeader(name: "transId", value: "string")
    http.setRequestHeader(name: "transactionSrc", value: "testing")

    // The "version" indicates Rate API to display the new release features in Rate API response based on Rate release.
    // Supported values: v1, v1601, v1607, v1701, v1707, v2108, v2205.
    http.setUrlVar(name: "version", value: "v1")

    // The "requestoption" has the following valid values:
    // Rate = The server rates (The default Request option is Rate if a Request Option is not provided). 
    // Shop = The server validates the shipment, and returns rates for all UPS products from the ShipFrom to the ShipTo addresses. 
    // Rate is the only valid request option for Ground Freight Pricing requests.
    http.setUrlVar(name: "requestoption", value: "Rate")

    let resp = CkoHttpResponse()!
    success = http.httpJson(verb: "POST", url: "https://wwwcie.ups.com/api/rating/{$version}/{$requestoption}?additionalinfo=string", json: json, contentType: "application/json", response: resp)
    if success == false {
        print("\(http.lastErrorText!)")
        return
    }

    let sbResponseBody = CkoStringBuilder()!
    resp.getBodySb(sb: sbResponseBody)

    let jResp = CkoJsonObject()!
    jResp.loadSb(sb: sbResponseBody)
    jResp.emitCompact = false

    print("Response Body:")
    print("\(jResp.emit()!)")

    // ----------------------------------------------------------------------------------------------------------
    // Important: If you get the following error response, read further for the solution..
    // 
    // {
    //   "response": {
    //     "errors": [
    //       {
    //         "code": "250002",
    //         "message": "Invalid Authentication Information."
    //       }
    //     ]
    //   }
    // }
    // 
    // It means you didn't add the Rating API permission to your app.
    // To add the Rating API, login to your developer account and go to your Apps page at https://developer.ups.com/apps?loc=en_US
    // Then edit your app and add the Rating API.
    // ----------------------------------------------------------------------------------------------------------

    var respStatusCode: Int = resp.statusCode.intValue
    print("Response Status Code = \(respStatusCode)")
    if respStatusCode >= 400 {
        print("Response Header:")
        print("\(resp.header!)")
        print("Failed.")
        return
    }

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "RateResponse": {
    //     "Response": {
    //       "ResponseStatus": {
    //         "Code": "s",
    //         "Description": "string"
    //       },
    //       "Alert": [
    //         {
    //           "Code": "string",
    //           "Description": "string"
    //         }
    //       ],
    //       "AlertDetail": [
    //         {
    //           "Code": "string",
    //           "Description": "string",
    //           "ElementLevelInformation": {
    //             "Level": "s",
    //             "ElementIdentifier": [
    //               {
    //                 "Code": null,
    //                 "Value": null
    //               }
    //             ]
    //           }
    //         }
    //       ],
    //       "TransactionReference": {
    //         "CustomerContext": "string"
    //       }
    //     },
    //     "RatedShipment": [
    //       {
    //         "Disclaimer": [
    //           {
    //             "Code": "st",
    //             "Description": "string"
    //           }
    //         ],
    //         "Service": {
    //           "Code": "str",
    //           "Description": "string"
    //         },
    //         "RateChart": "s",
    //         "RatedShipmentAlert": [
    //           {
    //             "Code": "string",
    //             "Description": "string"
    //           }
    //         ],
    //         "BillableWeightCalculationMethod": "st",
    //         "RatingMethod": "st",
    //         "BillingWeight": {
    //           "UnitOfMeasurement": {
    //             "Code": "str",
    //             "Description": "string"
    //           },
    //           "Weight": "strin"
    //         },
    //         "TransportationCharges": {
    //           "CurrencyCode": "str",
    //           "MonetaryValue": "stringstringstri"
    //         },
    //         "BaseServiceCharge": {
    //           "CurrencyCode": "str",
    //           "MonetaryValue": "stringstringstri"
    //         },
    //         "ItemizedCharges": [
    //           {
    //             "Code": "str",
    //             "Description": "string",
    //             "CurrencyCode": "str",
    //             "MonetaryValue": "string",
    //             "SubType": "string"
    //           }
    //         ],
    //         "FRSShipmentData": {
    //           "TransportationCharges": {
    //             "GrossCharge": {
    //               "CurrencyCode": "str",
    //               "MonetaryValue": "string"
    //             },
    //             "DiscountAmount": {
    //               "CurrencyCode": "str",
    //               "MonetaryValue": "string"
    //             },
    //             "DiscountPercentage": "st",
    //             "NetCharge": {
    //               "CurrencyCode": "str",
    //               "MonetaryValue": "string"
    //             }
    //           },
    //           "FreightDensityRate": {
    //             "Density": "strin",
    //             "TotalCubicFeet": "string"
    //           },
    //           "HandlingUnits": [
    //             {
    //               "Quantity": "string",
    //               "Type": {
    //                 "Code": null,
    //                 "Description": null
    //               },
    //               "Dimensions": {
    //                 "UnitOfMeasurement": null,
    //                 "Length": null,
    //                 "Width": null,
    //                 "Height": null
    //               },
    //               "AdjustedHeight": {
    //                 "Value": null,
    //                 "UnitOfMeasurement": null
    //               }
    //             }
    //           ]
    //         },
    //         "ServiceOptionsCharges": {
    //           "CurrencyCode": "str",
    //           "MonetaryValue": "string"
    //         },
    //         "TaxCharges": [
    //           {
    //             "Type": "string",
    //             "MonetaryValue": "string"
    //           }
    //         ],
    //         "TotalCharges": {
    //           "CurrencyCode": "str",
    //           "MonetaryValue": "string"
    //         },
    //         "TotalChargesWithTaxes": {
    //           "CurrencyCode": "str",
    //           "MonetaryValue": "string"
    //         },
    //         "NegotiatedRateCharges": {
    //           "ItemizedCharges": [
    //             {
    //               "Code": "str",
    //               "Description": "string",
    //               "CurrencyCode": "str",
    //               "MonetaryValue": "string",
    //               "SubType": "string"
    //             }
    //           ],
    //           "TaxCharges": [
    //             {
    //               "Type": "string",
    //               "MonetaryValue": "string"
    //             }
    //           ],
    //           "TotalCharge": {
    //             "CurrencyCode": "string",
    //             "MonetaryValue": "string"
    //           },
    //           "TotalChargesWithTaxes": {
    //             "CurrencyCode": "string",
    //             "MonetaryValue": "string"
    //           }
    //         },
    //         "RatedPackage": [
    //           {
    //             "BaseServiceCharge": {
    //               "CurrencyCode": "str",
    //               "MonetaryValue": "string"
    //             },
    //             "TransportationCharges": {
    //               "CurrencyCode": "string",
    //               "MonetaryValue": "string"
    //             },
    //             "ServiceOptionsCharges": {
    //               "CurrencyCode": "string",
    //               "MonetaryValue": "string"
    //             },
    //             "TotalCharges": {
    //               "CurrencyCode": "string",
    //               "MonetaryValue": "string"
    //             },
    //             "Weight": "string",
    //             "BillingWeight": {
    //               "UnitOfMeasurement": {
    //                 "Code": null,
    //                 "Description": null
    //               },
    //               "Weight": "string"
    //             },
    //             "Accessorial": [
    //               {
    //                 "Code": null,
    //                 "Description": null
    //               }
    //             ],
    //             "ItemizedCharges": [
    //               {
    //                 "Code": null,
    //                 "Description": null,
    //                 "CurrencyCode": null,
    //                 "MonetaryValue": null,
    //                 "SubType": null
    //               }
    //             ],
    //             "NegotiatedCharges": {
    //               "ItemizedCharges": [
    //                 null
    //               ]
    //             },
    //             "SimpleRate": {
    //               "Code": "st"
    //             },
    //             "RateModifier": [
    //               {
    //                 "ModifierType": null,
    //                 "ModifierDesc": null,
    //                 "Amount": null
    //               }
    //             ]
    //           }
    //         ],
    //         "TimeInTransit": {
    //           "PickupDate": "stringst",
    //           "DocumentsOnlyIndicator": "string",
    //           "PackageBillType": "st",
    //           "ServiceSummary": {
    //             "Service": {
    //               "Description": "string"
    //             },
    //             "GuaranteedIndicator": "string",
    //             "Disclaimer": "string",
    //             "EstimatedArrival": {
    //               "Arrival": {
    //                 "Date": null,
    //                 "Time": null
    //               },
    //               "BusinessDaysInTransit": "strin",
    //               "Pickup": {
    //                 "Date": null,
    //                 "Time": null
    //               },
    //               "DayOfWeek": "string",
    //               "CustomerCenterCutoff": "string",
    //               "DelayCount": "str",
    //               "HolidayCount": "st",
    //               "RestDays": "st",
    //               "TotalTransitDays": "strin"
    //             },
    //             "SaturdayDelivery": "string",
    //             "SaturdayDeliveryDisclaimer": "string",
    //             "SundayDelivery": "string",
    //             "SundayDeliveryDisclaimer": "string"
    //           },
    //           "AutoDutyCode": "st",
    //           "Disclaimer": "string"
    //         },
    //         "ScheduledDeliveryDate": "string",
    //         "RoarRatedIndicator": "string"
    //       }
    //     ]
    //   }
    // }

    // Sample code for parsing the JSON response...
    // Use the following online tool to generate parsing code from sample JSON:
    // Generate Parsing Code from JSON

    var Level: String?
    var j: Int
    var count_j: Int
    var Value: String?
    var ServiceCode: String?
    var ServiceDescription: String?
    var RateChart: String?
    var BillableWeightCalculationMethod: String?
    var RatingMethod: String?
    var UnitOfMeasurementCode: String?
    var UnitOfMeasurementDescription: String?
    var Weight: String?
    var CurrencyCode: String?
    var MonetaryValue: String?
    var BaseServiceChargeCurrencyCode: String?
    var BaseServiceChargeMonetaryValue: String?
    var GrossChargeCurrencyCode: String?
    var GrossChargeMonetaryValue: String?
    var DiscountAmountCurrencyCode: String?
    var DiscountAmountMonetaryValue: String?
    var DiscountPercentage: String?
    var NetChargeCurrencyCode: String?
    var NetChargeMonetaryValue: String?
    var Density: String?
    var TotalCubicFeet: String?
    var ServiceOptionsChargesCurrencyCode: String?
    var ServiceOptionsChargesMonetaryValue: String?
    var TotalChargesCurrencyCode: String?
    var TotalChargesMonetaryValue: String?
    var TotalChargesWithTaxesCurrencyCode: String?
    var TotalChargesWithTaxesMonetaryValue: String?
    var TotalChargeCurrencyCode: String?
    var TotalChargeMonetaryValue: String?
    var PickupDate: String?
    var DocumentsOnlyIndicator: String?
    var PackageBillType: String?
    var GuaranteedIndicator: String?
    var Disclaimer: String?
    var Date: String?
    var Time: String?
    var BusinessDaysInTransit: String?
    var PickupTime: String?
    var DayOfWeek: String?
    var CustomerCenterCutoff: String?
    var DelayCount: String?
    var HolidayCount: String?
    var RestDays: String?
    var TotalTransitDays: String?
    var SaturdayDelivery: String?
    var SaturdayDeliveryDisclaimer: String?
    var SundayDelivery: String?
    var SundayDeliveryDisclaimer: String?
    var AutoDutyCode: String?
    var TimeInTransitDisclaimer: String?
    var ScheduledDeliveryDate: String?
    var RoarRatedIndicator: String?
    var SubType: String?
    var Quantity: String?
    var TypeCode: String?
    var TypeDescription: String?
    var UnitOfMeasurement: String?
    var Length: String?
    var Width: String?
    var Height: String?
    var AdjustedHeightValue: String?
    var AdjustedHeightUnitOfMeasurement: String?
    var v_Type: String?
    var TransportationChargesCurrencyCode: String?
    var TransportationChargesMonetaryValue: String?
    var BillingWeightWeight: String?
    var SimpleRateCode: String?
    var k: Int
    var count_k: Int
    var nullVal: Bool
    var ModifierType: String?
    var ModifierDesc: String?
    var Amount: String?

    var Code: String? = jResp.string(of: "RateResponse.Response.ResponseStatus.Code")
    var Description: String? = jResp.string(of: "RateResponse.Response.ResponseStatus.Description")
    var CustomerContext: String? = jResp.string(of: "RateResponse.Response.TransactionReference.CustomerContext")
    var i: Int = 0
    var count_i: Int = jResp.size(ofArray: "RateResponse.Response.Alert").intValue
    while i < count_i {
        jResp.i = i
        Code = jResp.string(of: "RateResponse.Response.Alert[i].Code")
        Description = jResp.string(of: "RateResponse.Response.Alert[i].Description")
        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "RateResponse.Response.AlertDetail").intValue
    while i < count_i {
        jResp.i = i
        Code = jResp.string(of: "RateResponse.Response.AlertDetail[i].Code")
        Description = jResp.string(of: "RateResponse.Response.AlertDetail[i].Description")
        Level = jResp.string(of: "RateResponse.Response.AlertDetail[i].ElementLevelInformation.Level")
        j = 0
        count_j = jResp.size(ofArray: "RateResponse.Response.AlertDetail[i].ElementLevelInformation.ElementIdentifier").intValue
        while j < count_j {
            jResp.j = j
            Code = jResp.string(of: "RateResponse.Response.AlertDetail[i].ElementLevelInformation.ElementIdentifier[j].Code")
            Value = jResp.string(of: "RateResponse.Response.AlertDetail[i].ElementLevelInformation.ElementIdentifier[j].Value")
            j = j + 1
        }

        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "RateResponse.RatedShipment").intValue
    while i < count_i {
        jResp.i = i
        ServiceCode = jResp.string(of: "RateResponse.RatedShipment[i].Service.Code")
        ServiceDescription = jResp.string(of: "RateResponse.RatedShipment[i].Service.Description")
        RateChart = jResp.string(of: "RateResponse.RatedShipment[i].RateChart")
        BillableWeightCalculationMethod = jResp.string(of: "RateResponse.RatedShipment[i].BillableWeightCalculationMethod")
        RatingMethod = jResp.string(of: "RateResponse.RatedShipment[i].RatingMethod")
        UnitOfMeasurementCode = jResp.string(of: "RateResponse.RatedShipment[i].BillingWeight.UnitOfMeasurement.Code")
        UnitOfMeasurementDescription = jResp.string(of: "RateResponse.RatedShipment[i].BillingWeight.UnitOfMeasurement.Description")
        Weight = jResp.string(of: "RateResponse.RatedShipment[i].BillingWeight.Weight")
        CurrencyCode = jResp.string(of: "RateResponse.RatedShipment[i].TransportationCharges.CurrencyCode")
        MonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].TransportationCharges.MonetaryValue")
        BaseServiceChargeCurrencyCode = jResp.string(of: "RateResponse.RatedShipment[i].BaseServiceCharge.CurrencyCode")
        BaseServiceChargeMonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].BaseServiceCharge.MonetaryValue")
        GrossChargeCurrencyCode = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.TransportationCharges.GrossCharge.CurrencyCode")
        GrossChargeMonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.TransportationCharges.GrossCharge.MonetaryValue")
        DiscountAmountCurrencyCode = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.TransportationCharges.DiscountAmount.CurrencyCode")
        DiscountAmountMonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.TransportationCharges.DiscountAmount.MonetaryValue")
        DiscountPercentage = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.TransportationCharges.DiscountPercentage")
        NetChargeCurrencyCode = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.TransportationCharges.NetCharge.CurrencyCode")
        NetChargeMonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.TransportationCharges.NetCharge.MonetaryValue")
        Density = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.FreightDensityRate.Density")
        TotalCubicFeet = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.FreightDensityRate.TotalCubicFeet")
        ServiceOptionsChargesCurrencyCode = jResp.string(of: "RateResponse.RatedShipment[i].ServiceOptionsCharges.CurrencyCode")
        ServiceOptionsChargesMonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].ServiceOptionsCharges.MonetaryValue")
        TotalChargesCurrencyCode = jResp.string(of: "RateResponse.RatedShipment[i].TotalCharges.CurrencyCode")
        TotalChargesMonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].TotalCharges.MonetaryValue")
        TotalChargesWithTaxesCurrencyCode = jResp.string(of: "RateResponse.RatedShipment[i].TotalChargesWithTaxes.CurrencyCode")
        TotalChargesWithTaxesMonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].TotalChargesWithTaxes.MonetaryValue")
        TotalChargeCurrencyCode = jResp.string(of: "RateResponse.RatedShipment[i].NegotiatedRateCharges.TotalCharge.CurrencyCode")
        TotalChargeMonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].NegotiatedRateCharges.TotalCharge.MonetaryValue")
        TotalChargesWithTaxesCurrencyCode = jResp.string(of: "RateResponse.RatedShipment[i].NegotiatedRateCharges.TotalChargesWithTaxes.CurrencyCode")
        TotalChargesWithTaxesMonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].NegotiatedRateCharges.TotalChargesWithTaxes.MonetaryValue")
        PickupDate = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.PickupDate")
        DocumentsOnlyIndicator = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.DocumentsOnlyIndicator")
        PackageBillType = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.PackageBillType")
        ServiceDescription = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.Service.Description")
        GuaranteedIndicator = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.GuaranteedIndicator")
        Disclaimer = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.Disclaimer")
        Date = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.EstimatedArrival.Arrival.Date")
        Time = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.EstimatedArrival.Arrival.Time")
        BusinessDaysInTransit = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.EstimatedArrival.BusinessDaysInTransit")
        PickupDate = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.EstimatedArrival.Pickup.Date")
        PickupTime = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.EstimatedArrival.Pickup.Time")
        DayOfWeek = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.EstimatedArrival.DayOfWeek")
        CustomerCenterCutoff = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.EstimatedArrival.CustomerCenterCutoff")
        DelayCount = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.EstimatedArrival.DelayCount")
        HolidayCount = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.EstimatedArrival.HolidayCount")
        RestDays = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.EstimatedArrival.RestDays")
        TotalTransitDays = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.EstimatedArrival.TotalTransitDays")
        SaturdayDelivery = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.SaturdayDelivery")
        SaturdayDeliveryDisclaimer = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.SaturdayDeliveryDisclaimer")
        SundayDelivery = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.SundayDelivery")
        SundayDeliveryDisclaimer = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.ServiceSummary.SundayDeliveryDisclaimer")
        AutoDutyCode = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.AutoDutyCode")
        TimeInTransitDisclaimer = jResp.string(of: "RateResponse.RatedShipment[i].TimeInTransit.Disclaimer")
        ScheduledDeliveryDate = jResp.string(of: "RateResponse.RatedShipment[i].ScheduledDeliveryDate")
        RoarRatedIndicator = jResp.string(of: "RateResponse.RatedShipment[i].RoarRatedIndicator")
        j = 0
        count_j = jResp.size(ofArray: "RateResponse.RatedShipment[i].Disclaimer").intValue
        while j < count_j {
            jResp.j = j
            Code = jResp.string(of: "RateResponse.RatedShipment[i].Disclaimer[j].Code")
            Description = jResp.string(of: "RateResponse.RatedShipment[i].Disclaimer[j].Description")
            j = j + 1
        }

        j = 0
        count_j = jResp.size(ofArray: "RateResponse.RatedShipment[i].RatedShipmentAlert").intValue
        while j < count_j {
            jResp.j = j
            Code = jResp.string(of: "RateResponse.RatedShipment[i].RatedShipmentAlert[j].Code")
            Description = jResp.string(of: "RateResponse.RatedShipment[i].RatedShipmentAlert[j].Description")
            j = j + 1
        }

        j = 0
        count_j = jResp.size(ofArray: "RateResponse.RatedShipment[i].ItemizedCharges").intValue
        while j < count_j {
            jResp.j = j
            Code = jResp.string(of: "RateResponse.RatedShipment[i].ItemizedCharges[j].Code")
            Description = jResp.string(of: "RateResponse.RatedShipment[i].ItemizedCharges[j].Description")
            CurrencyCode = jResp.string(of: "RateResponse.RatedShipment[i].ItemizedCharges[j].CurrencyCode")
            MonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].ItemizedCharges[j].MonetaryValue")
            SubType = jResp.string(of: "RateResponse.RatedShipment[i].ItemizedCharges[j].SubType")
            j = j + 1
        }

        j = 0
        count_j = jResp.size(ofArray: "RateResponse.RatedShipment[i].FRSShipmentData.HandlingUnits").intValue
        while j < count_j {
            jResp.j = j
            Quantity = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.HandlingUnits[j].Quantity")
            TypeCode = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.HandlingUnits[j].Type.Code")
            TypeDescription = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.HandlingUnits[j].Type.Description")
            UnitOfMeasurement = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.HandlingUnits[j].Dimensions.UnitOfMeasurement")
            Length = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.HandlingUnits[j].Dimensions.Length")
            Width = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.HandlingUnits[j].Dimensions.Width")
            Height = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.HandlingUnits[j].Dimensions.Height")
            AdjustedHeightValue = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.HandlingUnits[j].AdjustedHeight.Value")
            AdjustedHeightUnitOfMeasurement = jResp.string(of: "RateResponse.RatedShipment[i].FRSShipmentData.HandlingUnits[j].AdjustedHeight.UnitOfMeasurement")
            j = j + 1
        }

        j = 0
        count_j = jResp.size(ofArray: "RateResponse.RatedShipment[i].TaxCharges").intValue
        while j < count_j {
            jResp.j = j
            v_Type = jResp.string(of: "RateResponse.RatedShipment[i].TaxCharges[j].Type")
            MonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].TaxCharges[j].MonetaryValue")
            j = j + 1
        }

        j = 0
        count_j = jResp.size(ofArray: "RateResponse.RatedShipment[i].NegotiatedRateCharges.ItemizedCharges").intValue
        while j < count_j {
            jResp.j = j
            Code = jResp.string(of: "RateResponse.RatedShipment[i].NegotiatedRateCharges.ItemizedCharges[j].Code")
            Description = jResp.string(of: "RateResponse.RatedShipment[i].NegotiatedRateCharges.ItemizedCharges[j].Description")
            CurrencyCode = jResp.string(of: "RateResponse.RatedShipment[i].NegotiatedRateCharges.ItemizedCharges[j].CurrencyCode")
            MonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].NegotiatedRateCharges.ItemizedCharges[j].MonetaryValue")
            SubType = jResp.string(of: "RateResponse.RatedShipment[i].NegotiatedRateCharges.ItemizedCharges[j].SubType")
            j = j + 1
        }

        j = 0
        count_j = jResp.size(ofArray: "RateResponse.RatedShipment[i].NegotiatedRateCharges.TaxCharges").intValue
        while j < count_j {
            jResp.j = j
            v_Type = jResp.string(of: "RateResponse.RatedShipment[i].NegotiatedRateCharges.TaxCharges[j].Type")
            MonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].NegotiatedRateCharges.TaxCharges[j].MonetaryValue")
            j = j + 1
        }

        j = 0
        count_j = jResp.size(ofArray: "RateResponse.RatedShipment[i].RatedPackage").intValue
        while j < count_j {
            jResp.j = j
            BaseServiceChargeCurrencyCode = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].BaseServiceCharge.CurrencyCode")
            BaseServiceChargeMonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].BaseServiceCharge.MonetaryValue")
            TransportationChargesCurrencyCode = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].TransportationCharges.CurrencyCode")
            TransportationChargesMonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].TransportationCharges.MonetaryValue")
            ServiceOptionsChargesCurrencyCode = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].ServiceOptionsCharges.CurrencyCode")
            ServiceOptionsChargesMonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].ServiceOptionsCharges.MonetaryValue")
            TotalChargesCurrencyCode = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].TotalCharges.CurrencyCode")
            TotalChargesMonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].TotalCharges.MonetaryValue")
            Weight = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].Weight")
            UnitOfMeasurementCode = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].BillingWeight.UnitOfMeasurement.Code")
            UnitOfMeasurementDescription = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].BillingWeight.UnitOfMeasurement.Description")
            BillingWeightWeight = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].BillingWeight.Weight")
            SimpleRateCode = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].SimpleRate.Code")
            k = 0
            count_k = jResp.size(ofArray: "RateResponse.RatedShipment[i].RatedPackage[j].Accessorial").intValue
            while k < count_k {
                jResp.k = k
                Code = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].Accessorial[k].Code")
                Description = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].Accessorial[k].Description")
                k = k + 1
            }

            k = 0
            count_k = jResp.size(ofArray: "RateResponse.RatedShipment[i].RatedPackage[j].ItemizedCharges").intValue
            while k < count_k {
                jResp.k = k
                Code = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].ItemizedCharges[k].Code")
                Description = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].ItemizedCharges[k].Description")
                CurrencyCode = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].ItemizedCharges[k].CurrencyCode")
                MonetaryValue = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].ItemizedCharges[k].MonetaryValue")
                SubType = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].ItemizedCharges[k].SubType")
                k = k + 1
            }

            k = 0
            count_k = jResp.size(ofArray: "RateResponse.RatedShipment[i].RatedPackage[j].NegotiatedCharges.ItemizedCharges").intValue
            while k < count_k {
                jResp.k = k
                nullVal = jResp.isNull(of: "RateResponse.RatedShipment[i].RatedPackage[j].NegotiatedCharges.ItemizedCharges[k]")
                k = k + 1
            }

            k = 0
            count_k = jResp.size(ofArray: "RateResponse.RatedShipment[i].RatedPackage[j].RateModifier").intValue
            while k < count_k {
                jResp.k = k
                ModifierType = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].RateModifier[k].ModifierType")
                ModifierDesc = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].RateModifier[k].ModifierDesc")
                Amount = jResp.string(of: "RateResponse.RatedShipment[i].RatedPackage[j].RateModifier[k].Amount")
                k = k + 1
            }

            j = j + 1
        }

        i = i + 1
    }


}