Class: WalmartApIs::ShippingApi
- Defined in:
- lib/walmart_ap_is/apis/shipping_api.rb
Overview
ShippingApi
Constant Summary
Constants inherited from BaseApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#cancel_shipment(shipment_id) ⇒ ApiResponse
Cancels a shipment that has not yet shipped.
-
#get_access_points(access_point_types, country_code, postal_code) ⇒ ApiResponse
Returns access points (pickup and dropoff locations) near the supplied postal code and country, optionally filtered by access point type.
-
#get_additional_inputs(rate_id, request_token) ⇒ ApiResponse
Returns a JSON Schema document describing any carrier-and-service-specific inputs required to purchase a shipment for the supplied requestToken + rateId.
-
#get_rates(body) ⇒ ApiResponse
Returns a list of shipping rate quotes for the given shipment request.
-
#get_shipment_documents(shipment_id, package_client_reference_id: nil, format: nil) ⇒ ApiResponse
Returns the label, customs, and other printable documents associated with a previously-purchased shipment.
-
#get_tracking(tracking_id, carrier_id) ⇒ ApiResponse
Returns the current tracking status, event history, and any proof-of-delivery details for the given trackingId/carrierId pair.
-
#one_click_shipment(body) ⇒ ApiResponse
Convenience endpoint that combines rate quote and purchase into a single round trip when the seller already knows the desired service level.
-
#purchase_shipment(body) ⇒ ApiResponse
Purchases the shipping label for the rate selected from a prior getRates response.
-
#submit_ndr_feedback(body) ⇒ ApiResponse
Submits seller feedback on a non-delivery event for a shipment, instructing the carrier on how to proceed (return, reattempt, redirect, etc).
Methods inherited from BaseApi
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from WalmartApIs::BaseApi
Instance Method Details
#cancel_shipment(shipment_id) ⇒ ApiResponse
Cancels a shipment that has not yet shipped. Cancellation eligibility is carrier-dependent; refer to the response cancellation status to confirm. to cancel.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/walmart_ap_is/apis/shipping_api.rb', line 220 def cancel_shipment(shipment_id) @api_call .request(new_request_builder(HttpMethodEnum::PUT, '/shipping/v4/shipments/{shipmentId}/cancel', Server::DEFAULT1) .template_param(new_parameter(shipment_id, key: 'shipmentId') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('walletAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(CancelShipmentResponse1.method(:from_hash)) .is_api_response(true) .local_error('400', 'Bad Request', ErrorListErrorException) .local_error('403', 'Forbidden', ErrorListErrorException) .local_error('404', 'Not Found', ErrorListErrorException) .local_error('429', 'Rate limit exceeded', ErrorListErrorException) .local_error('500', 'Internal Server Error', ErrorListErrorException)) .execute end |
#get_access_points(access_point_types, country_code, postal_code) ⇒ ApiResponse
Returns access points (pickup and dropoff locations) near the supplied postal code and country, optionally filtered by access point type. list of access point types to include. country code (e.g. US, CA, MX). around.
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/walmart_ap_is/apis/shipping_api.rb', line 262 def get_access_points(access_point_types, country_code, postal_code) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/shipping/v4/accessPoints', Server::DEFAULT1) .query_param(new_parameter(access_point_types, key: 'accessPointTypes') .is_required(true)) .query_param(new_parameter(country_code, key: 'countryCode') .is_required(true)) .query_param(new_parameter(postal_code, key: 'postalCode') .is_required(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('walletAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetAccessPointsResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Bad Request', ErrorListErrorException) .local_error('403', 'Forbidden', ErrorListErrorException) .local_error('404', 'Not Found', ErrorListErrorException) .local_error('429', 'Rate limit exceeded', ErrorListErrorException) .local_error('500', 'Internal Server Error', ErrorListErrorException)) .execute end |
#get_additional_inputs(rate_id, request_token) ⇒ ApiResponse
Returns a JSON Schema document describing any carrier-and-service-specific inputs required to purchase a shipment for the supplied requestToken + rateId. The schema is served verbatim and the calling client should validate the seller's input against it before issuing purchaseShipment. getRates response. a prior getRates response.
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'lib/walmart_ap_is/apis/shipping_api.rb', line 346 def get_additional_inputs(rate_id, request_token) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/shipping/v4/shipments/additionalInputs/schema', Server::DEFAULT1) .query_param(new_parameter(rate_id, key: 'rateId') .is_required(true)) .query_param(new_parameter(request_token, key: 'requestToken') .is_required(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('walletAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetAdditionalInputsResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Bad Request', ErrorListErrorException) .local_error('403', 'Forbidden', ErrorListErrorException) .local_error('404', 'Not Found', ErrorListErrorException) .local_error('429', 'Rate limit exceeded', ErrorListErrorException) .local_error('500', 'Internal Server Error', ErrorListErrorException)) .execute end |
#get_rates(body) ⇒ ApiResponse
Returns a list of shipping rate quotes for the given shipment request. The seller can then call purchaseShipment with the selected rateId to commit to a label purchase. here
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/walmart_ap_is/apis/shipping_api.rb', line 15 def get_rates(body) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/shipping/v4/shipments/rates', Server::DEFAULT1) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body) .is_required(true)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('walletAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetFulfillmentOrderResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Bad Request', ErrorListErrorException) .local_error('403', 'Forbidden', ErrorListErrorException) .local_error('404', 'Not Found', ErrorListErrorException) .local_error('429', 'Rate limit exceeded', ErrorListErrorException) .local_error('500', 'Internal Server Error', ErrorListErrorException)) .execute end |
#get_shipment_documents(shipment_id, package_client_reference_id: nil, format: nil) ⇒ ApiResponse
Returns the label, customs, and other printable documents associated with a previously-purchased shipment. whose documents to retrieve. package-level reference id to retrieve documents for a specific package within a multi-package shipment. (defaults to PDF).
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/walmart_ap_is/apis/shipping_api.rb', line 178 def get_shipment_documents(shipment_id, package_client_reference_id: nil, format: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/shipping/v4/shipments/{shipmentId}/documents', Server::DEFAULT1) .template_param(new_parameter(shipment_id, key: 'shipmentId') .is_required(true) .should_encode(true)) .query_param(new_parameter(package_client_reference_id, key: 'packageClientReferenceId')) .query_param(new_parameter(format, key: 'format')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('walletAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetShipmentDocumentsResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Bad Request', ErrorListErrorException) .local_error('403', 'Forbidden', ErrorListErrorException) .local_error('404', 'Not Found', ErrorListErrorException) .local_error('429', 'Rate limit exceeded', ErrorListErrorException) .local_error('500', 'Internal Server Error', ErrorListErrorException)) .execute end |
#get_tracking(tracking_id, carrier_id) ⇒ ApiResponse
Returns the current tracking status, event history, and any proof-of-delivery details for the given trackingId/carrierId pair. returned by purchaseShipment. tracking is being requested.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/walmart_ap_is/apis/shipping_api.rb', line 134 def get_tracking(tracking_id, carrier_id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/shipping/v4/tracking', Server::DEFAULT1) .query_param(new_parameter(tracking_id, key: 'trackingId') .is_required(true)) .query_param(new_parameter(carrier_id, key: 'carrierId') .is_required(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('walletAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetTrackingResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Bad Request', ErrorListErrorException) .local_error('403', 'Forbidden', ErrorListErrorException) .local_error('404', 'Not Found', ErrorListErrorException) .local_error('429', 'Rate limit exceeded', ErrorListErrorException) .local_error('500', 'Internal Server Error', ErrorListErrorException)) .execute end |
#one_click_shipment(body) ⇒ ApiResponse
Convenience endpoint that combines rate quote and purchase into a single round trip when the seller already knows the desired service level. Returns the purchased shipment record directly. description here
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/walmart_ap_is/apis/shipping_api.rb', line 93 def one_click_shipment(body) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/shipping/v4/oneClickShipment', Server::DEFAULT1) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body) .is_required(true)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('walletAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetFulfillmentOrderShipmentsResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Bad Request', ErrorListErrorException) .local_error('403', 'Forbidden', ErrorListErrorException) .local_error('404', 'Not Found', ErrorListErrorException) .local_error('429', 'Rate limit exceeded', ErrorListErrorException) .local_error('500', 'Internal Server Error', ErrorListErrorException)) .execute end |
#purchase_shipment(body) ⇒ ApiResponse
Purchases the shipping label for the rate selected from a prior getRates response. Returns the shipment record with label document references. description here
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/walmart_ap_is/apis/shipping_api.rb', line 54 def purchase_shipment(body) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/shipping/v4/shipments', Server::DEFAULT1) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body) .is_required(true)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('walletAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetFulfillmentOrderShipmentsResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Bad Request', ErrorListErrorException) .local_error('403', 'Forbidden', ErrorListErrorException) .local_error('404', 'Not Found', ErrorListErrorException) .local_error('429', 'Rate limit exceeded', ErrorListErrorException) .local_error('500', 'Internal Server Error', ErrorListErrorException)) .execute end |
#submit_ndr_feedback(body) ⇒ ApiResponse
Submits seller feedback on a non-delivery event for a shipment, instructing the carrier on how to proceed (return, reattempt, redirect, etc). description here
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/walmart_ap_is/apis/shipping_api.rb', line 305 def submit_ndr_feedback(body) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/shipping/v4/ndrFeedback', Server::DEFAULT1) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body) .is_required(true)) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('walletAuth'))) .response(new_response_handler .is_response_void(true) .is_api_response(true) .local_error('400', 'Bad Request', ErrorListErrorException) .local_error('403', 'Forbidden', ErrorListErrorException) .local_error('404', 'Not Found', ErrorListErrorException) .local_error('429', 'Rate limit exceeded', ErrorListErrorException) .local_error('500', 'Internal Server Error', ErrorListErrorException)) .execute end |