Skip to content

Commit

Permalink
Merge pull request #9 from apruve/AP-8971
Browse files Browse the repository at this point in the history
AP-8971 - match attribute names to Apruve
  • Loading branch information
donnen committed Oct 4, 2019
2 parents b59fa69 + fc4b24e commit f64138b
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Please use [Github issues](https://github.com/apruve/apruve-php/issues) to reque
Add this require to your `composer.json`:

"require": {
"apruve/apruve-php": "~1.4"
"apruve/apruve-php": "~1.4.1"
}

**NOTE**: Be sure to update the version as you update the version of apruve-php
Expand Down
3 changes: 2 additions & 1 deletion src/Apruve/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ class Invoice extends ApruveObject {
'currency',
'merchant_notes',
'invoice_items',
'tax_cents'
];
var $id;
var $order_id;
var $status;
var $amount_cents;
var $price_total_cents;
var $currency;
var $merchant_notes;
var $api_url;
var $view_url;
var $created_at;
var $updated_at;
var $invoice_items = [];
var $tax_cents;

public function __construct( $invoice = [], $client = null ) {
if ( array_key_exists( 'invoice_items', $invoice ) ) {
Expand Down
1 change: 0 additions & 1 deletion src/Apruve/InvoiceItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class InvoiceItem extends ApruveObject {

protected static $json_fields = [
'title',
'amount_cents',
'price_total_cents',
'quantity',
'price_ea_cents',
Expand Down
3 changes: 2 additions & 1 deletion src/Apruve/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class Order extends ApruveObject {
var $view_url;
var $created_at;
var $updated_at;
var $shopper_id;
var $customer_id;

public function __construct( $order = [], $client = null ) {
if ( array_key_exists( 'order_items', $order ) ) {
Expand Down Expand Up @@ -94,7 +96,6 @@ public static function getInvoices( $apruveOrderId ) {

public static function cancel( $apruveOrderId ) {
$client = new Client();
echo sprintf( __( self::$CANCEL_PATH, $apruveOrderId ) );
$response = $client->post( sprintf( __( self::$CANCEL_PATH ), $apruveOrderId ), '' );

return $response[0] == 200;
Expand Down
4 changes: 2 additions & 2 deletions src/Apruve/OrderItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class OrderItem extends ApruveObject {

protected static $hash_order = [
'title',
'amount_cents',
'price_total_cents',
'price_ea_cents',
'quantity',
'merchant_notes',
Expand All @@ -20,7 +20,7 @@ class OrderItem extends ApruveObject {
];
protected static $json_fields = [
'title',
'amount_cents',
'price_total_cents',
'price_ea_cents',
'quantity',
'merchant_notes',
Expand Down
3 changes: 0 additions & 3 deletions src/Apruve/ShipmentItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class ShipmentItem extends ApruveObject {

protected static $hash_order = [
'title',
'amount_cents',
'price_total_cents',
'quantity',
'price_ea_cents',
Expand All @@ -26,7 +25,6 @@ class ShipmentItem extends ApruveObject {
];
protected static $json_fields = [
'title',
'amount_cents',
'price_total_cents',
'quantity',
'price_ea_cents',
Expand All @@ -43,7 +41,6 @@ class ShipmentItem extends ApruveObject {
'currency',
];
var $title;
var $amount_cents;
var $quantity;
var $price_ea_cents;
var $merchant_notes;
Expand Down
2 changes: 0 additions & 2 deletions tests/Apruve/InvoiceItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function testToJsonString() {
$this->assertJsonStringEqualsJsonString(
'{
"title": "A title",
"amount_cents": 3400,
"price_total_cents": 3400,
"quantity": 1,
"price_ea_cents": 3400,
Expand All @@ -45,7 +44,6 @@ public function testToJsonString() {
protected function setUp() {
$this->item = new InvoiceItem( [
'title' => 'A title',
'amount_cents' => 3400,
'price_total_cents' => 3400,
'quantity' => 1,
'price_ea_cents' => 3400,
Expand Down
13 changes: 6 additions & 7 deletions tests/Apruve/InvoiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ public function testPropertiesAreDefined() {
'order_id',
'status',
'amount_cents',
'price_total_cents',
'currency',
'merchant_notes',
'api_url',
'view_url',
'created_at',
'updated_at',
'invoice_items',
'tax_cents'
] );
$this->assertEquals( 12, count( $vars ) );

Expand All @@ -39,18 +39,18 @@ public function testToJson() {
"invoice_items": [
{
"title": "test",
"amount_cents": 100,
"price_total_cents": 100,
"quantity" : 1,
"price_ea_cents": 100,
"merchant_notes": null,
"description": null,
"variant_info": null,
"sku": null,
"vendor": null,
"view_product_url": null,
"price_total_cents": null
"view_product_url": null
}
]
],
"tax_cents": null
}',
$this->invoice->toJson()
);
Expand Down Expand Up @@ -122,10 +122,9 @@ protected function setUp() {
"invoice_items" => [
[
'title' => 'test',
'amount_cents' => 100,
'price_total_cents' => 100,
'quantity' => 1,
'price_ea_cents' => 100

]
]
] );
Expand Down
4 changes: 2 additions & 2 deletions tests/Apruve/OrderItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testToJsonString() {
$this->assertJsonStringEqualsJsonString(
'{
"title": "A title",
"amount_cents": 3400,
"price_total_cents": 3400,
"price_ea_cents": 3400,
"quantity": 1,
"merchant_notes": "some notes.",
Expand All @@ -54,7 +54,7 @@ protected function setUp() {
$this->item = new OrderItem( [
'title' => 'A title',
'sku' => 'sku',
'amount_cents' => 3400,
'price_total_cents' => 3400,
'price_ea_cents' => 3400,
'quantity' => 1,
'merchant_notes' => 'some notes.',
Expand Down
22 changes: 14 additions & 8 deletions tests/Apruve/OrderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ public function testPropertiesAreDefined() {
'view_url',
'created_at',
'updated_at',
'shopper_id',
'customer_id'
] );
$this->assertEquals( 20, count( $vars ) );
$this->assertEquals( 22, count( $vars ) );

}

Expand All @@ -57,9 +59,9 @@ public function testToJson() {
"payment_term": [],
"order_items": [{
"title": "a title",
"amount_cents": 4500,
"price_ea_cents": null,
"quantity": null,
"price_total_cents": 4500,
"price_ea_cents": 4500,
"quantity": 1,
"merchant_notes": null,
"description": null,
"variant_info": null,
Expand All @@ -83,15 +85,15 @@ public function testToHashString() {

public function testToSecureString() {
$this->assertEquals(
'asdf1234order12346000USD50010002014-07-15T10:12:27-05:00falsea title4500',
'asdf1234order12346000USD50010002014-07-15T10:12:27-05:00falsea title450045001',
$this->po->toSecureString()
);
}

public function testToSecureHash() {
Apruve\Client::init( 'a key', Apruve\Environment::DEV() );
$this->assertEquals(
hash( 'sha256', 'a keyasdf1234order12346000USD50010002014-07-15T10:12:27-05:00falsea title4500' ),
hash( 'sha256', 'a keyasdf1234order12346000USD50010002014-07-15T10:12:27-05:00falsea title450045001' ),
$this->po->toSecureHash()
);
}
Expand Down Expand Up @@ -158,8 +160,10 @@ public function testSave() {
'order_items' => [
[
'title' => 'a title',
'amount_cents' => 4500,
'price_total_cents' => 4500,
'price_ea_cents' => 4500,
'order_id' => 'id',
'quantity' => 1
]
]
],
Expand Down Expand Up @@ -246,8 +250,10 @@ protected function setUp() {
'order_items' => [
[
'title' => 'a title',
'amount_cents' => 4500,
'price_total_cents' => 4500,
'price_ea_cents' => 4500,
'order_id' => 'id',
'quantity' => 1
]
],
] );
Expand Down
5 changes: 1 addition & 4 deletions tests/Apruve/ShipmentItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public function testPropertiesAreDefined() {

$this->assertEquals( array_keys( $item_vars ), array(
'title',
'amount_cents',
'quantity',
'price_ea_cents',
'merchant_notes',
Expand All @@ -25,14 +24,13 @@ public function testPropertiesAreDefined() {
'price_total_cents',
'currency'
) );
$this->assertEquals( 14, count( $item_vars ) );
$this->assertEquals( 13, count( $item_vars ) );
}

public function testToJsonString() {
$this->assertJsonStringEqualsJsonString(
'{
"title": "A title",
"amount_cents": 3400,
"quantity": 1,
"price_ea_cents": 3400,
"merchant_notes": "some notes.",
Expand All @@ -52,7 +50,6 @@ public function testToJsonString() {
protected function setUp() {
$this->shipmentItem = new ShipmentItem( [
'title' => 'A title',
'amount_cents' => 3400,
'quantity' => 1,
'price_ea_cents' => 3400,
'merchant_notes' => 'some notes.',
Expand Down
1 change: 0 additions & 1 deletion tests/Apruve/ShipmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public function testToJsonString() {
"shipment_items": [
{
"title": "a title",
"amount_cents": 4500,
"price_ea_cents": null,
"quantity": null,
"merchant_notes": null,
Expand Down

0 comments on commit f64138b

Please sign in to comment.