public function makeRequest(FormattedRequestInterface $request, \FS\Components\Shipping\RequestBuilder\Factory\RequestBuilderFactory $factory)
 {
     $request->setRequestPart('from', $this->makeRequestPart($factory->getBuilder('ShipperAddress', array('type' => 'order')), $this->payload));
     $toAddress = $this->makeRequestPart($factory->getBuilder('ReceiverAddress', array('type' => 'order')), $this->payload);
     $request->setRequestPart('to', $toAddress);
     $request->setRequestPart('packages', $this->makeRequestPart($factory->getBuilder('PackageItems', array('type' => 'order')), $this->payload));
     $request->setRequestPart('payment', array('payer' => 'F'));
     $request->setRequestPart('service', $this->makeRequestPart($factory->getBuilder('ShippingService', array('type' => 'order')), $this->payload));
     $request->setRequestPart('options', $this->makeRequestPart($factory->getBuilder('ShippingOptions', array('type' => 'order')), $this->payload + $request->getRequest()));
     return $request;
 }
 public function makeRequest(FormattedRequestInterface $request, \FS\Components\Shipping\RequestBuilder\Factory\RequestBuilderFactory $factory)
 {
     $request->setRequestPart('from', $this->makeRequestPart($factory->getBuilder('ShipperAddress', array('type' => 'cart')), $this->payload));
     $toAddress = $this->makeRequestPart($factory->getBuilder('ReceiverAddress', array('type' => 'cart')), $this->payload);
     $request->setRequestPart('to', $toAddress);
     $request->setRequestPart('packages', $this->makeRequestPart($factory->getBuilder('PackageItems', array('type' => 'cart')), $this->payload));
     $request->setRequestPart('payment', array('payer' => 'F'));
     // validate north american address
     if (in_array($toAddress['country'], array('CA', 'US'))) {
         $request->setRequestpart('options', array('address_correction' => true));
     }
     return $request;
 }
 public function makeRequest(FormattedRequestInterface $request, \FS\Components\Shipping\RequestBuilder\Factory\RequestBuilderFactory $factory)
 {
     $request->setRequestPart('address', $this->makeRequestPart($factory->getBuilder('ShipperAddress', array('type' => 'order')), $this->payload));
     $request->setRequestPart('courier', strtolower($this->payload['courier']));
     $request->setRequestPart('boxes', array_reduce($this->payload['orders'], function ($carry, $order) {
         $shipment = $order->getFlagShipRaw();
         if (!$shipment) {
             return $carry;
         }
         $carry += count($shipment['packages']);
         return $carry;
     }, 0));
     $request->setRequestPart('weight', array_reduce($this->payload['orders'], function ($carry, $order) {
         $shipment = $order->getFlagShipRaw();
         if (!$shipment) {
             return $carry;
         }
         $carry += array_reduce($shipment['packages'], function ($weight, $package) {
             $weight += $package['weight'];
             return $weight;
         }, 0);
         return $carry;
     }, 0));
     $request->setRequestPart('date', $this->payload['date']);
     $request->setRequestPart('from', $this->payload['options']->get('default_pickup_time_from', '09:00'));
     $request->setRequestPart('until', $this->payload['options']->get('default_pickup_time_to', '17:00'));
     $request->setRequestPart('units', 'imperial');
     $request->setRequestPart('location', 'Reception');
     $request->setRequestPart('to_country', $this->payload['orders'][0]->getWcOrder()->shipping_country);
     $request->setRequestPart('is_ground', $this->payload['type'] == 'domestic_ground' || $this->payload['type'] == 'international_ground');
     return $request;
 }
 public function makeRequest(FormattedRequestInterface $request, \FS\Components\Shipping\RequestBuilder\Factory\RequestBuilderFactory $factory)
 {
     $request->setRequestPart('address', $this->makeRequestPart($factory->getBuilder('ShipperAddress', array('type' => 'order')), $this->payload));
     $request->setRequestPart('courier', strtolower($this->payload['shipment']['service']['courier_name']));
     $request->setRequestPart('boxes', count($this->payload['shipment']['packages']));
     $request->setRequestPart('weight', array_reduce($this->payload['shipment']['packages'], function ($carry, $package) {
         $carry += $package['weight'];
         return $carry;
     }, 0));
     $request->setRequestPart('date', $this->payload['date']);
     $request->setRequestPart('from', $this->payload['options']->get('default_pickup_time_from', '09:00'));
     $request->setRequestPart('until', $this->payload['options']->get('default_pickup_time_to', '17:00'));
     $request->setRequestPart('units', 'imperial');
     $request->setRequestPart('location', 'Reception');
     $request->setRequestPart('to_country', $this->payload['order']->getWcOrder()->shipping_country);
     $request->setRequestPart('is_ground', strtolower($this->payload['shipment']['service']['courier_name']) == 'fedex' && strpos($this->payload['shipment']['service']['courier_code'], 'FedexGround') !== false);
     return $request;
 }