# frozen_string_literal: true # This file was auto-generated by lib/tasks/api.rake module Usps module Api module Endpoints module <%= data[:group].camelize %> # # <%= data[:title] %> # <% data[:description].to_s.split("\r").each do |line| %> # <%= line.strip %> <% end %> # <% data[:request_descriptions].each do |option_name, option| %> <%= Erubis::Eruby.new(File.read('lib/usps/api/templates/_options.erb')).result(option: option, parents: [], indentation: 0, static_indentation: 3) %><% end %> # # @see <%= data[:link] %> def <%= data[:group].underscore %>(options = {}) <% data[:request_descriptions].select{|n,o| o[:required]}.each do |option_name, option| %> <%= Erubis::Eruby.new(File.read('lib/usps/api/templates/_throw_argument_error.erb')).result(option: option, parents: [], indentation: 3) %> <% end %> request = build_request(:<%= data[:group].underscore %>, options) get('<%= data[:url] %>', { API: '<%= data[:group] %>', 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_<%= data[:group].underscore %>_request(xml, options = {}) <% data[:request_descriptions].each do |option_name, option| %> <% option[:children].each do |child_option_name, child_option| %> <%= Erubis::Eruby.new(File.read('lib/usps/api/templates/_build_xml.erb')).result(option: child_option, parents: [option[:name].underscore], indentation: 4) %> <% end %> <% end %> xml.target! end end end end end