'Message not found.', 'status' => '', 'recipient' => '', 'type' => '', 'delivery_message' => '', 'server' => '', 'server_ip' => '', ]; public function __construct(public Client $client) { } public function run(): array { // $settings = $this->client->getMergedSettings(); // if($settings->email_sending_method == 'default'){ // $this->postmark_token = config('services.postmark.token'); // } // elseif($settings->email_sending_method == 'client_postmark'){ // $this->postmark_token = $settings->postmark_secret; // } // else{ // return []; // } // $this->postmark = new PostmarkClient($this->postmark_token); return SystemLog::query() ->where('client_id', $this->client->id) ->where('category_id', SystemLog::CATEGORY_MAIL) ->orderBy('id','DESC') ->cursor() ->map(function ($system_log) { if($system_log->log['history'] ?? false){ return json_decode($system_log->log['history'],true); } })->toArray(); } private function fetchMessage(string $message_id): array { if(strlen($message_id) < 1){ return $this->default_response; } try { $messageDetail = $this->postmark->getOutboundMessageDetails($message_id); return [ 'subject' => $messageDetail->subject ?? '', 'status' => $messageDetail->status ?? '', 'recipient' => $messageDetail->messageevents[0]['Recipient'] ?? '', 'type' => $messageDetail->messageevents[0]->Type ?? '', 'delivery_message' => $messageDetail->messageevents[0]->Details->DeliveryMessage ?? '', 'server' => $messageDetail->messageevents[0]->Details->DestinationServer ?? '', 'server_ip' => $messageDetail->messageevents[0]->Details->DestinationIP ?? '', ]; } catch (\Exception $e) { return $this->default_response; } } }