-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 80311df
Showing
11 changed files
with
1,757 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# phpstorm project files | ||
.idea | ||
|
||
# windows thumbnail cache | ||
Thumbs.db | ||
|
||
# composer vendor dir | ||
/vendor | ||
|
||
# composer itself is not needed | ||
composer.phar | ||
composer.lock | ||
|
||
# Mac DS_Store Files | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Stamps.com API Client | ||
|
||
Stamps API Client for creating shipping labels, envelopes, checking addresses, etc. | ||
|
||
### Usage | ||
|
||
```php | ||
$to = []; // Sender's address | ||
$from = []; // Address of the recipient | ||
|
||
$toAddress = (new \integready\Stamps\Address\Address()) | ||
->setFullname($to['fullname']) | ||
->setAddress1($to['address1']) | ||
->setAddress2($to['address2']) | ||
->setCity($to['city']) | ||
->setState($to['state']) | ||
->setZipcode($to['zipCode']) | ||
->setCountry($to['country']); | ||
|
||
$fromAddress = (new \integready\Stamps\Address\Address()) | ||
->setFullname($from['fullname']) | ||
->setAddress1($from['address1']) | ||
->setAddress2($from['address2']) | ||
->setCity($from['city']) | ||
->setState($from['state']) | ||
->setZipcode($from['zipCode']) | ||
->setCountry($from['country']); | ||
|
||
try { | ||
$shippingLabel = (new \integready\Stamps\Api\Envelope()) | ||
->setApiUrl(API_URL) // Leave out for default | ||
->setApiIntegrationId(YOUR_API_INTEGRATION_ID) | ||
->setApiUserId(YOUR_API_USER_ID) | ||
->setApiPassword(YOUR_API_PASSWORD) | ||
->setImageType(\IntegReady\Stamps\Api\Envelope::IMAGE_TYPE_PNG) | ||
->setPackageType(\IntegReady\Stamps\Api\Envelope::RATE_PACKAGE_TYPE_LETTER) | ||
->setServiceType(\IntegReady\Stamps\Api\Envelope::RATE_SERVICE_TYPE_US_FC) | ||
->setPrintLayout(\IntegReady\Stamps\Api\Envelope::RATE_PRINT_LAYOUT_ENVELOPE10) | ||
->setMode(\IntegReady\Stamps\Api\Envelope::MODE_NOPOSTAGE) | ||
->setFrom($fromAddress) | ||
->setTo($toAddress) | ||
->setIsSampleOnly(false) | ||
->setShowPrice(true) | ||
->setWeightOz(100) | ||
->setShipDate(date('Y-m-d')); | ||
|
||
$labelUrl = $shippingLabel->create(); | ||
} catch(Exception $e) { | ||
// Handle exception | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "integready/stamps-api-client", | ||
"description": "Stamps.com API Client for creating shipping labels.", | ||
"type": "library", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Viktor Chistyakov", | ||
"email": "vityachis@gmail.com" | ||
}, | ||
{ | ||
"name": "Yevhen Tretiak", | ||
"email": "minister87@gmail.com" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.1", | ||
"ext-curl": "*", | ||
"ext-soap": "*" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"integready\\stamps\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"integready\\stamps\\": "tests/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
<?php | ||
|
||
namespace integready\stamps\address; | ||
|
||
/** | ||
* Class to represent a mailing address for a shipping label. | ||
*/ | ||
class Address implements AddressInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $fullname; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $address1; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $address2; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $city; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $state; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $zipcode; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $country = 'US'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setFullname($fullname) | ||
{ | ||
$this->fullname = (string) $fullname; | ||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFullname() | ||
{ | ||
return $this->fullname; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setAddress1($address1) | ||
{ | ||
$this->address1 = (string) $address1; | ||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getAddress1() | ||
{ | ||
return $this->address1; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setAddress2($address2) | ||
{ | ||
$this->address2 = (string) $address2; | ||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getAddress2() | ||
{ | ||
return $this->address2; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setCity($city) | ||
{ | ||
$this->city = (string) $city; | ||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getCity() | ||
{ | ||
return $this->city; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setState($state) | ||
{ | ||
$this->state = (string) $state; | ||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getState() | ||
{ | ||
return $this->state; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setZipcode($zipcode) | ||
{ | ||
$this->zipcode = (string) $zipcode; | ||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getZipcode() | ||
{ | ||
return $this->zipcode; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setCountry($country = 'US') | ||
{ | ||
$this->country = (string) $country; | ||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getCountry() | ||
{ | ||
return $this->country; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
namespace integready\Stamps\Address; | ||
|
||
/** | ||
* Interface for creating a mailing address. | ||
*/ | ||
interface AddressInterface | ||
{ | ||
/** | ||
* @param string $fullname | ||
* @return $this | ||
*/ | ||
public function setFullname($fullname); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getFullname(); | ||
|
||
/** | ||
* @param string $address1 | ||
* @return $this | ||
*/ | ||
public function setAddress1($address1); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getAddress1(); | ||
|
||
/** | ||
* @param string $address2 | ||
* @return $this | ||
*/ | ||
public function setAddress2($address2); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getAddress2(); | ||
|
||
/** | ||
* @param string $city | ||
* @return $this | ||
*/ | ||
public function setCity($city); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCity(); | ||
|
||
/** | ||
* @param string $state | ||
* @return $this | ||
*/ | ||
public function setState($state); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getState(); | ||
|
||
/** | ||
* @param string $zipcode | ||
* @return $this | ||
*/ | ||
public function setZipcode($zipcode); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getZipcode(); | ||
|
||
/** | ||
* @param string $country | ||
* @return $this | ||
*/ | ||
public function setCountry($country = 'US'); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCountry(); | ||
} |
Oops, something went wrong.