Create GitLab API endpoints.

@param GitLab_API|API $git
@param string         $endpoint

@return string $endpoint
508673
public function add_endpoints( $git, $endpoint ) {
		switch ( $git::$method ) {
			case 'projects':
				$endpoint = add_query_arg( 'per_page', '100', $endpoint );
				break;
			case 'meta':
			case 'tags':
			case 'branches':
			case 'download_link':
				break;
			case 'file':
			case 'changes':
			case 'readme':
				$endpoint = add_query_arg( 'ref', $git->type->branch, $endpoint );
				break;
			case 'translation':
				$endpoint = add_query_arg( 'ref', 'master', $endpoint );
				break;
			case 'release_asset':
				$endpoint = add_query_arg( 'job', $git->type->ci_job, $endpoint );
				break;
			default:
				break;
		}

		$endpoint = $this->add_access_token_endpoint( $git, $endpoint );

		/*
		 * If GitLab CE/Enterprise return this endpoint.
		 */
		if ( ! empty( $git->type->enterprise_api ) ) {
			return $git->type->enterprise_api . $endpoint;
		}

		return $endpoint;
	}
789736
public function fillEndPoint(string &$endPoint): void
    {
        $endPoint = str_replace("{sms}", $this->smsID, $endPoint);
        $endPoint = str_replace("{bundle}", $this->bundleID ?? "", $endPoint);
    }
975053
function makeRequest(string $method, string $endpoint, array $options) {
        $request = new \CharlotteDunois\Yasmin\HTTP\APIRequest($this, $method, $endpoint, $options);
        return $this->add($request);
    }
89417
public function makeRequest($endpoint, array $parameters = array(), $method = 'GET')
    {
        $response = array();

        // Validate if this endpoint has a BC url
        $bcEndpoint = null;
        if (!$this->bcAttempt) {
            if (!empty($this->bcRegexEndpoints)) {
                foreach ($this->bcRegexEndpoints as $regex => $bc) {
                    if (preg_match('@'.$regex.'@', $endpoint)) {
                        $this->bcAttempt = true;
                        $bcEndpoint = preg_replace('@'.$regex.'@', $bc, $endpoint);

                        break;
                    }
                }
            }
        }

        $url = $this->baseUrl.$endpoint;

        // Don't make the call if we're unit testing a BC endpoint
        if (!$bcEndpoint || !$this->bcTesting || ($bcEndpoint && $this->bcTesting && $this->bcAttempt)) {
            // Hack for unit testing to ensure this isn't being called due to a bad regex
            if ($this->bcTesting && !$this->bcAttempt) {
                $bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
                if (!is_array($this->bcTesting)) {
                    $this->bcTesting = array($this->bcTesting);
                }

                // The method is not catching the BC endpoint so fail the test
                if (in_array($bt[1]['function'], $this->bcTesting)) {
                    throw new \Exception($endpoint.' not matched in '.var_export($this->bcRegexEndpoints, true));
                }
            }
            $this->bcAttempt = false;

            if (strpos($url, 'http') === false) {
                $error = array(
                    'code'    => 500,
                    'message' => sprintf(
                        'URL is incomplete.  Please use %s, set the base URL as the third argument to $MauticApi->newApi(), or make $endpoint a complete URL.',
                        __CLASS__.'setBaseUrl()'
                    )
                );
            } else {
                try {
                    $settings = [];
                    if (method_exists($this, 'getTemporaryFilePath')) {
                        $settings['temporaryFilePath'] = $this->getTemporaryFilePath();
                    }
                    $response = $this->auth->makeRequest($url, $parameters, $method, $settings);

                    $this->getLogger()->debug('API Response', array('response' => $response));

                    if (!is_array($response)) {
                        $this->getLogger()->warning($response);

                        //assume an error
                        $error = array(
                            'code'    => 500,
                            'message' => $response
                        );
                    }

                    // @deprecated support for 2.6.0 to be removed in 3.0
                    if (!isset($response['errors']) && isset($response['error']) && isset($response['error_description'])) {
                        $message = $response['error'].': '.$response['error_description'];

                        $this->getLogger()->warning($message);

                        $error = array(
                            'code'    => 403,
                            'message' => $message
                        );
                    }
                } catch (\Exception $e) {
                    $this->getLogger()->error('Failed connecting to Mautic API: '.$e->getMessage(), array('trace' => $e->getTraceAsString()));

                    $error = array(
                        'code'    => $e->getCode(),
                        'message' => $e->getMessage()
                    );
                }
            }

            if (!empty($error)) {
                return array(
                    'errors' => array($error),
                    // @deprecated 2.6.0 to be removed 3.0
                    'error'  => $error
                );
            } elseif (!empty($response['errors'])) {
                $this->getLogger()->error('Mautic API returned errors: '.var_export($response['errors'], true));
            }

            // @deprecated 2.6.0 BC error handling
            // @todo remove in 3.0
            if (isset($response['error']) && !isset($response['errors'])) {
                if (isset($response['error_description'])) {
                    // BC Oauth2 error
                    $response['errors'] = array(
                        array(
                            'message' => $response['error_description'],
                            'type'    => $response['error']
                        )
                    );
                } elseif (isset($response['message'])) {
                    $response['errors'] = array(
                        $response['error']
                    );
                }
            }

            // Ensure a code is present in the error array
            if (!empty($response['errors'])) {
                $info = $this->auth->getResponseInfo();
                foreach ($response['errors'] as $key => $error) {
                    if (!isset($response['errors'][$key]['code'])) {
                        $response['errors'][$key]['code'] = $info['http_code'];
                    }
                }
            }
        }

        // Check for a 404 code and a BC URL then try again if applicable
        if ($bcEndpoint && ($this->bcTesting || (!empty($response['errors'][0]['code']) && (int) $response['errors'][0]['code'] === 404))) {
            $this->bcAttempt = true;

            return $this->makeRequest($bcEndpoint, $parameters, $method);
        }

        return $response;
    }
