{"id":13463432,"url":"https://github.com/jazminschroeder/fedex","last_synced_at":"2025-03-25T06:31:59.215Z","repository":{"id":663480,"uuid":"2477348","full_name":"jazminschroeder/fedex","owner":"jazminschroeder","description":"Ruby library to interact with FedEx Rate Web Service","archived":false,"fork":false,"pushed_at":"2024-07-10T04:49:53.000Z","size":279,"stargazers_count":105,"open_issues_count":25,"forks_count":179,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-02T21:48:24.655Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jazminschroeder.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-09-28T19:31:13.000Z","updated_at":"2024-06-03T00:20:30.000Z","dependencies_parsed_at":"2024-06-18T17:01:24.111Z","dependency_job_id":"8180966e-6d1d-4804-9400-df914d109d85","html_url":"https://github.com/jazminschroeder/fedex","commit_stats":{"total_commits":198,"total_committers":40,"mean_commits":4.95,"dds":0.696969696969697,"last_synced_commit":"8fd1fa56ca58101bfb5c17c8be1c77ea203ec891"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jazminschroeder%2Ffedex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jazminschroeder%2Ffedex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jazminschroeder%2Ffedex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jazminschroeder%2Ffedex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jazminschroeder","download_url":"https://codeload.github.com/jazminschroeder/fedex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245414347,"owners_count":20611357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T13:00:53.369Z","updated_at":"2025-03-25T06:31:58.877Z","avatar_url":"https://github.com/jazminschroeder.png","language":"Ruby","readme":"# IMPORTANT!!\nI plan a major refactor to this gem. Sorry but at this moment I am not merging PR's. I appreciate your effort but need some time to catch up. Thanks!! \n\n# Fedex Rate Web Service\n## Fedex API Shipment Version: 13\n\nFor more information visit [Fedex Web Services for Shipping](https://www.fedex.com/wpor/web/jsp/drclinks.jsp?links=wss/index.html).\n\nThis version uses the Non-SOAP Web Services so there is no need to download the\nFedex WSDL files, note however that you will need to apply for development/production credentials.\n\nNote: Please make sure to test your results.\n\n\n# Installation:\n\n```ruby\ngem install fedex\n```\n\n# Usage example:\n\nDefine the shipper:\n\n```ruby\n\nshipper = { :name =\u003e \"Sender\",\n            :company =\u003e \"Company\",\n            :phone_number =\u003e \"555-555-5555\",\n            :address =\u003e \"Main Street\",\n            :city =\u003e \"Harrison\",\n            :state =\u003e \"AR\",\n            :postal_code =\u003e \"72601\",\n            :country_code =\u003e \"US\" }\n```\n\nDefine the recipient:\n\n```ruby\nrecipient = { :name =\u003e \"Recipient\",\n              :company =\u003e \"Company\",\n              :phone_number =\u003e \"555-555-5555\",\n              :address =\u003e \"Main Street\",\n              :city =\u003e \"Franklin Park\",\n              :state =\u003e \"IL\",\n              :postal_code =\u003e \"60131\",\n              :country_code =\u003e \"US\",\n              :residential =\u003e \"false\" }\n```\n\nDefine the packages; multiple packages in a single shipment are allowed:\nNote that all the dimensions must be integers.\n\n```ruby\npackages = []\npackages \u003c\u003c {\n  :weight =\u003e {:units =\u003e \"LB\", :value =\u003e 2},\n  :dimensions =\u003e {:length =\u003e 10, :width =\u003e 5, :height =\u003e 4, :units =\u003e \"IN\" }\n}\npackages \u003c\u003c {\n  :weight =\u003e {:units =\u003e \"LB\", :value =\u003e 6},\n  :dimensions =\u003e {:length =\u003e 5, :width =\u003e 5, :height =\u003e 4, :units =\u003e \"IN\" }\n}\n```\n\nBy default packaging type is \"YOUR PACKAGING\" and the drop off type is \"REGULAR PICKUP\".\nIf you need something different you can pass an extra hash for shipping options.\n\n```ruby\nshipping_options = {\n  :packaging_type =\u003e \"YOUR_PACKAGING\",\n  :drop_off_type =\u003e \"REGULAR_PICKUP\"\n}\n```\n\nIf you pass a non-nil `:return_reason` as part of the shipping options, you will create\na return shipment. The request to fedex will include the following additional XML.\n\n```xml\n\u003cSpecialServicesRequested\u003e\n  \u003cSpecialServiceTypes\u003eRETURN_SHIPMENT\u003c/SpecialServiceTypes\u003e\n  \u003cReturnShipmentDetail\u003e\n    \u003cReturnType\u003ePRINT_RETURN_LABEL\u003c/ReturnType\u003e\n    \u003cRma\u003e\n      \u003cReason\u003eYOUR RETURN REASON HERE\u003c/Reason\u003e\n    \u003c/Rma\u003e\n  \u003c/ReturnShipmentDetail\u003e\n\u003c/SpecialServicesRequested\u003e\n```\n\nBy default the shipping charges will be assigned to the sender. If you may\nchange this by passing an extra hash of payment options.\n\n```ruby\npayment_options = {\n  :type =\u003e \"THIRD_PARTY\",\n  :account_number =\u003e \"123456789\",\n  :name =\u003e \"Third Party Payor\",\n  :company =\u003e \"Company\",\n  :phone_number =\u003e \"555-555-5555\",\n  :country_code =\u003e \"US\"\n}\n```\n\nCreate a `Fedex::Shipment` object using your FedEx credentials; mode should be\neither production or development depending on what Fedex environment you want to use.\n\n```ruby\nrequire 'fedex'\nfedex = Fedex::Shipment.new(:key =\u003e 'xxx',\n                            :password =\u003e 'xxxx',\n                            :account_number =\u003e 'xxxx',\n                            :meter =\u003e 'xxx',\n                            :mode =\u003e 'production')\n```\n\n### ** Getting Shipping Rates **\n\nTo find a shipping rate:\n\n```ruby\nrate = fedex.rate(:shipper=\u003eshipper,\n                  :recipient =\u003e recipient,\n                  :packages =\u003e packages,\n                  :service_type =\u003e \"FEDEX_GROUND\",\n                  :shipping_options =\u003e shipping_options)\n```\n\nFedex provides multiple total values; `total_net_charge` is the final amount you are looking for.\n\n```ruby\n    $ rate.total_net_charge =\u003e \"34.03\"\n    # Complete response\n    $ \u003cFedex::Rate:0x1019ba5f8\n          @total_net_charge=\"34.03\",\n          @total_surcharges=\"1.93\",\n          @total_billing_weight=\"8.0 LB\",\n          @total_taxes=\"0.0\",\n          @rate_type=\"PAYOR_ACCOUNT_PACKAGE\",\n          @total_base_charge=\"32.1\",\n          @total_freight_discounts=nil,\n          @total_net_freight=\"32.1\",\n          @rate_zone=\"51\"\u003e\n```\n### ** Create a shipment and Get a Transit time(please note this will generate a shipment in your Fedex account if you are using production mode) **\n```ruby\nship = fedex.ship(:shipper=\u003eshipper,\n                  :recipient =\u003e recipient,\n                  :packages =\u003e packages,\n                  :service_type =\u003e \"FEDEX_GROUND\",\n                  :shipping_options =\u003e shipping_options)\nputs ship[:completed_shipment_detail][:operational_detail][:transit_time]\n```\nAbove code will give you the transit time.\n\n### ** Generate a shipping label (PDF) **\n\nTo create a label for a shipment:\n\n```ruby\nlabel = fedex.label(:filename =\u003e \"my_dir/example.pdf\",\n                    :shipper=\u003eshipper,\n                    :recipient =\u003e recipient,\n                    :packages =\u003e packages,\n                    :service_type =\u003e \"FEDEX_GROUND\",\n                    :shipping_options =\u003e shipping_options)\n```\n\n### ** Generate a shipping label in any available format **\n\nChange the filename extension and pass a label_specification hash. For example:\n\n```ruby\nexample_spec = {\n  :image_type =\u003e \"EPL2\",\n  :label_stock_type =\u003e \"STOCK_4X6\"\n}\n\nlabel = fedex.label(:filename =\u003e \"my_dir/example_epl2.pcx\",\n                    :shipper=\u003eshipper,\n                    :recipient =\u003e recipient,\n                    :packages =\u003e packages,\n                    :service_type =\u003e \"FEDEX_GROUND\",\n                    :shipping_options =\u003e shipping_options,\n                    :label_specification =\u003e example_spec)\n```\n### ** Storing a label on Amazon S3 with Paperclip **\n\nThis is useful when you need to store the labels for later use, and are hosting your application on [Heroku](http://www.heroku.com/) as they do not allow writing to the filesystem, save the `tmp` directory. With [Paperclip](https://github.com/thoughtbot/paperclip/) setup up on a shipment model:\n\n```ruby\nlabel = fedex.label(:filename =\u003e \"tmp/example_label.pdf\",\n                    :shipper=\u003eshipper,\n                    :recipient =\u003e recipient,\n                    :packages =\u003e packages,\n                    :service_type =\u003e \"FEDEX_GROUND\",\n                    :shipping_options =\u003e shipping_options,\n                    :label_specification =\u003e example_spec)\n```\n\nThen attach the label to your Paperclip model:\n\n```ruby\nshipment.fedex_label = label.file_name\nshipment.save!\n```\n\nDocumentation for setting up Paperclip with Amazon S3 can be found in the Paperclip [README](https://github.com/thoughtbot/paperclip/#storage).\n\n### ** Generate shipping labels for multi-package shipments (MPS) **\n\nMultiple packages for a single pick-up, destination and payer can be combined into a single MPS shipment. The first label will provide a master tracking number which must be used in the subsequent calls for the remaining packages in the shipment.\n\nParameters for the first label:\n```ruby\nlabel = fedex.label(\n  :filename =\u003e file_name,\n  :shipper =\u003e shipper,\n  :recipient =\u003e recipient,\n  :packages =\u003e packages,\n  :service_type =\u003e service_type,\n  :shipping_details =\u003e shipping_details,\n  :shipping_charges_payment =\u003e shipping_charges_payment,\n  :customs_clearance_detail =\u003e customs_clearance_detail,\n  :mps =\u003e {:package_count =\u003e package_count, :total_weight =\u003e total_weight, :sequence_number =\u003e '1'}\n  )\n```\n\nParameters for labels 2 through 'n':\n```ruby\nfedex.label(\n  :filename =\u003e file_name,\n  :shipper =\u003e shipper,\n  :recipient =\u003e recipient,\n  :packages =\u003e packages,\n  :service_type =\u003e service_type,\n  :shipping_details =\u003e shipping_details,\n  :shipping_charges_payment =\u003e shipping_charges_payment,\n  :customs_clearance_detail =\u003e customs_clearance_detail,\n  :mps =\u003e {\n      :master_tracking_id =\u003e {:tracking_id_type =\u003e 'FEDEX', :tracking_number =\u003etracking_number},\n      :package_count =\u003e package_count,\n      :total_weight =\u003e {\n          :value =\u003e total_weight,\n          :units =\u003e 'KG'\n      }\n      :sequence_number =\u003e 'n'\n      }\n   )\n```\n\n### ** Create COD Shipment **\n\nTo create a Cash On Delivery label for a shipment:\n\nchange \"commerical_invoice = {:purpose =\u003e 'SOLD'}\" in customs_clearance_detail\n\nadd shipping_options with {:cod =\u003e {:currency =\u003e \"currency\", :amount =\u003e \"amount\", :collection_type =\u003e 'PAYMENT COLLECTION TYPE'}\n\nPAYMENT COLLECTION TYPE - CASH, CHEQUE, DEMAND DRAFT\n\n### ** To add multiple commodities in customs_clearance_detail\n\nuse this format commodities_1 .... commodities_N\n\nexample \n\n```\n\ncustoms_clearance_detail['commodites_1'] \ncustoms_clearance_detail['commodites_2']\n\n```\n\n### ** Masking shipper details in label **\n\nthis allows you hide shipper details on the label\n\nAdd customer_specified_detail = {:masked_data_1 =\u003e 'SOMETHING', :masked_data_2 =\u003e 'SOMETHING'} in :label_specification key\n\nExample\n\n```\n  customer_specified_detail = {\n      :masked_data_1 =\u003e \"SHIPPER_ACCOUNT_NUMBER\",\n      :masked_data_2 =\u003e \"TRANSPORTATION_CHARGES_PAYOR_ACCOUNT_NUMBER\",\n      :masked_data_3 =\u003e \"DUTIES_AND_TAXES_PAYOR_ACCOUNT_NUMBER\"\n  }\n\n```\n\n### ** Delete a shipment **\n\nIf you do not intend to use a label you should delete it. This will notify FedEx that you will not be using the label and they won't charge you. \n\nTo delete a shipment:\n\n```ruby\nfedex.delete(:tracking_number =\u003e \"1234567890123\")\n```\n\n### ** Tracking a shipment **\n\nTo track a shipment:\n\n```ruby\nresults = fedex.track(:tracking_number =\u003e \"1234567890123\")\n# =\u003e [#\u003cFedex::TrackingInformation\u003e]\n\n# Pull the first result from the returned array\n#\ntracking_info = results.first\n\ntracking_info.tracking_number\n# =\u003e \"1234567890123\"\n\ntracking_info.status\n# =\u003e \"Delivered\"\n\ntracking_info.events.first.description\n# =\u003e \"On FedEx vehicle for delivery\"\n```\n\n### ** Verifying an address **\n\nTo verify an address is valid and deliverable:\n\n```ruby\n\naddress = {\n  :street     =\u003e \"5 Elm Street\",\n  :city        =\u003e \"Norwalk\",\n  :state       =\u003e \"CT\",\n  :postal_code =\u003e \"06850\",\n  :country     =\u003e \"USA\"\n}\n\naddress_result = fedex.validate_address(:address =\u003e address)\n\naddress_result.residential\n# =\u003e true\n\naddress_result.score\n# =\u003e 100\n\naddress_result.postal_code\n# =\u003e \"06850-3901\"\n```\n\n### ** Requesting a Pickup **\n\nTo request a pickup:\n\n```ruby\n\npickup = fedex.pickup(:carrier_code =\u003e 'FDXE',\n                      :packages =\u003e {:weight =\u003e {:units =\u003e \"LB\", :value =\u003e 10}, :count =\u003e 2},\n                      :ready_timestamp =\u003e Date.today.to_datetime + 1.375,\n                      :close_time =\u003e Date.today.to_time + 60 * 60 * 17,\n                      :country_relationship =\u003e \"DOMESTIC\")\nputs pickup[:pickup_confirmation_number]\n```\n\n### ** Getting pickup availability details **\n\nTo check for pickup availability:\n\n```ruby\n\ndispatch = Date.tomorrow.strftime('%Y-%m-%d')\n\npickup_availability = fedex.pickup_availability(:country_code =\u003e 'IN',\n                                   :postal_code =\u003e '400061',\n                                   :request_type =\u003e 'FUTURE_DAY',\n                                   :dispatch_date =\u003e dispatch_date,\n                                   :carrier_code =\u003e 'FDXE')\n\nputs pickup_availability[:options]\n```\n\n### ** Getting service availability **\n\nTo check service availability:\n\n```ruby\n\norigin = {:postal_code =\u003e '400012', :country_code =\u003e 'IN'}\ndestination = { :postal_code =\u003e '400020', :country_code =\u003e 'IN'}\nfedex_service_hash = {:origin =\u003e origin, :destination =\u003e destination, :ship_date =\u003e '2014-06-28', :carrier_code =\u003e 'FDXE'}\n\nservice = fedex.service_availability(fedex_service_hash)\n\nputs service[:options]\n```\n\n# Services/Options Available\n\n```ruby\nFedex::Request::Base::SERVICE_TYPES\nFedex::Request::Base::PACKAGING_TYPES\nFedex::Request::Base::DROP_OFF_TYPES\nFedex::Request::Base::CARRIER_CODES\n````\n\n# Contributors:\n- [jazminschroeder] (http://github.com/jazminschroeder) (Jazmin Schroeder)\n- [parndt] (https://github.com/parndt) (Philip Arndt)\n- [mmell] (https://github.com/mmell) (Michael Mell)\n- [jordanbyron] (https://github.com/jordanbyron) (Jordan Byron)\n- [geermc4] (https://github.com/geermc4) (German Garcia)\n- [janders223] (https://github.com/janders223) (Jim Anders)\n- [jlambert121] (https://github.com/jlambert121) (Justin Lambert)\n- [sborsje] (https://github.com/sborsje) (Stefan Borsje)\n- [bradediger] (https://github.com/bradediger) (Brad Ediger)\n- [yevgenko] (https://github.com/yevgenko) (Yevgeniy Viktorov)\n- [smartacus] (https://github.com/smartacus) (Michael Lippold)\n- [jonathandean] (https://github.com/jonathandean) (Jonathan Dean)\n- [chirag7jain] (https://github.com/chirag7jain) (Chirag Jain)\n- and more... (https://github.com/jazminschroeder/fedex/graphs/contributors)\n\n# Copyright/License:\nCopyright 2011 [Jazmin Schroeder](http://jazminschroeder.com)\n\nThis gem is made available under the MIT license.\n","funding_links":[],"categories":["Web Apps, Services \u0026 Interaction"],"sub_categories":["API Clients"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjazminschroeder%2Ffedex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjazminschroeder%2Ffedex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjazminschroeder%2Ffedex/lists"}