[API] Rework serialization

This commit is contained in:
Łukasz 2017-02-14 16:47:42 +01:00
parent d2fa07e021
commit 80537a524f
19 changed files with 84 additions and 187 deletions

View file

@ -9,33 +9,36 @@ Sylius\Component\Addressing\Model\Address:
firstName:
expose: true
type: string
groups: [Default, Detailed]
lastName:
expose: true
type: string
groups: [Default, Detailed]
street:
expose: true
type: string
groups: [Default, Detailed]
city:
expose: true
type: string
groups: [Default, Detailed]
postcode:
expose: true
type: string
groups: [Default, Detailed]
phoneNumber:
expose: true
type: string
createdAt:
expose: true
type: DateTime
updatedAt:
expose: true
type: DateTime
groups: [Default, Detailed]
countryCode:
expose: true
type: string
groups: [Default, Detailed]
provinceCode:
expose: true
type: string
groups: [Default, Detailed]
provinceName:
expose: true
type: string
groups: [Default, Detailed]

View file

@ -9,6 +9,7 @@ sylius_api_checkout_show:
_controller: sylius.controller.order:showAction
_sylius:
serialization_version: $version
serialization_groups: [Detailed]
sylius_api_checkout_addressing:
path: /addressing/{orderId}
@ -30,8 +31,6 @@ sylius_api_checkout_available_shipping_methods:
methods: [GET]
defaults:
_controller: sylius.controller.show_available_shipping_methods:showAction
_sylius:
serialization_version: $version
sylius_api_checkout_select_shipping:
path: /select-shipping/{orderId}
@ -53,8 +52,6 @@ sylius_api_checkout_available_payment_methods:
methods: [GET]
defaults:
_controller: sylius.controller.show_available_payment_methods:showAction
_sylius:
serialization_version: $version
sylius_api_checkout_select_payment:
path: /select-payment/{orderId}

View file

@ -0,0 +1,13 @@
Sylius\Component\Core\Model\ChannelPricing:
exclusion_policy: ALL
xml_root_name: channel
properties:
channel:
expose: true
groups: [Default, Detailed]
price:
expose: true
groups: [Default, Detailed]
productVariant:
expose: true
groups: [Default, Detailed]

View file

@ -1,9 +1,6 @@
Sylius\Component\Core\Model\Payment:
exclusion_policy: ALL
xml_root_name: payment
properties:
order:
expose: false
relations:
- rel: order
exclusion:

View file

@ -6,23 +6,22 @@ Sylius\Component\Payment\Model\Payment:
expose: true
type: integer
xml_attribute: true
groups: [Default, Detailed]
amount:
expose: true
type: integer
groups: [Default, Detailed]
currency:
expose: true
type: string
groups: [Default, Detailed]
state:
expose: true
type: string
groups: [Default, Detailed]
method:
expose: true
createdAt:
expose: true
type: DateTime
updatedAt:
expose: true
type: DateTime
groups: [Default, Detailed]
relations:
- rel: self
exclusion:

View file

@ -6,18 +6,15 @@ Sylius\Component\Payment\Model\PaymentMethod:
expose: true
type: integer
xml_attribute: true
groups: [Default, Detailed]
code:
expose: true
type: string
groups: [Default, Detailed]
name:
expose: true
type: string
createdAt:
expose: true
type: DateTime
updatedAt:
expose: true
type: DateTime
groups: [Default, Detailed]
relations:
- rel: self
href:

View file

@ -5,9 +5,11 @@ Sylius\Component\Product\Model\ProductOptionValue:
code:
expose: true
type: string
groups: [Default, Detailed]
value:
expose: true
type: string
groups: [Detailed]
virtual_properties:
getName:
serialized_name: name

View file

@ -6,19 +6,17 @@ Sylius\Component\Shipping\Model\Shipment:
expose: true
type: integer
xml_attribute: true
groups: [Default, Detailed]
state:
expose: true
type: string
groups: [Default, Detailed]
method:
expose: true
groups: [Default, Detailed]
tracking:
expose: true
createdAt:
expose: true
type: DateTime
updatedAt:
expose: true
type: DateTime
groups: [Default, Detailed]
relations:
- rel: self
exclusion:

View file

@ -9,28 +9,15 @@ Sylius\Component\Shipping\Model\ShippingMethod:
name:
expose: true
type: string
groups: [Default, Detailed]
enabled:
expose: true
type: boolean
categoryRequirement:
expose: true
type: integer
calculator:
expose: true
type: string
configuration:
expose: true
type: array
xml_key_value_pairs: true
createdAt:
expose: true
type: DateTime
updatedAt:
expose: true
type: DateTime
groups: [Default, Detailed]
code:
expose: true
type: string
groups: [Default, Detailed]
relations:
- rel: self
href:

View file