863832
public function callEndpoint($endpoint, array $endpointParameters = [], $body = null, $method = HttpMethod::REQUEST_GET)
    {
        // Set the endpoint
        $this->setEndpoint($endpoint);
        // Set the parameters
        $this->setEndpointParameters($endpointParameters);
        // Set the body
        $this->setBody($body);
        // Set the HTTP method
        $this->setHttpMethod($method);
        // Call the endpoint
        $this->call();
        // return the result
        return $this->getResult();
    }
418212
private function request($method, $endpoint, $params, $body)
    {
        $setParams = $params && in_array($method, ["GET", "POST", "DELETE"]);
        $setBody = $body && in_array($method, ["POST", "PUT", "DELETE"]);

        $method = strtoupper($method);
        $url = $this->basePath . $endpoint . ($setParams ? "?" . $this->encodeParams($params) : "");

        $options = array();
        $options[CURLOPT_URL] = $url;
        $options[CURLOPT_HTTPHEADER] = $this->headers;
        $options[CURLOPT_RETURNTRANSFER] = true;
        $options[CURLOPT_CUSTOMREQUEST] = $method;
        $options[CURLOPT_POSTFIELDS] = $setBody ? json_encode($body) : null;
        $options[CURLOPT_CONNECTTIMEOUT] = $this->getConnectionOption("connectTimeout");
        $options[CURLOPT_TIMEOUT_MS] = $this->getConnectionOption("timeout");

        $curl = curl_init();

        if (isset($this->logger)) {
            $context = [ "options" => $options ];
            $this->logger->info("[ApiClient][Request] Curl request;", $context);
        }

        curl_setopt_array($curl, $options);

        $result = curl_exec($curl);
        $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        $error = curl_error($curl);

        curl_close($curl);

        if (isset($this->logger)) {
            $context = [ "result" => $result, "statusCode" => $statusCode, "error" => $error ];
            $this->logger->info("[ApiClient][Request] Curl response;", $context);
        }

        if ($result === false) {
            throw new ClientException($error);
        }
        elseif ($statusCode >= 400) {
            $error = json_decode($result);
            throw new ClientException($error, $statusCode);
        }

        return json_decode($result);
    }
154010
public static function requestApi($endpoint, $data, $cert = false): Collection
    {
        Events::dispatch(Events::API_REQUESTING, new Events\ApiRequesting('Wechat', '', self::$instance->getBaseUri().$endpoint, $data));

        $result = self::$instance->post(
            $endpoint,
            self::toXml($data),
            $cert ? [
                'cert'    => self::$instance->cert_client,
                'ssl_key' => self::$instance->cert_key,
            ] : []
        );
        $result = is_array($result) ? $result : self::fromXml($result);

        Events::dispatch(Events::API_REQUESTED, new Events\ApiRequested('Wechat', '', self::$instance->getBaseUri().$endpoint, $result));

        return self::processingApiResult($endpoint, $result);
    }
1175024
public function requestEndpoint(AbstractEndpoint $endpoint)
    {
        $cloned = clone $endpoint;
        $cloned->setType($this->getName());

        return $this->getIndex()->requestEndpoint($cloned);
    }
