Skip to main content

Access Data

An Access represents a connection between a Buyer and a Seller integrated into Travelgate. It contains all the credentials and custom parameters (specific to the supplier) required for successful communication.

Every request made to the connector includes an Access field with the following information:


Access Fields

FieldTypeDescription
CodeintA unique identifier for the access configuration. This field is provided by TG.
UserstringThe username provided by the supplier for authentication.
PasswordstringThe password provided by the supplier for authentication.
UrlsUrlsA collection of URLs used for specific operations like Search, Quote, etc.
ParametersAccessParametersA dictionary of custom fields specific to the supplier (e.g., RequestorID).

Urls Class

FieldTypeDescription
BookstringThe URL endpoint for the Book operation.
SearchstringThe URL endpoint for the Search operation.
QuotestringThe URL endpoint for the Quote operation.
GenericstringA generic URL endpoint that can be used for other operations or as a fallback.

Note: Each URL must be a valid and complete endpoint conforming to the supplier's API specifications.


AccessParameters Class

The AccessParameters class is a dictionary where custom fields specific to the supplier can be added. For instance, fields like RequestorID, ClientID, or Version, which are common in many APIs, can be defined here. These fields provide flexibility for supplier-specific configurations.


Example JSON

Below is an example Access configuration with fictitious values:

{
"Code": 1234,
"User": "supplier_user",
"Password": "secure_password",
"Urls": {
"Book": "https://api.supplier.com/book",
"Search": "https://api.supplier.com/search",
"Quote": "https://api.supplier.com/quote",
"Generic": "https://api.supplier.com/generic"
},
"Parameters": {
"RequestorID": "Travelgate",
"ClientID": "Client123",
"Version": "v1.0"
}
}

Key Points

  • The Access object centralizes all connection-related data for seamless integration with suppliers.
  • Custom fields in Parameters allow suppliers to extend the standard functionality based on their API requirements.
  • Proper configuration of Urls and authentication details (User and Password) is essential for successful communication.

Connector's Binder

Each connector defines a class responsible for validating and binding access information. This layer ensures that the access credentials and parameters are valid before proceeding with any operations. It acts as the first validation layer to prevent errors later in the process.

The binder is crucial for ensuring seamless communication between the Travelgate Marketplace and suppliers by verifying that all required fields and parameters are correctly set.

Example Binder Class

Below is an example implementation of a binder class:

public class CntAccessModel : IBindAccessModel
{
public string User { get; private set; }
public string Password { get; private set; }
public Uri Url { get; private set; }
public string RequestorID { get; private set; }
public int ClientId { get; private set; }
public bool UseVersion22 { get; private set; } // This field is optional

public void Bind(string supplier, Access access)
{
if (string.IsNullOrEmpty(access.User))
{
throw new ArgumentException("User cannot be null or empty.", nameof(access.User));
}
User = access.User;

if (string.IsNullOrEmpty(access.Password))
{
throw new ArgumentException("Password cannot be null or empty.", nameof(access.Password));
}
Password = access.Password;

if (access.Urls?.Generic == null)
{
throw new ArgumentException("Generic URL cannot be null.", nameof(access.Urls.Generic));
}

RequestorID = access.Parameters.GetRequiredOrException("RequestorID");
ClientId = access.Parameters.GetRequiredOrExceptionAsInt("ClientId");
UseVersion22 = access.Parameters.GetOrFalse("UseVersion22");
}
}

Key Features of the Binder

  1. Validation of Required Fields:

    • Ensures that fields such as User, Password, and Generic URL are not null or empty.
    • Throws clear and descriptive exceptions for missing or invalid fields.
  2. Extraction of Custom Parameters:

    • Custom parameters like RequestorID and ClientId are fetched from the AccessParameters dictionary using helper methods.
  3. Optional Parameters:

    • Includes support for optional parameters like UseVersion22, which defaults to false if not explicitly set.
  4. Centralized Access Management:

    • Centralizes the logic for binding and validating access credentials, reducing duplication across the connector.

Example JSON Access Object

{
"User": "SupplierUser123",
"Password": "SecurePassword",
"Urls": {
"Book": "https://api.supplier.com/book",
"Search": "https://api.supplier.com/search",
"Quote": "https://api.supplier.com/quote",
"Generic": "https://api.supplier.com"
},
"Parameters": {
"RequestorID": "REQ-12345",
"ClientId": "789",
"UseVersion22": "true"
}
}

Benefits of a Binder

  • Error Prevention: Ensures early detection of invalid access details.
  • Consistency: Establishes a uniform validation mechanism across all connectors.
  • Scalability: Easily extendable to include new parameters or requirements.

This approach ensures that access validation is handled efficiently, maintaining the integrity of the connector's operations.