/**
  * Transform the Order
  *
  * @param Order $order
  * @return mixed
  */
 public function transform(Order $order)
 {
     foreach ($order->meta() as $key => $total) {
         $payload[$key] = $this->converter->convert($total);
     }
     $payload['products'] = [];
     foreach ($order->products() as $product) {
         $payload['products'][] = array_map(function ($value) {
             return $this->converter->convert($value);
         }, $product);
     }
     return json_encode($payload);
 }
Example #2
0
 /** @test */
 public function should_return_order_as_an_array()
 {
     $this->assertTrue(is_array($this->order->toArray()));
 }