1187411
protected function request($method, $endpoint, $options = [])
    {
        return $this->unwrapResponse($this->getHttpClient($this->getBaseOptions())->{$method}($endpoint, $options));
    }
1210450
private Retrofit.Builder setEndpoint(Retrofit.Builder retrofitBuilder, String endpoint) {
    if (endpoint != null) {
      return retrofitBuilder.baseUrl(endpoint);
    }
    return retrofitBuilder;
  }
733269
protected function createClient($endpoint, $config = [])
    {
        $ssl = $this->config['ssl'];
        $name = $this->config['ssl_name'];
        $verifySign = $this->config['ssl_verify_sign'];
        $verifyPeer = $this->config['ssl_verify_peer'];
        $verifyDepth = $this->config['ssl_verify_depth'];

        $context = [];
        $context['socket'] = [
            'connect' => $endpoint
        ];
        $context['ssl'] = [
            'capture_peer_cert' => true,
            'capture_peer_chain' => true,
            'capture_peer_cert_chain' => true,
            'allow_self_signed' => !$verifySign,
            'verify_peer' => $verifyPeer,
            'verify_peer_name' => $verifyPeer,
            'verify_depth' => $verifyDepth,
            'SNI_enabled' => $name !== '',
            'SNI_server_name' => $name,
            'peer_name' => $name,
            'disable_compression' => true,
            'honor_cipher_order' => true,
        ];

        if ($ssl && isset($config['ssl_cafile']))
        {
            $context['ssl']['cafile'] = $config['ssl_cafile'];
        }

        if ($ssl && isset($config['ssl_capath']))
        {
            $context['ssl']['capath'] = $config['ssl_capath'];
        }

        $context = stream_context_create($context);
        // Error reporting suppressed since stream_socket_client() emits an E_WARNING on failure.
        $socket = @stream_socket_client(
            $endpoint,
            $errno,
            $errstr,
            0, // Timeout does not apply for async connect.
            STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT,
            $context
        );

        if (!$socket || $errno > 0)
        {
            throw new LogicException(
                sprintf('Could not connect socket [%s] because of error [%d; %s]', $endpoint, $errno, $errstr)
            );
        }

        stream_set_blocking($socket, false);

        return $socket;
    }
913077
public function setEndpoint($endpoint = '')
    {
        $this->endpoint = $endpoint;
        $this->debug->info(__FUNCTION__, 'setEndpoint: ', $this->endpoint);

        return $this;
    }
1028268
public function post($endpoint, array $options = [])
    {
        $jsonValues = [];

        if (isset($options['json'])) {
            $jsonValues = $options['json'];
        }

        return $this->httpClient->request('POST', 'https://api.craftcms.com/v1/'.$endpoint, [
            'auth' => $this->setAuth(),
            'json' => $jsonValues
        ]);
    }
560115
private function makeRequest($body, $endpoint, $account = null)
    {
        return Core::instance()->client()
            ->request(
                'POST',
                $endpoint,
                [
                    'headers' => [
                        'Authorization' => 'Bearer ' . Core::instance()->auth()->authenticate($account),
                        'Content-Type'  => 'application/json',
                    ],
                    'json' => $body,
                ]
            );
    }
332031
protected function request(string $method, string $endpoint, $json = null)
    {
        $uri = $this->buildUri($endpoint);
        $options = $json != null ? ['json' => $json] : [];

        try {
            $response = $this->client->request($method, $uri, $options);
        } catch (ClientException $exception) {
            throw $this->determineException($exception);
        }

        $body = (string) $response->getBody();

        return $this->jsonValidator($body) ? json_decode($body, true) : $body;
    }
1128932
public static function getApiUrl($endpoint, $version = null)
    {
        if ($version === null) {
            $version = self::$apiVersion;
        }
        return self::$apiBase . '/v' . $version . '/' . $endpoint . '/json';
    }
315386
public function get_remote_api_repo_meta( $git, $request ) {
		$response = isset( $this->response['meta'] ) ? $this->response['meta'] : false;

		if ( ! $response ) {
			self::$method = 'meta';
			$response     = $this->api( $request );

			if ( $response ) {
				$response = $this->parse_meta_response( $response );
				$this->set_repo_cache( 'meta', $response );
			}
		}

		if ( $this->validate_response( $response ) ) {
			return false;
		}

		$this->type->repo_meta = $response;
		$this->add_meta_repo_object();

		return true;
	}