{"id":17925409,"url":"https://github.com/scottbedard/shipping","last_synced_at":"2025-04-03T09:40:32.110Z","repository":{"id":25560269,"uuid":"28993472","full_name":"scottbedard/shipping","owner":"scottbedard","description":"A simple PHP wrapper for USPS shipping calulations.","archived":false,"fork":false,"pushed_at":"2015-01-09T09:28:09.000Z","size":156,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T14:13:09.869Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/bedard/shipping","language":"PHP","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/scottbedard.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}},"created_at":"2015-01-09T00:40:42.000Z","updated_at":"2019-04-09T12:36:20.000Z","dependencies_parsed_at":"2022-08-24T11:52:43.329Z","dependency_job_id":null,"html_url":"https://github.com/scottbedard/shipping","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottbedard%2Fshipping","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottbedard%2Fshipping/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottbedard%2Fshipping/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottbedard%2Fshipping/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scottbedard","download_url":"https://codeload.github.com/scottbedard/shipping/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246981154,"owners_count":20863825,"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-10-28T20:55:58.967Z","updated_at":"2025-04-03T09:40:32.089Z","avatar_url":"https://github.com/scottbedard.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# USPS Shipping Calculator\n[![Build Status](https://travis-ci.org/scottbedard/shipping.svg?branch=master)](https://travis-ci.org/scottbedard/shipping)\n[![Coverage Status](https://coveralls.io/repos/scottbedard/shipping/badge.png?branch=master)](https://coveralls.io/r/scottbedard/shipping?branch=master)\n\nA simple PHP wrapper for USPS shipping calulations.\n\n### Instructions\nThe first step to requesting a shipping quote is injecting your USPS Web Tools ID.\n\n```php\nuse Bedard\\Shipping\\Usps;\n$shipment = new Usps('123ABCDE4567');\n```\n\nIf you would like to run the calculator on the USPS testing server, call ```useTestingServer()```.\n\n```php\n$shipment-\u003euseTestingServer();\n```\n\nOnce this is done, it's time to build up the data you'll be sending to USPS. Length, width, and height are all specified in inches. Pounds, ounces, and setValue() are all optional.\n\n```php\n$rates = $shipment\n    -\u003esetOrigin('12345')\n    -\u003esetDestination('90210')\n    -\u003esetDimensions([\n        'length'    =\u003e 12,\n        'width'     =\u003e 12,\n        'height'    =\u003e 4,\n        'pounds'    =\u003e 0,\n        'ounces'    =\u003e 1\n    ])\n    -\u003esetValue(49.99)\n    -\u003ecalculate();\n```\n\nThe above is an example of a domestic shipment. To request an international rate, simply pass the destination country into ```setDestination()``` instead of a postal code.\n\n```php\n$shipment-\u003esetDestination('Canada');\n```\n\nOnce you've called ```calculate()```, shipping rates will be returned in the following format. Results will be ordered by cost in ascending order.\n\n```\n 1 =\u003e \n    array (size=3)\n      'code' =\u003e string '01' (length=2)\n      'name' =\u003e string 'First-Class Mail Large Envelope' (length=31)\n      'cost' =\u003e float 0.98\n  2 =\u003e \n    array (size=3)\n      'code' =\u003e string '00' (length=2)\n      'name' =\u003e string 'First-Class Mail Parcel' (length=23)\n      'cost' =\u003e float 2.32\n  3 =\u003e \n    array (size=3)\n      'code' =\u003e string '1' (length=1)\n      'name' =\u003e string 'Priority Mail 2-Day' (length=19)\n      'cost' =\u003e float 5.75\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscottbedard%2Fshipping","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscottbedard%2Fshipping","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscottbedard%2Fshipping/lists"}