Skip to content

[bc break] BusinessModel removal, Serializer addition #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
### Added
- [Api] Add `getHttpStatusCode` to `ApiClientException` and `ApiServerException`. This method returns the response HTTP status code.
- [Serializer] New component focused only in assist the conversion of PHP types to JSON compatible types.

### Changed
- [BusinessModel] Remove constructors
- [BusinessModel] This component has been replaced by [Serializer]
- [Api] Change in `ApiClientException` and `ApiServerException` constructor signature.

### Deprecated

### Removed
- [BusinessModel] This component has been replaced by [Serializer]

### Fixed

Expand Down
108 changes: 54 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This SDK provides a tree of objects for guide you about to craft the checkout mo
/*
* Merchant model
*/
$merchant = new Aplazame\BusinessModel\Merchant();
$merchant = new stdClass();
$merchant->confirmation_url = "/confirm"; // url that the JS client sent to confirming the order.
$merchant->cancel_url = "/cancel"; // url that the customer is sent to if there is an error in the checkout.
$merchant->success_url = "/success"; // url that the customer is sent to after confirming their order.
Expand All @@ -36,17 +36,17 @@ $merchant->checkout_url = "/checkout"; // url that the customer is sent to if
/*
* Article model
*/
$article = new Aplazame\BusinessModel\Article();
$article->id = "89793238462643383279"; // The article ID.
$article->name = "Reloj en oro blanco de 18 quilates y diamantes"; // Article name.
$article->url = "http://shop.example.com/product.html"; // Article url.
$article->image_url = "http://shop.example.com/product_image.png"; // Article image url.
$article->quantity = 2; // Article quantity.
$article->price = Aplazame\BusinessModel\Decimal::fromFloat(4020.00); // Article price (tax is not included). (4,020.00 €)
$article->description = "Movimiento de cuarzo de alta precisión"; // Article description.
$article->tax_rate = Aplazame\BusinessModel\Decimal::fromFloat(21.00); // Article tax rate. (21.00%)
$article->discount = Aplazame\BusinessModel\Decimal::fromFloat(5.00); // The discount amount of the article. (5.00 €)
$article->discount_rate = Aplazame\BusinessModel\Decimal::fromFloat(2.00); // The rate discount of the article. (2.00 %)
$article = new stdClass();
$article->id = "89793238462643383279"; // The article ID.
$article->name = "Reloj en oro blanco de 18 quilates y diamantes"; // Article name.
$article->url = "http://shop.example.com/product.html"; // Article url.
$article->image_url = "http://shop.example.com/product_image.png"; // Article image url.
$article->quantity = 2; // Article quantity.
$article->price = Aplazame\Serializer\Decimal::fromFloat(4020.00); // Article price (tax is not included). (4,020.00 €)
$article->description = "Movimiento de cuarzo de alta precisión"; // Article description.
$article->tax_rate = Aplazame\Serializer\Decimal::fromFloat(21.00); // Article tax rate. (21.00%)
$article->discount = Aplazame\Serializer\Decimal::fromFloat(5.00); // The discount amount of the article. (5.00 €)
$article->discount_rate = Aplazame\Serializer\Decimal::fromFloat(2.00); // The rate discount of the article. (2.00 %)

// ... rest of articles in the shopping cart.