@ -89,6 +89,38 @@ final class CheckoutCompleteApiTest extends CheckoutApiTestCase
$this->assertResponse($response, 'checkout/completed_order_response');
}
/**
* @test
*/
public function it_allows_to_add_a_note_to_order_when_completing()
{
$this->loadFixturesFromFile('authentication/api_administrator.yml');
$this->loadFixturesFromFile('resources/checkout.yml');
$cartId = $this->createCart();
$this->addItemToCart($cartId);
$this->addressOrder($cartId);
$this->selectOrderShippingMethod($cartId);
$this->selectOrderPaymentMethod($cartId);
$data =
<<<EOT
{
"notes": "Please, call me before delivery"
}
EOT;
$this->client->request('PUT', $this->getCheckoutCompleteUrl($cartId), [], [], static::$authorizedHeaderWithContentType, $data);
$response = $this->client->getResponse();
$this->assertResponseCode($response, Response::HTTP_NO_CONTENT);
$this->client->request('GET', $this->getCheckoutSummaryUrl($cartId), [], [], static::$authorizedHeaderWithAccept);
$response = $this->client->getResponse();
$this->assertResponse($response, 'checkout/completed_order_response');
}
/**
* @param mixed $cartId
*

View file

@ -38,26 +38,20 @@
}
},
"shipping_address": {
"id": @integer@,
"first_name": "Hieronim",
"last_name": "Bosch",
"country_code": "NL",
"street": "Surrealism St.",
"city": "s-Hertogenbosch",
"postcode": "99-999",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()"
"postcode": "99-999"
},
"billing_address": {
"id": @integer@,
"first_name": "Vincent",
"last_name": "van Gogh",
"country_code": "NL",
"street": "Post-Impressionism St.",
"city": "Groot Zundert",
"postcode": "88-888",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()"
"postcode": "88-888"
},
"payments": @array@,
"shipments": @array@,

View file

@ -38,7 +38,6 @@
"tracked": false,
"channel_pricings": [
{
"id": @integer@,
"channel": {
"id": @integer@,
"code": "CHANNEL",
@ -127,8 +126,6 @@
"method": {
"id": @integer@,
"code": "cod",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"channels": [
{
"id": @integer@,
@ -156,8 +153,6 @@
},
"amount": 30,
"state": "cart",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"_links": {
"self": {
"href": "@string@"
@ -178,15 +173,6 @@
"method": {
"id": @integer@,
"code": "UPS",
"category_requirement": 1,
"calculator": "flat_rate",
"configuration": {
"CHANNEL": {
"amount": 10
}
},
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"enabled": true,
"_links": {
"self": {
@ -197,8 +183,6 @@
}
}
},
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"_links": {
"self": {
"href": "@string@"

View file

@ -40,7 +40,6 @@
"tracked": false,
"channel_pricings": [
{
"id": @integer@,
"channel": {
"id": @integer@,
"code": "CHANNEL",
@ -130,9 +129,7 @@
"country_code": "NL",
"street": "Surrealism St.",
"city": "\u2019s-Hertogenbosch",
"postcode": "99-999",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()"
"postcode": "99-999"
},
"billing_address": {
"id": @integer@,
@ -141,9 +138,7 @@
"country_code": "NL",
"street": "Post-Impressionism St.",
"city": "Groot Zundert",
"postcode": "88-888",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()"
"postcode": "88-888"
},
"payments": [
{
@ -151,8 +146,6 @@
"method": {
"id": @integer@,
"code": "cod",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"channels": [
{
"id": @integer@,
@ -180,8 +173,6 @@
},
"amount": 30,
"state": "cancelled",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"_links": {
"self": {
"href": "@string@"
@ -202,15 +193,6 @@
"method": {
"id": @integer@,
"code": "UPS",
"category_requirement": 1,
"calculator": "flat_rate",
"configuration": {
"CHANNEL": {
"amount": 10
}
},
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"enabled": true,
"_links": {
"self": {
@ -221,8 +203,6 @@
}
}
},
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"_links": {
"self": {
"href": "@string@"

View file

@ -40,7 +40,6 @@
"tracked": false,
"channel_pricings": [
{
"id": @integer@,
"channel": {
"id": @integer@,
"code": "CHANNEL",
@ -130,9 +129,7 @@
"country_code": "NL",
"street": "Surrealism St.",
"city": "\u2019s-Hertogenbosch",
"postcode": "99-999",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()"
"postcode": "99-999"
},
"billing_address": {
"id": @integer@,
@ -141,9 +138,7 @@
"country_code": "NL",
"street": "Post-Impressionism St.",
"city": "Groot Zundert",
"postcode": "88-888",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()"
"postcode": "88-888"
},
"payments": [
{
@ -151,8 +146,6 @@
"method": {
"id": @integer@,
"code": "cod",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"channels": [
{
"id": @integer@,
@ -180,8 +173,6 @@
},
"amount": 30,
"state": "completed",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"_links": {
"self": {
"href": "@string@"
@ -202,15 +193,6 @@
"method": {
"id": @integer@,
"code": "UPS",
"category_requirement": 1,
"calculator": "flat_rate",
"configuration": {
"CHANNEL": {
"amount": 10
}
},
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"enabled": true,
"_links": {
"self": {
@ -221,8 +203,6 @@
}
}
},
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"_links": {
"self": {
"href": "@string@"

View file

@ -3,8 +3,6 @@
"method": {
"id": @integer@,
"code": "cod",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"channels": [
{
"id": @integer@,
@ -32,8 +30,6 @@
},
"amount": 30,
"state": "completed",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"_links": {
"self": {
"href": "@string@"

View file

@ -40,7 +40,6 @@
"tracked": false,
"channel_pricings": [
{
"id": @integer@,
"channel": {
"id": @integer@,
"code": "CHANNEL",
@ -130,9 +129,7 @@
"country_code": "NL",
"street": "Surrealism St.",
"city": "\u2019s-Hertogenbosch",
"postcode": "99-999",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()"
"postcode": "99-999"
},
"billing_address": {
"id": @integer@,
@ -141,9 +138,7 @@
"country_code": "NL",
"street": "Post-Impressionism St.",
"city": "Groot Zundert",
"postcode": "88-888",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()"
"postcode": "88-888"
},
"payments": [
{
@ -151,8 +146,6 @@
"method": {
"id": @integer@,
"code": "cod",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"channels": [
{
"id": @integer@,
@ -180,8 +173,6 @@
},
"amount": 30,
"state": "new",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"_links": {
"self": {
"href": "@string@"
@ -202,15 +193,6 @@
"method": {
"id": @integer@,
"code": "UPS",
"category_requirement": 1,
"calculator": "flat_rate",
"configuration": {
"CHANNEL": {
"amount": 10
}
},
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"enabled": true,
"_links": {
"self": {
@ -221,8 +203,6 @@
}
}
},
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"_links": {
"self": {
"href": "@string@"

View file

@ -40,7 +40,6 @@
"tracked": false,
"channel_pricings": [
{
"id": @integer@,
"channel": {
"id": @integer@,
"code": "CHANNEL",
@ -130,9 +129,7 @@
"country_code": "NL",
"street": "Surrealism St.",
"city": "\u2019s-Hertogenbosch",
"postcode": "99-999",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()"
"postcode": "99-999"
},
"billing_address": {
"id": @integer@,
@ -141,9 +138,7 @@
"country_code": "NL",
"street": "Post-Impressionism St.",
"city": "Groot Zundert",
"postcode": "88-888",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()"
"postcode": "88-888"
},
"payments": [
{
@ -151,8 +146,6 @@
"method": {
"id": @integer@,
"code": "cod",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"channels": [
{
"id": @integer@,
@ -180,8 +173,6 @@
},
"amount": 30,
"state": "new",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"_links": {
"self": {
"href": "@string@"
@ -202,15 +193,6 @@
"method": {
"id": @integer@,
"code": "UPS",
"category_requirement": 1,
"calculator": "flat_rate",
"configuration": {
"CHANNEL": {
"amount": 10
}
},
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"enabled": true,
"_links": {
"self": {
@ -222,8 +204,6 @@
}
},
"tracking": "BANANAS",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"_links": {
"self": {
"href": "@string@"

View file

@ -40,7 +40,6 @@
"tracked": false,
"channel_pricings": [
{
"id": @integer@,
"channel": {
"id": @integer@,
"code": "CHANNEL",
@ -130,9 +129,7 @@
"country_code": "NL",
"street": "Surrealism St.",
"city": "\u2019s-Hertogenbosch",
"postcode": "99-999",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()"
"postcode": "99-999"
},
"billing_address": {
"id": @integer@,
@ -141,9 +138,7 @@
"country_code": "NL",
"street": "Post-Impressionism St.",
"city": "Groot Zundert",
"postcode": "88-888",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()"
"postcode": "88-888"
},
"payments": [
{
@ -151,8 +146,6 @@
"method": {
"id": @integer@,
"code": "cod",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"channels": [
{
"id": @integer@,
@ -180,8 +173,6 @@
},
"amount": 30,
"state": "new",
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"_links": {
"self": {
"href": "@string@"
@ -202,15 +193,6 @@
"method": {
"id": @integer@,
"code": "UPS",
"category_requirement": 1,
"calculator": "flat_rate",
"configuration": {
"CHANNEL": {
"amount": 10
}
},
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"enabled": true,
"_links": {
"self": {
@ -221,8 +203,6 @@
}
}
},
"created_at": "@string@.isDateTime()",
"updated_at": "@string@.isDateTime()",
"_links": {
"self": {
"href": "@string@"

View file

@ -14,7 +14,6 @@
"tracked": false,
"channel_pricings": [
{
"id": @integer@,
"channel": {
"id": @integer@,
"code": "WEB",
@ -35,7 +34,6 @@
"price": 124300
},
{
"id": @integer@,
"channel": {
"id": @integer@,
"code": "MOB",