| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Ipag\Sdk\Model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Ipag\Sdk\Model\Schema\Mutator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Ipag\Sdk\Model\Schema\Schema; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Ipag\Sdk\Model\Schema\SchemaBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Kubinyete\Assertation\Assert; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * Order Class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * Classe responsável por representar o recurso Order. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | class Order extends Model | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      *  @param array $data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      *  array de dados do Order. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      *  + [`'order_id'`] string. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      *  + [`'amount'`] float. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      *  + [`'created_at'`] string. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      *  + [`'callback_url'`] string. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      *  + [`'return_url'`] string. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      *  + [`'return_type'`] string. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     public function __construct(?array $data = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         parent::__construct($data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     protected function schema(SchemaBuilder $schema): Schema | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         $schema->string('order_id')->nullable(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         $schema->float('amount')->nullable(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         $schema->string('created_at')->nullable(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $schema->string('callback_url')->nullable(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         $schema->string('return_url')->nullable(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $schema->string('return_type')->nullable(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         return $schema->build(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     protected function amount(): Mutator | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         return new Mutator( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |             null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |             fn($value, $ctx) => | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             is_null($value) ? $value : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |                 Assert::value(floatval($value))->gte(0)->get() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |                 ?? $ctx->raise('inválido') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * Retorna o valor da propriedade `order_id`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * @return string|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     public function getOrderId(): ?string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         return $this->get('order_id'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      * Seta o valor da propriedade `order_id`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |      * @param string|null $orderId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |      * @return self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     public function setOrderId(?string $orderId = null): self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         $this->set('order_id', $orderId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      * Retorna o valor da propriedade `amount`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      * @return float|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     public function getAmount(): ?float | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         return $this->get('amount'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |      * Seta o valor da propriedade `amount`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      * @param float|null $amount | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      * @return self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     public function setAmount(?float $amount = null): self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         $this->set('amount', $amount); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |      * Retorna o valor da propriedade `created_at`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |      * @return string|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     public function getCreatedAt(): ?string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |         return $this->get('created_at'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |      * Seta o valor da propriedade `created_at`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |      * @param string|null $createdAt | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |      * @return self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     public function setCreatedAt(?string $createdAt = null): self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         $this->set('created_at', $createdAt); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |      * Retorna o valor da propriedade `callback_url`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |      * @return string|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     public function getCallbackUrl(): ?string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         return $this->get('callback_url'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      * Seta o valor da propriedade `callback_url`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |      * @param string|null $callbackUrl | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |      * @return self | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 139 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 140 |  |  |     public function setCallbackUrl(?string $callbackUrl = null): self | 
            
                                                                        
                            
            
                                    
            
            
                | 141 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  |         $this->set('callback_url', $callbackUrl); | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |      * Retorna o valor da propriedade `return_url`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |      * @return string|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |     public function getReturnUrl(): ?string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |         return $this->get('return_url'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |      * Seta o valor da propriedade `return_url`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |      * @param string|null $returnUrl | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |      * @return self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |     public function setReturnUrl(?string $returnUrl = null): self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         $this->set('return_url', $returnUrl); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |      * Retorna o valor da propriedade `return_type`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      * @return string|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     public function getReturnType(): ?string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |         return $this->get('return_type'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |      * Seta o valor da propriedade `return_type`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |      * @param string|null $returnType | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |      * @return self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |     public function setReturnType(?string $returnType = null): self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         $this->set('return_type', $returnType); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 190 |  |  | } |