# frozen_string_literal: true
# This file was auto-generated by lib/tasks/api.rake
module Usps
module Api
module Endpoints
module HFPFacilityInfo
#
# Hold for Pickup Facility Information API
#
# Hold For
# Pickup service is available at approximately 31,000 USPS locations. This API
# will list US Postal Service Facilities where Hold-For-Pickup service is
# available. The response includes facilities based on ZIP code (five or nine
# digit) or City/State up to a maximum number of locations. Shipments are
# available for pickup by the recipient or a designee at the designated Hold For Pickup location by either 10 a.m., noon, or 3 p.m.,
# based on the service standard associated with the mail class. Hold For Pickup shipments are sent to a designated Hold For
# Pickup location, such as a Post Office, where the shipment can be picked up
# within five calendar days. Hold For Pickup service
# lets customers pick up shipments when it is convenient for them, with the
# assurance that their shipments are held safely and securely.
#
# @option option [(Alias)] :HFPFacilityInfoRequest (Required)
# - API=HFPFacilityInfo
# @option option [String] :PickupCity (Required)
# - Either City/State or ZIP code must be specified. When only city and state are provided, all pickup facilities with addresses within that city and state will be returned. For example: Boston
# @option option [String] :PickupState (Required)
# - Either City/State or ZIP code must be specified. For example: MA
# @option option [String] :PickupZIP (Required)
# - Either City/State or ZIP code must be specified. When PickupZIP provided without PickupZIP4, all pickup facilities that service that ZIP code are returned. For example: 02111
# @option option [String] :PickupZIP4 (Required)
# - If PickupZIP is specified, then PickupZIP4 may also be specified. This will match to a single pickup facility with the given nine-digit ZIP code. For example: 9998
# @option option [String] :Service (Optional)
# - For future use. May be omitted.
#
# @see
def hfp_facility_info(options = {})
throw ArgumentError.new('Required arguments :hfp_facility_info_request missing') if options[:hfp_facility_info_request].nil?
throw ArgumentError.new('Required arguments :hfp_facility_info_request, :pickup_city missing') if options[:hfp_facility_info_request][:pickup_city].nil?
throw ArgumentError.new('Required arguments :hfp_facility_info_request, :pickup_state missing') if options[:hfp_facility_info_request][:pickup_state].nil?
throw ArgumentError.new('Required arguments :hfp_facility_info_request, :pickup_zip missing') if options[:hfp_facility_info_request][:pickup_zip].nil?
throw ArgumentError.new('Required arguments :hfp_facility_info_request, :pickup_zip4 missing') if options[:hfp_facility_info_request][:pickup_zip4].nil?
request = build_request(:hfp_facility_info, options)
get('https://secure.shippingapis.com/ShippingAPI.dll', {
API: 'HFPFacilityInfo',
XML: request,
})
end
private
def tag_unless_blank(xml, tag_name, data)
xml.tag!(tag_name, data) unless data.blank? || data.nil?
end
def build_hfp_facility_info_request(xml, options = {})
xml.tag!('PickupCity', options[:hfp_facility_info_request][:pickup_city])
xml.tag!('PickupState', options[:hfp_facility_info_request][:pickup_state])
xml.tag!('PickupZIP', options[:hfp_facility_info_request][:pickup_zip])
xml.tag!('PickupZIP4', options[:hfp_facility_info_request][:pickup_zip4])
tag_unless_blank(xml, 'Service', options[:hfp_facility_info_request][:service])
xml.target!
end
end
end
end
end