protected static function record_event($timestamp, $code, $data, $key = '', $url = '') { $key = $key ? $key : Prompt_Core::$options->get('prompt_key'); $default_url = defined('PROMPT_EVENT_API_URL') ? PROMPT_EVENT_API_URL : 'https://events.gopostmatic.com/api/v1'; $url = $url ? $url : $default_url; $client = new Prompt_Api_Client(array(), $key, $url); $data = array('events' => array(compact('timestamp', 'code', 'data'))); $client->post_events($data); }
/** * @since 2.0.0 * * @return null|object|WP_Error */ public function send() { do_action('prompt/outbound/batch', $this->batch); if (!$this->batch->get_individual_message_values()) { return null; } if ($this->is_retry and $this->already_retried()) { return new WP_Error(Prompt_Enum_Error_Codes::DUPLICATE, __('Duplicate retry skipped.', 'Postmatic'), array('batch' => $this->batch, 'retry_wait_seconds' => $this->retry_wait_seconds)); } $result = $this->client->post_outbound_message_batches($this->batch->to_array()); if ($this->reschedule($result)) { return $result; } $error = $this->translate_error($result); if ($error) { return $error; } return json_decode($result['body']); }