Expand All @@ -59,21 +59,21 @@ $articles = array( $article, ... );
/*
* Order model
*/
$order = new Aplazame\BusinessModel\Order();
$order->id = "28475648233786783165"; // Your order ID.
$order->currency = "EUR"; // Currency code of the order.
$order->tax_rate = Aplazame\BusinessModel\Decimal::fromFloat(21.00); // Order tax rate. (21.00%)
$order->total_amount = Aplazame\BusinessModel\Decimal::fromFloat(4620.00); // Order total amount. (4,620.00 €)
$order->articles = $articles; // Articles in cart.
$order->discount = Aplazame\BusinessModel\Decimal::fromFloat(160.00); // The discount amount of the order. (160.00 €)
$order->discount_rate = Aplazame\BusinessModel\Decimal::fromFloat(2.00); // The rate discount of the order. (2.00 %)
$order->cart_discount = Aplazame\BusinessModel\Decimal::fromFloat(0.50); // The discount amount of the cart. (0.50 €)
$order->cart_discount_rate = Aplazame\BusinessModel\Decimal::fromFloat(3.00); // The rate discount of the cart. (3.00 %)
$order = new stdClass();
$order->id = "28475648233786783165"; // Your order ID.
$order->currency = "EUR"; // Currency code of the order.
$order->tax_rate = Aplazame\Serializer\Decimal::fromFloat(21.00); // Order tax rate. (21.00%)
$order->total_amount = Aplazame\Serializer\Decimal::fromFloat(4620.00); // Order total amount. (4,620.00 €)
$order->articles = $articles; // Articles in cart.
$order->discount = Aplazame\Serializer\Decimal::fromFloat(160.00); // The discount amount of the order. (160.00 €)
$order->discount_rate = Aplazame\Serializer\Decimal::fromFloat(2.00); // The rate discount of the order. (2.00 %)
$order->cart_discount = Aplazame\Serializer\Decimal::fromFloat(0.50); // The discount amount of the cart. (0.50 €)
$order->cart_discount_rate = Aplazame\Serializer\Decimal::fromFloat(3.00); // The rate discount of the cart. (3.00 %)

/*
* Customer address model
*/
$customerAddress = new Aplazame\BusinessModel\Address();
$customerAddress = new stdClass();
$customerAddress->first_name = "John"; // Address first name.
$customerAddress->last_name = "Coltrane"; // Address last name.
$customerAddress->street = "Plaza del Angel nº10"; // Address street.
Expand All @@ -88,24 +88,24 @@ $customerAddress->address_addition = "Cerca de la plaza Santa Ana"; // Address a
/*
* Customer model
*/
$customer = new Aplazame\BusinessModel\Customer();
$customer->id = "1618"; // Customer ID.
$customer->email = "[email protected]"; // The customer email.
$customer->type = Aplazame\BusinessModel\Customer::TYPE_EXISTING; // Customer type. Other options are: TYPE_GUEST and TYPE_NEW.
$customer->gender = Aplazame\BusinessModel\Customer::GENDER_UNKNOWN; // Customer gender. Other options are: GENDER_MALE, GENDER_FEMALE and GENDER_NOT_APPLICABLE.
$customer->first_name = "John"; // Customer first name.
$customer->last_name = "Coltrane"; // Customer last name.
$customer->birthday = DateTime::createFromFormat(DateTime::ISO8601, "1990-08-21T13:56:45+0000"); // Customer birthday.
$customer->language = "es"; // Customer language preferences.
$customer->date_joined = DateTime::createFromFormat(DateTime::ISO8601, "2014-08-21T13:56:45+0000"); // A datetime designating when the customer account was created.
$customer->last_login = DateTime::createFromFormat(DateTime::ISO8601, "2014-08-27T19:57:56+0000"); // A datetime of the customer last login.
$customer->address = $customerAddress; // Customer address.
$customer = new stdClass();
$customer->id = "1618"; // Customer ID.
$customer->email = "[email protected]"; // The customer email.
$customer->type = 'e'; // Customer type, the choices are g:guest, n:new, e:existing.
$customer->gender = 0; // Customer gender, the choices are 0: not known, 1: male, 2:female, 3: not applicable.
$customer->first_name = "John"; // Customer first name.
$customer->last_name = "Coltrane"; // Customer last name.
$customer->birthday = Aplazame\Serializer\Date::fromDateTime(new DateTime("1990-08-21 13:56:45")); // Customer birthday.
$customer->language = "es"; // Customer language preferences.
$customer->date_joined = Aplazame\Serializer\Date::fromDateTime(new DateTime("2014-08-21 13:56:45")); // A datetime designating when the customer account was created.
$customer->last_login = Aplazame\Serializer\Date::fromDateTime(new DateTime("2014-08-27 19:57:56")); // A datetime of the customer last login.
$customer->address = $customerAddress; // Customer address.


