# frozen_string_literal: true # This file was auto-generated by lib/tasks/api.rake module Usps module Api module Endpoints module PTSRre # Overview # @param [Hash] options # @option options [required, Hash] pts_rre_request # * *:track_id* (required, String) # * *:client_ip* (String) # * *:source_id* (String) # * *:mp_suffix* (required, integer) # * *:mp_date* (required, String) # * *:first_name* (required, String) # * *:last_name* (required, String) # * *:email1* (required, String) # * *:email2* (String) # * *:email3* (String) # * *:table_code* (required, String) # * *:cust_reg_id* (String) def pts_rre(options = {}) throw ArgumentError.new('Required arguments :pts_rre_request missing') if options[:pts_rre_request].nil? throw ArgumentError.new('Required arguments :pts_rre_request, :track_id missing') if options[:pts_rre_request][:track_id].nil? throw ArgumentError.new('Required arguments :pts_rre_request, :mp_suffix missing') if options[:pts_rre_request][:mp_suffix].nil? throw ArgumentError.new('Required arguments :pts_rre_request, :mp_date missing') if options[:pts_rre_request][:mp_date].nil? throw ArgumentError.new('Required arguments :pts_rre_request, :first_name missing') if options[:pts_rre_request][:first_name].nil? throw ArgumentError.new('Required arguments :pts_rre_request, :last_name missing') if options[:pts_rre_request][:last_name].nil? throw ArgumentError.new('Required arguments :pts_rre_request, :email1 missing') if options[:pts_rre_request][:email1].nil? throw ArgumentError.new('Required arguments :pts_rre_request, :table_code missing') if options[:pts_rre_request][:table_code].nil? request = build_request(:pts_rre, options) get('https://secure.shippingapis.com/ShippingAPI.dll', { API: 'PTSRre', 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_pts_rre_request(xml, options = {}) xml.tag!('TrackId', options[:pts_rre_request][:track_id]) tag_unless_blank(xml, 'ClientIp', options[:pts_rre_request][:client_ip]) tag_unless_blank(xml, 'SourceId', options[:pts_rre_request][:source_id]) xml.tag!('MpSuffix', options[:pts_rre_request][:mp_suffix]) xml.tag!('MpDate', options[:pts_rre_request][:mp_date]) xml.tag!('FirstName', options[:pts_rre_request][:first_name]) xml.tag!('LastName', options[:pts_rre_request][:last_name]) xml.tag!('Email1', options[:pts_rre_request][:email1]) tag_unless_blank(xml, 'Email2', options[:pts_rre_request][:email2]) tag_unless_blank(xml, 'Email3', options[:pts_rre_request][:email3]) xml.tag!('TableCode', options[:pts_rre_request][:table_code]) tag_unless_blank(xml, 'CustRegID', options[:pts_rre_request][:cust_reg_id]) xml.target! end end end end end