Endpoint

class Endpoint

Class Endpoint

A representation of a versioned SalesForce REST API endpoint.

Properties

protected string $_baseUrl
protected string $_version

Methods

public __construct(string $baseUrl, string $version) Endpoint constructor.
public string getUrl() Gets the full endpoint url

Details

at line 38

__construct()

public __construct(string $baseUrl, string $version)

Endpoint constructor.

The provided SalesForce base url should omit a trailing slash. The version should be of the form \d\d.\d and should omit the preceding 'v'.

$endpoint = new Endpoint('https://company.my.salesforce.com', '10.0');

Parameters

string $baseUrl
string $version
at line 48

getUrl()

public string getUrl()

Gets the full endpoint url

Return Value

string

Source code

<?php

namespace SFClient\Endpoint;

/**
 * Class Endpoint
 *
 * A representation of a versioned SalesForce REST API endpoint.
 *
 * @package SFClient\Endpoint
 */
class Endpoint {

  /**
   * @var string
   */
  protected $_baseUrl;

  /**
   * @var string
   */
  protected $_version;

  /**
   * Endpoint constructor.
   *
   * The provided SalesForce base url should omit a trailing slash. The version
   * should be of the form \d\d.\d and should omit the preceding 'v'.
   *
   * ```php
   * $endpoint = new Endpoint('https://company.my.salesforce.com', '10.0');
   *
   * ```
   *
   * @param string $baseUrl
   * @param string $version
   */
  public function __construct(string $baseUrl, string $version) {
    $this->_baseUrl = $baseUrl;
    $this->_version = $version;
  }

  /**
   * Gets the full endpoint url
   *
   * @return string
   */
  public function getUrl(): string {
    return "{$this->_baseUrl}/services/data/v{$this->_version}/";
  }
}