/// <summary>
        /// Before posting a shipment, you can retrieve the carrier’s shipment rules, including the available services and parcel types, with
        /// weight and dimension restrictions.
        ///
        /// Things to Consider:
        ///     * The call to retrieve rate rules is an expensive API call because of the size of the returned data.It is recommended that you
        ///     cache the returned data and make the API call only once a day.
        ///     * At the top level, rules are organized by service type.
        ///     * Within a service type, each set of rules applies to a combination of parcel type (parcelTypeRules.parcelType) and rate type
        ///     (parcelTypeRules.rateTypeId).
        ///
        /// Rules tell you:
        ///     * Compatible special services (parcelTypeRules.specialServiceRules)
        ///     * Required special services (parcelTypeRules.specialServiceRules.prerequisiteRules)
        ///     * Incompatible special services (parcelTypeRules.specialServiceRules.incompatibleSpecialServices)
        ///     * Required input parameters (parcelTypeRules.specialServiceRules.inputParameterRules)
        ///     * Weight constraints (parcelTypeRules.weightRules)
        ///     * Dimension constraints (parcelTypeRules.dimensionRules)
        /// <param name="request"></param>
        /// <param name="session"></param>
        /// <returns></returns>
        /// </summary>
        public async static Task <ShippingApiResponse <CarrierRule> > RatingServices(RatingServicesRequest request, ISession session = null)
        {
            var response = await WebMethod.Get <ServiceRule[], RatingServicesRequest>("/shippingservices/v1/information/rules/rating-services", request, session);

            var carrierRuleResponse = new ShippingApiResponse <CarrierRule>
            {
                Errors     = response.Errors,
                HttpStatus = response.HttpStatus,
                Success    = response.Success
            };

            if (response.Success)
            {
                carrierRuleResponse.APIResponse = new CarrierRule()
                {
                    Carrier            = request.Carrier,
                    DestinationCountry = request.DestinationCountryCode,
                    OriginCountry      = request.OriginCountryCode,
                    ServiceRules       = new IndexedList <Services, ServiceRule>()
                };
                foreach (var s in response.APIResponse)
                {
                    carrierRuleResponse.APIResponse.ServiceRules.Add(s.ServiceId, s);
                }
            }
            return(carrierRuleResponse);
        }
Esempio n. 2
0
 /// <summary>
 /// This operation returns a list of supported destination countries to which the carrier offers international shipping services.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="request"></param>
 /// <param name="session"></param>
 /// <returns></returns>
 public async static Task <ShippingApiResponse <IEnumerable <T> > > Countries <T>(CountriesRequest <T> request, ISession session = null) where T : Country, new()
 {
     return(await WebMethod.Get <IEnumerable <T>, CountriesRequest <T> >("/shippingservices/v1/countries", request, session));
 }