Laravel AT Protocol Client (alpha & unstable)
at main 1.4 kB view raw
1<?php 2 3namespace SocialDept\AtpClient\Http; 4 5use Illuminate\Http\Client\Response as LaravelResponse; 6use Illuminate\Support\Collection; 7 8class Response 9{ 10 public function __construct( 11 protected LaravelResponse $response 12 ) {} 13 14 /** 15 * Get JSON response data 16 */ 17 public function json(?string $key = null, mixed $default = null): mixed 18 { 19 return $this->response->json($key, $default); 20 } 21 22 /** 23 * Get response as collection 24 */ 25 public function collect(?string $key = null): Collection 26 { 27 return $this->response->collect($key); 28 } 29 30 /** 31 * Get HTTP status code 32 */ 33 public function status(): int 34 { 35 return $this->response->status(); 36 } 37 38 /** 39 * Check if response was successful 40 */ 41 public function successful(): bool 42 { 43 return $this->response->successful(); 44 } 45 46 /** 47 * Check if response failed 48 */ 49 public function failed(): bool 50 { 51 return $this->response->failed(); 52 } 53 54 /** 55 * Get response body 56 */ 57 public function body(): string 58 { 59 return $this->response->body(); 60 } 61 62 /** 63 * Convert to array 64 */ 65 public function toArray(): array 66 { 67 return $this->response->json(); 68 } 69 70 /** 71 * Get underlying Laravel response 72 */ 73 public function getResponse(): LaravelResponse 74 { 75 return $this->response; 76 } 77}