Exemplo n.º 1
0
 /**
  * Return API url.
  *
  * @param string $endpoint
  *
  * @return string
  */
 private function _get_api_url($endpoint)
 {
     $type = $this->return_repo_type();
     $segments = array('owner' => $this->type->owner, 'repo' => $this->type->repo);
     /*
      * Add or filter the available segments that are used to replace placeholders.
      *
      * @param array $segments list of segments.
      */
     $segments = apply_filters('github_updater_api_segments', $segments);
     foreach ($segments as $segment => $value) {
         $endpoint = str_replace('/:' . sanitize_key($segment), '/' . sanitize_text_field($value), $endpoint);
     }
     switch ($type['repo']) {
         case 'github':
             $endpoint = GitHub_API::add_endpoints($this, $endpoint);
             if ($this->type->enterprise) {
                 return $endpoint;
             }
             break;
         case 'gitlab':
             $endpoint = GitLab_API::add_endpoints($this, $endpoint);
             if ($this->type->enterprise) {
                 return $endpoint;
             }
             break;
         default:
     }
     return $type['base_uri'] . $endpoint;
 }
Exemplo n.º 2
0
 /**
  * Return API url.
  *
  * @access private
  *
  * @param string $endpoint
  *
  * @return string $endpoint
  */
 private function get_api_url($endpoint)
 {
     $type = $this->return_repo_type();
     $segments = array('owner' => $this->type->owner, 'repo' => $this->type->repo);
     foreach ($segments as $segment => $value) {
         $endpoint = str_replace('/:' . sanitize_key($segment), '/' . sanitize_text_field($value), $endpoint);
     }
     switch ($type['repo']) {
         case 'github':
             $api = new GitHub_API($type['type']);
             $endpoint = $api->add_endpoints($this, $endpoint);
             if ($this->type->enterprise_api) {
                 return $endpoint;
             }
             break;
         case 'gitlab':
             $api = new GitLab_API($type['type']);
             $endpoint = $api->add_endpoints($this, $endpoint);
             if ($this->type->enterprise_api) {
                 return $endpoint;
             }
             break;
         default:
     }
     return $type['base_uri'] . $endpoint;
 }