/*
* Billing address model
*/
$billingAddress = new Aplazame\BusinessModel\Address();
$billingAddress = new stdClass();
$billingAddress->first_name = "Bill"; // Billing first name.
$billingAddress->last_name = "Evans"; // Billing last name.
$billingAddress->street = "Calle de Las Huertas 22"; // Billing street.
Expand All @@ -121,28 +121,28 @@ $billingAddress->address_addition = "Cerca de la pizzería"; // Billing address
/*
* Shipping info model
*/
$shippingInfo = new Aplazame\BusinessModel\Address();
$shippingInfo->first_name = "Django"; // Shipping first name.
$shippingInfo->last_name = "Reinhard"; // Shipping last name.
$shippingInfo->street = "Plaza del Angel nº10"; // Shipping street.
$shippingInfo->city = "Madrid"; // Shipping city.
$shippingInfo->state = "Madrid"; // Shipping state.
$shippingInfo->country = "ES"; // Shipping country code.
$shippingInfo->postcode = "28012"; // Shipping postcode.
$shippingInfo->name = "Planet Express"; // Shipping name.
$shippingInfo->price = Aplazame\BusinessModel\Decimal::fromFloat(5.00); // Shipping price (tax is not included). (5.00 €)
$shippingInfo->phone = "616123456"; // Shipping phone number.
$shippingInfo->alt_phone = "+34917909930"; // Shipping alternative phone.
$shippingInfo->address_addition = "Cerca de la plaza Santa Ana"; // Shipping address addition.
$shippingInfo->tax_rate = Aplazame\BusinessModel\Decimal::fromFloat(21.00); // Shipping tax rate. (21.00%)
$shippingInfo->discount = Aplazame\BusinessModel\Decimal::fromFloat(1.00); // The discount amount of the shipping. (1.00 €)
$shippingInfo->discount_rate = Aplazame\BusinessModel\Decimal::fromFloat(2.00); // The rate discount of the shipping. (2.00 %)
$shippingInfo = new stdClass();
$shippingInfo->first_name = "Django"; // Shipping first name.
$shippingInfo->last_name = "Reinhard"; // Shipping last name.
$shippingInfo->street = "Plaza del Angel nº10"; // Shipping street.
$shippingInfo->city = "Madrid"; // Shipping city.
$shippingInfo->state = "Madrid"; // Shipping state.
$shippingInfo->country = "ES"; // Shipping country code.
$shippingInfo->postcode = "28012"; // Shipping postcode.
$shippingInfo->name = "Planet Express"; // Shipping name.
$shippingInfo->price = Aplazame\Serializer\Decimal::fromFloat(5.00); // Shipping price (tax is not included). (5.00 €)
$shippingInfo->phone = "616123456"; // Shipping phone number.
$shippingInfo->alt_phone = "+34917909930"; // Shipping alternative phone.
$shippingInfo->address_addition = "Cerca de la plaza Santa Ana"; // Shipping address addition.
$shippingInfo->tax_rate = Aplazame\Serializer\Decimal::fromFloat(21.00); // Shipping tax rate. (21.00%)
$shippingInfo->discount = Aplazame\Serializer\Decimal::fromFloat(1.00); // The discount amount of the shipping. (1.00 €)
$shippingInfo->discount_rate = Aplazame\Serializer\Decimal::fromFloat(2.00); // The rate discount of the shipping. (2.00 %)


/*
* Checkout model
*/
$checkout = new Aplazame\BusinessModel\Checkout();
$checkout = new stdClass();
$checkout->toc = true;
$checkout->merchant = $merchant;
$checkout->order = $order;
Expand All @@ -154,7 +154,7 @@ $checkout->shipping = $shippingInfo;
In your view you will need to put an snippet similar to this one.
```html
<script>
aplazame.checkout( <?php echo json_encode($checkout->jsonSerialize()); ?> );
aplazame.checkout( <?php echo json_encode(Aplazame\Serializer\JsonSerializer::serializeValue($checkout)); ?> );
</script>
```

Expand Down
64 changes: 0 additions & 64 deletions src/BusinessModel/AbstractModel.php

This file was deleted.

76 changes: 0 additions & 76 deletions src/BusinessModel/Address.php

This file was deleted.

Loading