Skip to content

Unable to get "Return Label" Rates #237

@codewithshinde

Description

@codewithshinde

Steps

Issues: Unable to fetch return label rates no matter where I pass is_return: true

Function Call

return await this.shipengine.getRatesWithShipmentDetails(data);

Types

import { z } from 'zod';

export const ShipEngineAddressSchema = z.object({
  name: z.string().min(1, 'Name is required'),
  phone: z.string().optional(),
  companyName: z.string().optional(),
  addressLine1: z.string().min(1, 'Address is required'),
  addressLine2: z.string().optional(),
  cityLocality: z.string().min(1, 'City is required'),
  stateProvince: z.string().min(2, 'State/Province required'),
  postalCode: z.string().min(1, 'Postal code required'),
  countryCode: z
    .string()
    .transform((val) => {
      if (val.toLowerCase() === 'united states') return 'US';
      return val;
    })
    .pipe(z.string().length(2)),
  addressResidentialIndicator: z
    .enum(['yes', 'no', 'unknown'])
    .default('unknown'),
});

export const ShipEnginePackageSchema = z.object({
  weight: z.object({
    value: z.number().positive(),
    unit: z.enum(['pound', 'ounce', 'gram', 'kilogram']),
  }),
  dimensions: z
    .object({
      length: z.number().positive(),
      width: z.number().positive(),
      height: z.number().positive(),
      unit: z.enum(['inch', 'centimeter']),
    })
    .optional(),
});

export const ShipmentPayloadSchema = z.object({
  serviceCode: z.string().optional(),
  carrierId: z.string().optional(),
  shipTo: ShipEngineAddressSchema,
  shipFrom: ShipEngineAddressSchema,
  packages: z.array(ShipEnginePackageSchema).min(1),
  is_return: z.boolean().default(false),
  advancedOptions: z.object({
    reference1: z.string().optional(),
    reference2: z.string().optional(),
    reference3: z.string().optional(),
    originType: z.enum(['pickup', 'drop_off']).optional(),
  }).optional(),
});

export const GetRatesSchema = z.object({
  shipment: ShipmentPayloadSchema,
  rateOptions: z
    .object({
      carrierIds: z.array(z.string()).min(1),
      serviceCodes: z.array(z.string()).optional(),
      is_return: z.boolean().default(false).optional(),
    })
    .optional(),
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions