public static function deploy($remote_url, $public_key, $private_key)
 {
     $fail = false;
     self::$elapsed_time = microtime(true);
     if (!class_exists('Pods_Migrate_Packages')) {
         return new WP_Error('pods-deploy-need-packages', __('You must activate the Packages Component on both the site sending and receiving this package.', 'pods-deploy'));
     }
     //@todo add options for these params
     $params = array('pods' => true, 'templates' => true, 'page' => true, 'helpers' => true);
     $data = Pods_Migrate_Packages::export($params);
     $url = trailingslashit($remote_url) . 'pods-components?package';
     $request_token = Pods_Deploy_Auth::generate_token($public_key, $private_key);
     $url = Pods_Deploy_Auth::add_to_url($public_key, $request_token, $url);
     $data = json_encode($data);
     $response = wp_remote_post($url, array('method' => 'POST', 'body' => $data));
     if (self::check_return($response)) {
         echo self::output_message(__('Package deployed successfully. ', 'pods-deploy'), $url);
         $responses = array();
         $api = pods_api();
         $params['names'] = true;
         $pod_names = $api->load_pods($params);
         $pod_names = array_flip($pod_names);
         $data = Pods_Deploy::get_relationships();
         $pods_api_url = trailingslashit($remote_url) . 'pods-api/';
         foreach ($pod_names as $pod_name) {
             $url = $pods_api_url . "{$pod_name}/update_rel";
             $url = Pods_Deploy_Auth::add_to_url($public_key, $request_token, $url);
             $responses[] = $response = wp_remote_post($url, array('method' => 'POST', 'body' => json_encode($data)));
             if (self::check_return($response)) {
                 echo self::output_message(__(sprintf('Relationships for the %1s Pod were updated.', $pod_name), 'pods-deploy'), $url);
             } else {
                 $fail = true;
                 echo self::output_message(__(sprintf('Relationships for the %1s Pod were not updated.', $pod_name), 'pods-deploy'), $url);
                 var_dump($response);
             }
         }
         if (!$fail) {
             echo self::output_message(__('Deployment complete :)', 'pods-deploy'));
         } else {
             echo self::output_message(__('Deployment completed with mixed results :|', 'pods-deploy'));
         }
     } else {
         echo self::output_message(__('Package could not be deployed :(', 'pods-deploy'));
         var_dump($response);
     }
 }
 /**
  * Update relationships
  *
  * @since 0.3.0 ?
  *
  * @return bool
  */
 private static function do_deploy_relationships($deploy_types = null)
 {
     $fail = false;
     $responses = array();
     $data = Pods_Deploy::get_relationships($deploy_types);
     if ($data === false) {
         // Don't try to deploy relationships if there aren't any
         return false;
     }
     $pods_api_url = trailingslashit(self::$remote_url) . 'pods-api/';
     $pod_name = pods_serial_comma(self::get_names_by_relationships($data));
     $url = $pods_api_url . "update_rel";
     $url = Pods_Deploy_Auth::add_to_url(self::$public_key, self::$token, $url);
     $responses[] = $response = wp_remote_post($url, array('method' => 'POST', 'body' => json_encode($data), 'timeout' => self::$timeout));
     if (self::check_return($response)) {
         echo self::output_message(__(sprintf('Relationships for the %1s Pod were updated.', $pod_name), 'pods-deploy'), $url);
     } else {
         $fail = true;
         echo self::output_message(__(sprintf('Relationships for the %1s Pod were not updated.', $pod_name), 'pods-deploy'), $url, true, false);
     }
     return $fail;
 }