Sha256: eae9583a3bad4d2bdfd89d98b7c25b55b1bc147e6c03ba41ecb7ffb19ee29e85

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

# 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
usps-ruby-client-0.1.0 lib/usps/api/templates/method.erb