Sha256: 0542468917b931e1f378b82654b267c89f08d468ee8c553b6847749e98527b2a

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 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[:description].to_s.split("\r").each do |line| %>
				# <%= line.strip %>
				<% end %>
				# @param [Hash] options
				# @option options [required, Hash] <%= data[:request_descriptions].first[1][:name].underscore %> <%= data[:request_descriptions].first[1][:description] %>
				<% 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/_options.erb')).result(option: child_option, parents: [], indentation: 0, static_indentation: 3) %><% end %><% end %>				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.2.0 lib/usps/api/templates/method.erb