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