lib/shippinglogic/fedex/request.rb in binarylogic-shippinglogic-0.9.0 vs lib/shippinglogic/fedex/request.rb in binarylogic-shippinglogic-1.0.0
- old
+ new
@@ -3,11 +3,11 @@
# Methods relating to building and sending a request to FedEx's web services.
module Request
private
# Convenience method for sending requests to FedEx
def request(body)
- self.class.post(base.options[:test] ? base.options[:test_url] : base.options[:production_url], :body => body)
+ real_class.post(base.options[:test] ? base.options[:test_url] : base.options[:production_url], :body => body)
end
# Convenience method to create a builder object so that our builder options are consistent across
# the various services.
#
@@ -38,9 +38,51 @@
b.Version do
b.ServiceId service
b.Major major
b.Intermediate intermediate
b.Minor minor
+ end
+ end
+
+ # A convenience method for building the contact block in your XML request
+ def build_contact(b, type)
+ b.Contact do
+ b.Contact send("#{type}_name") if send("#{type}_name")
+ b.CompanyName send("#{type}_company_name") if send("#{type}_company_name")
+ b.PhoneNumber send("#{type}_phone_number") if send("#{type}_phone_number")
+ end
+ end
+
+ # A convenience method for building the address block in your XML request
+ def build_address(b, type)
+ b.Address do
+ b.StreetLines send("#{type}_streets") if send("#{type}_streets")
+ b.City send("#{type}_city") if send("#{type}_city")
+ b.StateOrProvinceCode send("#{type}_state") if send("#{type}_state")
+ b.PostalCode send("#{type}_postal_code") if send("#{type}_postal_code")
+ b.CountryCode send("#{type}_country") if send("#{type}_country")
+ b.Residential send("#{type}_residential")
+ end
+ end
+
+ # A convenience method for building the package block in your XML request
+ def build_package(b)
+ b.PackageCount package_count
+
+ b.RequestedPackages do
+ b.SequenceNumber 1
+
+ b.Weight do
+ b.Units package_weight_units
+ b.Value package_weight
+ end
+
+ b.Dimensions do
+ b.Length package_length
+ b.Width package_width
+ b.Height package_height
+ b.Units package_dimension_units
+ end
end
end
end
end
end
\ No newline at end of file