Vote count:
0
Im using this Gem for Fedex Web services and being really new to Ruby/Rails i need help figure out how to start using this gem within my application.
This is what i got so far...
test.html.erb
<h4>Shipper</h4>
<div class="col-xs-2">
<input type="text" class="form-control" placeholder="Address">
<input type="text" class="form-control" placeholder="City">
<input type="text" class="form-control" placeholder="State">
<input type="text" class="form-control" placeholder="Postal Code">
</div>
<h4>Recipient</h4>
<div class="col-xs-2">
<input type="text" class="form-control" placeholder="Address">
<input type="text" class="form-control" placeholder="City">
<input type="text" class="form-control" placeholder="State">
<input type="text" class="form-control" placeholder="Postal Code">
</div>
<%= button_to "Generate Rate" %
<h4>Total Cost</h4>
<%= "Output Here" %>
Now with the inputs to collect the shipper and receipt address, i need to know run query to the api through the following script.
require 'fedex'
def fedex
test_creds = {...mycreds...}
fedex_test = Fedex::Shipment.new(test_creds)
recipient = {:name => "Recipient",
:company => "Company",
:phone_number => "555-555-5555",
:address => "1211 Burke Street",
:city => "Cambridge",
:state => "CA",
:postal_code => "02141",
:country_code => "MA",
:residential => "false" }
shipper = { :name => "Bob Jones",
:company => "Test Company",
:phone_number => "777-777-7777",
:address => "8799 W. Music Ln",
:city => "Netherland",
:state => "AD",
:postal_code => "89045",
:country_code => "US" }
packages = []
packages << {
:weight => {:units => "LB", :value => 6},
:dimensions => {:length => 26, :width => 9, :height => 2, :units => "IN" }
}
shipping_options = {
:packaging_type => "YOUR_PACKAGING",
:drop_off_type => "REGULAR_PICKUP"
}
rates = fedex_test.rate({:shipper=>shipper, :recipient => recipient, :packages => packages, :service_type => "FEDEX_GROUND", :shipping_options => shipping_options})
rates.to_s
IS to figure out how to easily link the html inputs "forms" with the actual hash's for both recipient and shipper.
Any help, links to help, suggestions, code examples are very helpful. Thanks in advance
asked 43 secs ago
Aucun commentaire:
Enregistrer un commentaire