Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

jsarnowski / jsarnowski/flexible-shipping-pro   php

Repository URL to install this package:

Version: 1.11.1 

/ wpdesk / wp-wpdesk-tracker / src / sender / class-wpdesk-tracker-sender-wordpress-to-wpdesk.php

<?php

namespace FSProVendor;

if (!\defined('ABSPATH')) {
    exit;
}
if (!\class_exists('FSProVendor\\WPDesk_Tracker_Sender_Wordpress_To_WPDesk')) {
    class WPDesk_Tracker_Sender_Wordpress_To_WPDesk implements \WPDesk_Tracker_Sender
    {
        /**
         * URL to the WP Desk Tracker API endpoint.
         * @var string
         */
        private $api_url = 'https://data.wpdesk.org/?track=1';
        private $test_api_url = 'https://testdata.wpdesk.org/?track=1';
        private function get_api_url()
        {
            $api_url = $this->api_url;
            if (\apply_filters('wpdesk_tracker_use_testdata', \false)) {
                $api_url = $this->test_api_url;
            }
            return $api_url;
        }
        /**
         * Sends payload to predefined receiver.
         *
         * @param array $payload Payload to send.
         *
         * @throws WPDesk_Tracker_Sender_Exception_WpError Error if send failed.
         *
         * @return array If succeeded. Array containing 'headers', 'body', 'response', 'cookies', 'filename'.
         */
        public function send_payload(array $payload)
        {
            $response = \wp_remote_post($this->get_api_url(), array('method' => 'POST', 'timeout' => 5, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => \false, 'headers' => array('user-agent' => 'WPDeskTracker'), 'body' => \json_encode($payload), 'cookies' => array()));
            if ($response instanceof \WP_Error) {
                throw new \FSProVendor\WPDesk_Tracker_Sender_Exception_WpError('Payload send error', $response);
            } else {
                return $response;
            }
        }
    }
}