Skip to content

Commit

Permalink
Merge pull request #22 from Peardian/betterdoc
Browse files Browse the repository at this point in the history
better documentation
  • Loading branch information
carl689 committed Mar 28, 2014
2 parents 7889654 + ba846e6 commit 4bd2247
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 9 deletions.
40 changes: 34 additions & 6 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,50 @@
To install, simply add the library to your project. Composer is the default installation tool for this library.
If you do not use Composer for your project, you can still auto-load classes by including the file **includes/classes.php** in the page or function.

Before you use any commands, you need to create a **amazon-config.php** file with your account credentials. Start by copying the template provided (*amazon-config.default.php*) and renaming the file.
Before you use any commands, you need to create an **amazon-config.php** file with your account credentials. Start by copying the template provided (*amazon-config.default.php*) and renaming the file.

Only the first section of the config file needs to be filled out. If you are operating outside of the United States, be sure to change the Amazon Service URL as well. Everything after that point is pertaining to Amazon's API. Be sure to keep these values up to date, as Amazon could change them in a new API version release.
If you are operating outside of the United States, be sure to change the Amazon Service URL to the one matching your region.

You can also link the built-in logging system to your own logging system by putting the function name in the *$logfunction* parameter.
You can also link the built-in logging system to your own system by putting the logging function's name in the *$logfunction* parameter.

In the event that PHP does not have the correct permissions to create a file in the library's main directory, you will have to create the log file as "log.txt" and give all users permission to edit it.
The default location for the built-in log file is in the library's main directory. In the event that PHP does not have the correct permissions to create a file in there, you will have to create the log file as "log.txt" and give PHP permission to edit it.

## Example Usage
## Usage
All of the technical details required by the API are handled behind the scenes,
so users can easily build code for sending requests to Amazon
without having to jump hurdles such as parameter URL formatting and token management.
The general work flow for using one of the objects is this:

1. Create an object for the task you need to perform.
2. Load it up with parameters, depending on the object, using *set____* methods.
3. Submit the request to Amazon. The methods to do this are usually named *fetch____* or *submit____* and have no parameters.
4. Reference the returned data, whether as single values or in bulk, using *get____* methods.
5. Monitor the performance of the library using built-in logging system.
5. Monitor the performance of the library using the built-in logging system.

Note that if you want to act on more than one Amazon store, you will need a separate object for each store.

Also note that the objects perform best when they are not treated as reusable. Otherwise, you may end up grabbing old response data if a new request fails.

## Examples
Here is an example of a function used to get all warehouse-fulfilled orders from Amazon updated in the past 24 hours:
```php
function getAmazonOrders() {
$amz = new AmazonOrderList("myStore");
$amz->setLimits('Modified', "- 24 hours");
$amz->setFulfillmentChannelFilter("MFN"); //no Amazon-fulfilled orders
$amz->setOrderStatusFilter(array("Unshipped", "Canceled", "Unfulfillable")); //no shipped or pending
$amz->setUseToken(); //Amazon sends orders 100 at a time, but we want them all
$amz->fetchOrders();
return $amz->getList();
}
```
This example shows a function used to send a previously-created XML feed to Amazon to update Inventory numbers:
```php
function sendInventoryFeed($feed) {
$amz=new AmazonFeed("myStore");
$amz->setFeedType("_POST_INVENTORY_AVAILABILITY_DATA_"); //feed types listed in documentation
$amz->setFeedContent($feed);
$amz->submitFeed();
return $amz->getResponse();
}
```
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
phpAmazonMWS
============

A library to connect to Amazon's MWS web services in an object-oriented manner, with a focus on intuitive usage.
A library to connect to Amazon's MWS web services in an object-oriented manner, with a focus on intuitive usage.


## Example Usage
Here are a couple of examples of the library in use.
All of the technical details required by the API are handled behind the scenes,
so users can easily build code for sending requests to Amazon
without having to jump hurdles such as parameter URL formatting and token management.

Here is an example of a function used to get all warehouse-fulfilled orders from Amazon updated in the past 24 hours:
```php
function getAmazonOrders() {
$amz = new AmazonOrderList("myStore");
$amz->setLimits('Modified', "- 24 hours");
$amz->setFulfillmentChannelFilter("MFN"); //no Amazon-fulfilled orders
$amz->setOrderStatusFilter(array("Unshipped", "Canceled", "Unfulfillable")); //no shipped or pending
$amz->setUseToken(); //Amazon sends orders 100 at a time, but we want them all
$amz->fetchOrders();
return $amz->getList();
}
```
This example shows a function used to send a previously-created XML feed to Amazon to update Inventory numbers:
```php
function sendInventoryFeed($feed) {
$amz=new AmazonFeed("myStore");
$amz->setFeedType("_POST_INVENTORY_AVAILABILITY_DATA_"); //feed types listed in documentation
$amz->setFeedContent($feed);
$amz->submitFeed();
return $amz->getResponse();
}
```
4 changes: 2 additions & 2 deletions includes/classes/AmazonOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ public function getEarliestShipDate(){
/**
* Returns the timestamp of the latest shipping date.
*
* Note that this is usually set to midnight of the day after the last date,
* Note that this could be set to midnight of the day after the last date,
* so the timestamp "2013-09-025T00:00:00Z" indicates the last day is the 24th and not the 25th.
* This method will return <b>FALSE</b> if the timestamp has not been set yet.
* @return string|boolean timestamp, or <b>FALSE</b> if timestamp not set yet
Expand Down Expand Up @@ -638,7 +638,7 @@ public function getEarliestDeliveryDate(){
/**
* Returns the timestamp of the estimated latest delivery date.
*
* Note that this is usually set to midnight of the day after the last date,
* Note that this could be set to midnight of the day after the last date,
* so the timestamp "2013-09-025T00:00:00Z" indicates the last day is the 24th and not the 25th.
* This method will return <b>FALSE</b> if the timestamp has not been set yet.
* @return string|boolean timestamp, or <b>FALSE</b> if timestamp not set yet
Expand Down

0 comments on commit 4bd2247

Please sign in to comment.