Sha256: 8efc7a480fbf98fd3a7c5cab19d6a118b8a13b91d8810be305907bcfc182e668

Contents?: true

Size: 1.78 KB

Versions: 3

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

3 entries across 3 versions & 1 rubygems

Version Path
usps-ruby-client-0.1.3 lib/usps/api/templates/method.erb
usps-ruby-client-0.1.2 lib/usps/api/templates/method.erb
usps-ruby-client-0.1.1 lib/usps/api/templates/method.erb