-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from apruve/AP-5505
Ap 5505 - adding invoiceItems, shipment, shipmentItems, and changing the watchr
- Loading branch information
Showing
14 changed files
with
450 additions
and
27 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
File renamed without changes.
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
} | ||
], | ||
"require": { | ||
"php": ">=5.3.0" | ||
"php": ">=5.4.0" | ||
}, | ||
"autoload": { | ||
"psr-0": { | ||
|
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
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
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
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,105 @@ | ||
<?php | ||
// Shipment | ||
namespace Apruve; | ||
|
||
require_once 'ApruveObject.php'; | ||
|
||
class Shipment extends ApruveObject { | ||
|
||
protected static $SHIPMENTS_PATH = '/invoices/%s/shipments'; | ||
protected static $hash_order = [ | ||
'id', | ||
'amount_cents', | ||
'invoice_id', | ||
'shipper', | ||
'tracking_number', | ||
'shipped_at', | ||
'delivered_at', | ||
'merchant_notes', | ||
'uuid', | ||
'created_at', | ||
'currency', | ||
'tax_cents', | ||
'shipping_cents', | ||
'merchant_invoice_id', | ||
'shipment_items', | ||
]; | ||
protected static $json_fields = [ | ||
'id', | ||
'amount_cents', | ||
'invoice_id', | ||
'shipper', | ||
'tracking_number', | ||
'shipped_at', | ||
'delivered_at', | ||
'merchant_notes', | ||
'uuid', | ||
'created_at', | ||
'currency', | ||
'tax_cents', | ||
'shipping_cents', | ||
'status', | ||
'merchant_shipment_id', | ||
'shipment_items', | ||
]; | ||
var $id; | ||
var $amount_cents; | ||
var $invoice_id; | ||
var $shipper; | ||
var $tracking_number; | ||
var $shipped_at; | ||
var $delivered_at; | ||
var $merchant_notes; | ||
var $uuid; | ||
var $created_at; | ||
var $currency; | ||
var $tax_cents; | ||
var $shipping_cents; | ||
var $status; | ||
var $merchant_shipment_id; | ||
var $shipment_items = []; | ||
|
||
public function __construct( $shipment = [], $client = null ) { | ||
if ( array_key_exists( 'shipment_items', $shipment ) ) { | ||
foreach ( $shipment['shipment_items'] as $key => $shipment_item ) { | ||
if ( is_array( $shipment_item ) ) { | ||
$shipment['shipment_items'][ $key ] = new ShipmentItem( $shipment_item ); | ||
} | ||
} | ||
} | ||
|
||
parent::__construct( $shipment, $client ); | ||
} | ||
|
||
public static function get( $invoice_id, $client = null ) { | ||
if ( $client == null ) { | ||
$client = new Client(); | ||
} | ||
$response = $client->get( sprintf( self::$SHIPMENTS_PATH, $invoice_id ) ); | ||
|
||
if ( $response[0] == 200 ) { | ||
return new self( $response[1], $client ); | ||
} else { | ||
return $response[2]; | ||
} | ||
} | ||
|
||
public function save() { | ||
$response = $this->client->post( | ||
sprintf( | ||
self::$SHIPMENTS_PATH, $this->invoice_id ), $this->toJson() ); | ||
if ( $response[0] == 201 ) { | ||
return new self( $response[1], $this->client ); | ||
} else { | ||
return $response[2]; | ||
} | ||
} | ||
|
||
public function addShipmentItem( $shipment_item ) { | ||
if ( get_class( $shipment_item ) == 'Apruve\ShipmentItem' ) { | ||
return array_push( $this->shipment_items, $shipment_item ); | ||
} else { | ||
return false; | ||
} | ||
} | ||
} |
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,59 @@ | ||
<?php | ||
// Shipment Item | ||
namespace Apruve; | ||
|
||
require_once 'ApruveObject.php'; | ||
|
||
class ShipmentItem extends ApruveObject { | ||
|
||
protected static $hash_order = [ | ||
'title', | ||
'amount_cents', | ||
'price_total_cents', | ||
'quantity', | ||
'price_ea_cents', | ||
'merchant_notes', | ||
'description', | ||
'variant_info', | ||
'sku', | ||
'vendor', | ||
'sku', | ||
'view_product_url', | ||
'shipping_cents', | ||
'tax_cents', | ||
'price_total_cents', | ||
'currency', | ||
]; | ||
protected static $json_fields = [ | ||
'title', | ||
'amount_cents', | ||
'price_total_cents', | ||
'quantity', | ||
'price_ea_cents', | ||
'merchant_notes', | ||
'description', | ||
'variant_info', | ||
'sku', | ||
'vendor', | ||
'sku', | ||
'view_product_url', | ||
'shipping_cents', | ||
'tax_cents', | ||
'price_total_cents', | ||
'currency', | ||
]; | ||
var $title; | ||
var $amount_cents; | ||
var $quantity; | ||
var $price_ea_cents; | ||
var $merchant_notes; | ||
var $description; | ||
var $variant_info; | ||
var $sku; | ||
var $vendor; | ||
var $view_product_url; | ||
var $shipping_cents; | ||
var $tax_cents; | ||
var $price_total_cents; | ||
var $currency; | ||
} |
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
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
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
Oops, something went wrong.