@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
116 lines • 6.39 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createRatesShopResource = createRatesShopResource;
exports.createRatesShopDataResource = createRatesShopDataResource;
const schemas_1 = require("../schemas");
/**
* Creates the ratesShop resource methods
* OpenAPI Path: /rates-shop → ratesShop.*
* @description Rates shop endpoint for UPS service
*/
function createRatesShopResource(executeRequest) {
return {
/**
* Shop UPS shipping rates for packages with comprehensive service options
*
* @fullPath api.ups.ratesShop.get
* @service ups
* @domain shipping-and-logistics
* @dataMethod ratesShopData.get
* @discoverable true
* @searchTerms ["ups rates", "shipping cost", "ups pricing", "package shipping", "ups quotes", "delivery cost", "ground", "air", "next day", "2-day", "3-day", "international"]
* @relatedEndpoints ["api.shipping.rates.calculate", "api.logistics.speedship.freight.get", "api.commerce.cart.shipping.calculate", "api.orders.shipping.estimate", "api.customers.addresses.validate"]
* @commonPatterns ["Calculate UPS shipping cost", "Compare UPS services", "Get UPS delivery options", "Estimate UPS shipping", "Find cheapest UPS option", "Get fastest UPS delivery"]
* @workflow ["e-commerce-checkout", "order-fulfillment", "shipping-estimation", "ups-rate-comparison", "carrier-selection", "delivery-planning", "shipping-cost-analysis"]
* @prerequisites ["Valid shipping addresses", "Package weight specified", "Valid authentication token", "x-site-id header", "UPS API access", "Complete address information"]
* @nextSteps ["Select UPS service option", "Create UPS shipping label", "Track UPS shipment", "Update order with UPS shipping cost", "Process payment with UPS shipping"]
* @businessRules ["Requires origin and destination addresses", "Package weight is mandatory", "Supports single package shipments", "Returns UPS-specific rates and services", "Includes all UPS fees and surcharges", "Respects UPS service area limitations"]
* @functionalArea "shipping-and-logistics"
* @crossSite "Supports multi-site UPS configurations and different UPS accounts per site"
* @caching "Cache UPS rates for 15 minutes, invalidate on address or package changes"
* @performance "Single UPS API call, optimized for UPS rate shopping, supports edge caching with cacheSiteId parameter"
*
* @param params Complete UPS rate shopping request with addresses and package information
* @returns Promise<RatesShopResponse> UPS shipping rates with service options and delivery information
*
* @example
* ```typescript
* // Calculate UPS rates for e-commerce order
* const upsRateRequest = {
* // Origin address (warehouse/fulfillment center)
* fromAddress1: '123 Warehouse Blvd',
* fromCity: 'Los Angeles',
* fromStateProvinceCode: 'CA',
* fromPostalCode: '90210',
* fromCountryCode: 'US',
*
* // Customer delivery address
* toAddress1: '456 Customer St',
* toCity: 'New York',
* toStateProvinceCode: 'NY',
* toPostalCode: '10001',
* toCountryCode: 'US',
*
* // Package information (required)
* weight: 5, // pounds
*
* // Optional caching for performance
* cacheSiteId: 'ECOMMERCE-SITE',
* 'x-site-id': 'SITE123'
* };
*
* const response = await client.ratesShop.get(upsRateRequest);
* console.log(response.data.rates); // Array of UPS shipping rates
* console.log(response.data.cheapest_rate); // Most economical option
* console.log(response.data.fastest_rate); // Quickest delivery option
* console.log(response.status); // HTTP status code
*
* // Get just the rates data
* const ratesData = await client.ratesShop.getData(upsRateRequest);
* console.log(ratesData); // Direct UPS rates data access
* ```
*/
get: async (params) => {
return executeRequest({
method: 'GET',
path: '/rates-shop',
paramsSchema: schemas_1.RatesShopParamsSchema,
responseSchema: schemas_1.RatesShopResponseSchema,
}, params);
},
};
}
/**
* Creates the ratesShopData resource methods (data-only versions)
*/
function createRatesShopDataResource(ratesShop) {
return {
/**
* Get UPS shipping rates data without full response metadata
*
* @fullPath api.ups.ratesShop.getData
* @service ups
* @domain shipping-and-logistics
* @dataMethod ratesShopData
* @discoverable true
* @searchTerms ["ups rates data", "shipping cost data", "ups pricing data", "delivery quotes", "carrier rates"]
* @relatedEndpoints ["api.ups.ratesShop.get", "api.shipping.rates.calculate", "api.commerce.cart.shipping.calculate"]
* @commonPatterns ["Get UPS rates data", "Calculate UPS shipping cost", "Compare UPS service options", "Extract UPS pricing"]
* @workflow ["e-commerce-checkout", "order-fulfillment", "shipping-estimation", "ups-rate-analysis"]
* @prerequisites ["Valid shipping addresses", "Package weight", "Valid authentication token", "UPS API access"]
* @nextSteps ["Select UPS service option", "Create UPS shipping label", "Process payment with UPS cost"]
* @businessRules ["Returns only UPS rates data", "No response metadata included", "Direct access to rate comparison"]
* @functionalArea "shipping-and-logistics"
* @caching "Cache UPS rates for 15 minutes"
* @performance "Direct data access, optimal for UPS rate comparisons and e-commerce integrations"
*
* @param params Complete UPS rate shopping request parameters
* @returns Promise<RatesShopData> Direct UPS shipping rates data without response wrapper
*/
get: async (params) => {
const response = await ratesShop.get(params);
return response.data;
},
};
}
//# sourceMappingURL=rates-shop.js.map