| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * This file is part of gpupo/netshoes-sdk | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Created by Gilmar Pupo <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * For the information of copyright and license you should read the file | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * LICENSE which is distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * Para a informação dos direitos autorais e de licença você deve ler o arquivo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * LICENSE que é distribuído com este código-fonte. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * Para obtener la información de los derechos de autor y la licencia debe leer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * el archivo LICENSE que se distribuye con el código fuente. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * For more information, see <http://www.g1mr.com/>. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | namespace Gpupo\NetshoesSdk\Entity\Order; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Gpupo\CommonSdk\Entity\EntityAbstract; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Gpupo\CommonSdk\Entity\EntityInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * @method string getAgreedDate()    Acesso a agreedDate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * @method setAgreedDate(string $agreedDate)    Define agreedDate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * @method string getBusinessUnit()    Acesso a businessUnit | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * @method setBusinessUnit(string $businessUnit)    Define businessUnit | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  * @method bool getDevolutionRequested()    Acesso a devolutionRequested | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * @method setDevolutionRequested(boolean $devolutionRequested)    Define devolutionRequested | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  * @method bool getExchangeRequested()    Acesso a exchangeRequested | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  * @method setExchangeRequested(boolean $exchangeRequested)    Define exchangeRequested | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  * @method string getOrderDate()    Acesso a orderDate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  * @method setOrderDate(string $orderDate)    Define orderDate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  * @method string getOrderNumber()    Acesso a orderNumber | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  * @method setOrderNumber(string $orderNumber)    Define orderNumber | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  * @method string getOrderStatus()    Acesso a orderStatus | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  * @method setOrderStatus(string $orderStatus)    Define orderStatus | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  * @method string getOrderType()    Acesso a orderType | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  * @method setOrderType(string $orderType)    Define orderType | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  * @method string getOriginNumber()    Acesso a originNumber | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  * @method setOriginNumber(string $originNumber)    Define originNumber | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  * @method string getOriginSite()    Acesso a originSite | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  * @method setOriginSite(string $originSite)    Define originSite | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  * @method string getPaymentDate()    Acesso a paymentDate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  * @method setPaymentDate(string $paymentDate)    Define paymentDate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  * @method Gpupo\NetshoesSdk\Entity\Order\Shippings\Shippings getShippings()    Acesso a shippings | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  * @method setShippings(Gpupo\NetshoesSdk\Entity\Order\Shippings\Shippings $shippings)    Define shippings | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  * @method float getTotalCommission()    Acesso a totalCommission | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  * @method setTotalCommission(float $totalCommission)    Define totalCommission | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  * @method float getTotalDiscount()    Acesso a totalDiscount | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  * @method setTotalDiscount(float $totalDiscount)    Define totalDiscount | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  * @method float getTotalFreight()    Acesso a totalFreight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  * @method setTotalFreight(float $totalFreight)    Define totalFreight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  * @method float getTotalGross()    Acesso a totalGross | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  * @method setTotalGross(float $totalGross)    Define totalGross | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  * @method float getTotalNet()    Acesso a totalNet | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  * @method setTotalNet(float $totalNet)    Define totalNet | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  * @method float getTotalQuantity()    Acesso a totalQuantity | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  * @method setTotalQuantity(float $totalQuantity)    Define totalQuantity | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | class Order extends EntityAbstract implements EntityInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     protected $primaryKey = 'orderNumber'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * @codeCoverageIgnore | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     public function getSchema() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |             'agreedDate'          => 'string', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |             'businessUnit'        => 'string', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             'devolutionRequested' => 'boolean', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             'exchangeRequested'   => 'boolean', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |             'orderDate'           => 'string', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             'orderNumber'         => 'string', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             'orderStatus'         => 'string', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             'orderType'           => 'string', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |             'originNumber'        => 'string', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |             'originSite'          => 'string', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |             'paymentDate'         => 'string', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |             'shippings'           => 'object', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |             'totalCommission'     => 'number', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |             'totalDiscount'       => 'number', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |             'totalFreight'        => 'number', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |             'totalGross'          => 'number', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |             'totalNet'            => 'number', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |             'totalQuantity'       => 'number', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 1 |  |     protected function setUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 | 1 |  |         $this->setOptionalSchema(['devolutionRequested', 'exchangeRequested']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 | 1 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     public function toLog() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         return $this->partitionByArrayKey([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |             'orderDate', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |             'orderNumber', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |             'orderStatus', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |             'orderType', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |             'originNumber', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |             'originSite', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |             'paymentDate', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |             'totalFreight', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 | 5 |  |             'totalNet', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |             'totalQuantity', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 | 5 |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 109 | 5 |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 110 | 1 |  |     public function getShipping() | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  |         $shipping = $this->getShippings()->first(); | 
            
                                                                        
                            
            
                                    
            
            
                | 113 | 4 |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  |         if (empty($shipping)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  |             throw new \Exception('Shipping Missed!'); | 
            
                                                                        
                            
            
                                    
            
            
                | 116 | 3 |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 118 | 3 |  |         return $shipping; | 
            
                                                                        
                            
            
                                    
            
            
                | 119 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 | 1 |  |     public function getInvoice() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 | 1 |  |         return $this->getShipping()->getInvoice(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 | 1 |  |     public function getItems() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 | 1 |  |         return $this->getShipping()->getItems(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     public function check() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |         $this->setRequiredSchema(['businessUnit', 'orderDate', 'orderNumber']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |         return $this->isValid(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 137 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 138 |  |  |  |