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
Field | Type | Description |
---|---|---|
Code | int | A unique identifier for the access configuration. This field is provided by TG. |
User | string | The username provided by the supplier for authentication. |
Password | string | The password provided by the supplier for authentication. |
Urls | Urls | A collection of URLs used for specific operations like Search , Quote , etc. |
Parameters | AccessParameters | A dictionary of custom fields specific to the supplier (e.g., RequestorID ). |
Urls Class
Field | Type | Description |
---|---|---|
Book | string | The URL endpoint for the Book operation. |
Search | string | The URL endpoint for the Search operation. |
Quote | string | The URL endpoint for the Quote operation. |
Generic | string | A 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
andPassword
) 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
-
Validation of Required Fields:
- Ensures that fields such as
User
,Password
, andGeneric URL
are not null or empty. - Throws clear and descriptive exceptions for missing or invalid fields.
- Ensures that fields such as
-
Extraction of Custom Parameters:
- Custom parameters like
RequestorID
andClientId
are fetched from theAccessParameters
dictionary using helper methods.
- Custom parameters like
-
Optional Parameters:
- Includes support for optional parameters like
UseVersion22
, which defaults tofalse
if not explicitly set.
- Includes support for optional parameters like
-
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.