diff --git a/samples/ship-shipment.php b/samples/ship-shipment.php new file mode 100644 index 0000000..4d77cb2 --- /dev/null +++ b/samples/ship-shipment.php @@ -0,0 +1,18 @@ +setShipmentAsShipped($shipmentId); + +if (!empty($response)) { + echo $response; +} diff --git a/src/OneflowSDK.php b/src/OneflowSDK.php index 8c60052..1d51b38 100644 --- a/src/OneflowSDK.php +++ b/src/OneflowSDK.php @@ -226,12 +226,9 @@ public function ordersUpdateById($id, $orderData){ else return false; } -///////////////////////////////////////////////////////////////// - /** - * request function. + * Performs an HTTP request to the OneFlow API * - * @access private * @param mixed $method * @param mixed $path * @param mixed $jsonData (default: null) @@ -239,7 +236,7 @@ public function ordersUpdateById($id, $orderData){ * @throws Exception * @return mixed */ - protected function request($method, $path, $jsonData=null, $optional_headers = null) { + public function request($method, $path, $jsonData=null, $optional_headers = null) { ini_set("track_errors","on"); $timestamp = time(); @@ -283,14 +280,13 @@ protected function request($method, $path, $jsonData=null, $optional_headers = n } /** - * get function. + * Performs a GET HTTP request * - * @access private * @param mixed $path * @param string $format (default: 'application/json') * @return mixed */ - protected function get($path, $format = 'application/json'){ + public function get($path, $format = 'application/json'){ try { $response = $this->request("GET", $path, "", array( 'Accept' => $format, @@ -305,15 +301,14 @@ protected function get($path, $format = 'application/json'){ } /** - * post function. + * Performs a POST HTTP request * - * @access private * @param mixed $path * @param mixed $jsonData * @param string $format (default: 'application/json') * @return mixed */ - protected function post($path, $jsonData, $format = 'application/json') { + public function post($path, $jsonData, $format = 'application/json') { try { $response = $this->request("POST", $path, $jsonData, array( 'Content-Type' => $format, @@ -328,15 +323,14 @@ protected function post($path, $jsonData, $format = 'application/json') { } /** - * put function. + * Performs a PUT HTTP request * - * @access private * @param mixed $path * @param mixed $jsonData * @param string $format (default: 'application/json') * @return mixed */ - protected function put($path, $jsonData = null, $format = 'application/json'){ + public function put($path, $jsonData = null, $format = 'application/json'){ try { $response = $this->request("PUT", $path, $jsonData, array( 'Content-Type' => $format, @@ -351,14 +345,13 @@ protected function put($path, $jsonData = null, $format = 'application/json'){ } /** - * del function. + * Performs a DELETE HTTP request * - * @access private * @param mixed $path * @param string $format (default: 'application/json') * @return mixed */ - protected function del($path, $format = 'application/json'){ + public function del($path, $format = 'application/json'){ try { $response = $this->request("DELETE", $path, "", array( 'Accept' => $format, @@ -427,4 +420,4 @@ private function token($method, $path, $timestamp){ $stringToSign = strtoupper($method) . ' ' . $path . ' ' . $timestamp; return $this->key . ':' . hash_hmac('sha1', $stringToSign, $this->secret); } -} \ No newline at end of file +} diff --git a/src/ProductionSDK.php b/src/ProductionSDK.php index 9af85b8..cd3da08 100644 --- a/src/ProductionSDK.php +++ b/src/ProductionSDK.php @@ -1,117 +1,265 @@ get("/station"); } + + /** + * Creates a station + * @param $jsonData + * @return mixed + */ public function addStation($jsonData){ return $this->post("/station", $jsonData); } + /** + * Returns a list of SKUs + * @return mixed + */ public function getSKUs(){ return $this->get("/sku"); } + + /** + * Creates a SKU + * @param $jsonData + * @return mixed + */ public function addSKU($jsonData){ return $this->post("/sku", $jsonData); } + /** + * Returns a list of clients + * @return mixed + */ public function getClients(){ return $this->get("/client"); } + + /** + * Creates a client + * @param $jsonData + * @return mixed + */ public function addClient($jsonData){ return $this->post("/client", $jsonData); } + /** + * Returns a list of batches + * @return mixed + */ public function getBatches(){ return $this->get("/batch"); } + /** + * Returns a list of walls + * @return mixed + */ public function getWalls(){ return $this->get("/wall"); } + + /** + * Creates a wall + * @param $jsonData + * @return mixed + */ public function addWall($jsonData){ return $this->post("/wall", $jsonData); } + /** + * Returns a list of stocks + * @return mixed + */ public function getStock(){ return $this->get("/stock"); } + + /** + * Creates a stock + * @param $jsonData + * @return mixed + */ public function addStock($jsonData){ return $this->post("/stock", $jsonData); } + /** + * Returns a list of couriers + * @return mixed + */ public function getCouriers(){ return $this->get("/courier"); } + + /** + * Creates a courier + * @param $jsonData + * @return mixed + */ public function addCourier($jsonData){ return $this->post("/courier", $jsonData); } - public function getPresses(){ - return $this->get("/press"); - } - public function addPress($jsonData){ - return $this->post("/press", $jsonData); - } - + /** + * Returns a list of accounts + * @return mixed + */ public function getAccounts(){ return $this->get("/account"); } + + /** + * Return a list of accounts + * @return mixed + */ public function getAccount(){ return $this->get("/account"); } + /** + * Returns the current account settings + * @return mixed + */ public function getAccountSettings(){ return $this->get("/accountSettings"); } + + /** + * Returns the sub-batches for a given station + * @param $id + * @return mixed + */ public function getStationWorkList($id){ return $this->get("/worklist/id/$id"); } + /** + * Returns a list of products + * @return mixed + */ public function getProducts(){ return $this->get("/product"); } + + /** + * Creates a product + * @param $jsonData + * @return mixed + */ public function addProduct($jsonData){ return $this->post("/product", $jsonData); } + + /** + * Deletes a product + * @param $id + * @return mixed + */ public function removeProduct($id){ return $this->del("/product/$id"); } + /** + * Creates a event type + * @param $jsonData + * @return mixed + */ public function addEventType($jsonData){ return $this->post("/event-type", $jsonData); } + + /** + * Returns a list of event types + * @return mixed + */ public function getEventTypes(){ return $this->get("/event-type"); } + /** + * Returns a list of papers + * @return mixed + */ public function getPaper(){ return $this->get("/paper"); } + + /** + * Creates a paper + * @param $jsonData + * @return mixed + */ public function addPaper($jsonData){ return $this->post("/paper", $jsonData); } + /** + * Returns a list of printers + * @return mixed + */ public function getPrinters(){ return $this->get("/printer"); } + + /** + * Creates a printer + * @param $jsonData + * @return mixed + */ public function addPrinter($jsonData){ return $this->post("/printer", $jsonData); } + /** + * Returns a list of users + * @return mixed + */ public function getUsers(){ return $this->get("/user"); } + + /** + * Creates a user + * @param $jsonData + * @return mixed + */ public function addUser($jsonData){ return $this->post("/register", $jsonData); } + + /** + * Returns a list of files for a given order + * @param $orderId + * @return mixed + */ public function getOrderFiles($orderId){ return $this->get("/files/order/$orderId"); } -} \ No newline at end of file + /** + * Sets a shipment as shipped + * @param $orderId + * @param $jsonData + * @return mixed + */ + public function setShipmentAsShipped($shipmentId, $jsonData = null){ + return $this->put("/shipment/shipped/$shipmentId", $jsonData); + } + +}