API Transformer Documentation

Project Overview

This service allows you to add your own integrations, resulting in a standardized output of event data.

This service uses NitroJS. Nitro.js is a framework-agnostic, TypeScript-based server-side rendering engine for NodeJs. Learn more at nitro JS.

Architectural Approach

1. Core API Endpoint

2. Integration Registry

3. Transformer Functions

4. Configuration Management

5. Error Handling and Logging

Code Structure

src/
├── server/
│   ├── api/
│   │   └── transform-events.ts
│   ├── integrations/
│   │   ├── integration-registry.ts
│   │   ├── base-transformer.ts
│   │   └── [integration-name]/
│   │       ├── transformer.ts
│   │       └── config.ts
│   ├── utils/
│   │   ├── error-handler.ts
│   │   └── logger.ts
│   └── config/
│       └── integrations-config.ts
├── types/
│   └── web-event-item.ts
└── tests/
    └── integrations/
        └── [integration-name]/
            └── transformer.test.ts
    

API Usage

To use the API, send a POST request to /api/transform-events with the following structure:

{
  "integration": "integration-name",
  "data": {
    // Raw data from the integration's API
  }
}

Data is optional; if not provided, it will be fetched from the integration's API in the config file.

The API will respond with an array of WebEventItem objects.

Adding New Integrations

  1. Create a new folder under src/server/integrations/[integration-name].
  2. Implement the transformer in transformer.ts.
  3. Add any necessary configuration in config.ts.
  4. Register the new integration in integration-registry.ts.
  5. Add unit tests in tests/integrations/[integration-name]/transformer.test.ts.

Transform Data Extructure

    export interface WebEventItem  {
        backgroundImage: string;
        eventCategoryName: string;
        eventCategoryId: string;
        eventSubCategoryName: string;
        eventSubCategoryId: string;
        eventTitle: string;
        eventSubtitle: string;
        eventDataId: string;
        eventMetatile?: string;
        eventMetaDescription?: string;
        eventOgImage?: string;
        eventOgFocusKeyWords?: string;
        eventModificationDate?: Date;
        eventStatus: EventStatus;
        eventTypologyId: TypologyIds | string;
        eventisActive: boolean;
        eventVivaTypes: string[];
        eventImageUrl?: string;
        areaCode: string;
        areaDescription: string;
        currency: string;
        currentavailability: string;
        eventDescription: string;
        eventGroupId: string;
        eventGroupDescription: string;
        eventId: string;
        isGA: boolean;
        lang: string;
        performanceDate: Date;
        performanceId: string;
        price: string;
        priceMax: string;
        priceMin: string;
        promoterDescription: string;
        promoterId: string;
        reductionCode: string;
        reductionDescription: string;
        redirectUrl: string;
        saleEnd: Date;
        saleStart: Date;
        salesUrl: string;
        serverCode: 'janto' | 'viva' | 'eata' | 'cms';
        systemCode: string;
        totalavailability: string;
        url: string;
        venueAddress: string;
        venueCountry: string;
        venueDescription: string;
        venueId: string;
        googlePlacesId?: string;
        venueImageUrl?: string;
        htmlDescription?: string;
        venueInfoDescription?: string;
        venueInfoSchedule?: string;
        venueInfoUrl?: string;
        venueInfoPhone?: string;
        venueInfoEmail?: string;
        venueInfoMap?: string;
        venueInfoAddress?: string;
        venueInfoCity?: string;
        venueInfoState?: string;
        venueInfoZip?: string;
        venueInfoCountry?: string;
        widget: boolean;
        seoCanBeIndexed?: boolean;
        pixels?:Pixel[];
        recaptchaSiteKey?: string;
        widgetImageUrl?: string;
        headerImageUrl?: string;
        privacyPolicyUrl?: string;
        termsOfServiceUrl?: string;
    };

    interface Pixel {
        type: string;
        provider: string;
        data: PixelData;
    }

    interface PixelData {
        token: number;
    }


    export enum TypologyIds {
        Ticket = "0",
        Tour = "1",
        Programming = "2"
    }

    export enum TypologyTypes {
        Programming = "programming",
        Ticket = "ticket",
        Tour = "tour",
    }

    export enum EventStatus {
        NotVisible = 0,
        VisibleAndSearchable = 1,
        VisibleButNotSearchable = 2
    }


    
Property Type Optional Description
backgroundImage string No URL or path to the background image
eventCategoryName string No Name of the event category
eventCategoryId string No Unique identifier for the event category
eventSubCategoryName string No Name of the event subcategory
eventSubCategoryId string No Unique identifier for the event subcategory
eventTitle string No Title of the event
eventSubtitle string No Subtitle of the event
eventDataId string No Unique identifier for the event data
eventMetatile string Yes Meta title for the event
eventMetaDescription string Yes Meta description for the event
eventOgImage string Yes Open Graph image URL for the event
eventOgFocusKeyWords string Yes Open Graph focus keywords for the event
eventModificationDate Date Yes Date of last modification for the event
eventStatus EventStatus No Current status of the event (enum)
eventTypologyId TypologyIds | string No Typology identifier for the event
eventisActive boolean No Indicates if the event is active
eventVivaTypes string[] No Array of Viva types for the event
eventImageUrl string Yes URL of the event image
areaCode string No Code of the area where the event takes place
areaDescription string No Description of the area
currency string No Currency used for pricing
currentavailability string No Current availability status
eventDescription string No Detailed description of the event
eventGroupId string No Identifier for the event group
eventGroupDescription string No Description of the event group
eventId string No Unique identifier for the event
isGA boolean No Indicates if it's a general admission event
lang string No Language code for the event information
performanceDate Date No Date of the performance
performanceId string No Unique identifier for the performance
price string No Price of the event
priceMax string No Maximum price for the event
priceMin string No Minimum price for the event
promoterDescription string No Description of the event promoter
promoterId string No Unique identifier for the promoter
reductionCode string No Code for price reduction or discount
reductionDescription string No Description of the price reduction
redirectUrl string No URL for redirection
saleEnd Date No End date of the sale period
saleStart Date No Start date of the sale period
salesUrl string No URL for purchasing tickets
serverCode 'janto' | 'viva' | 'eata' | 'cms' No Code indicating the server type
systemCode string No Code of the system
totalavailability string No Total availability for the event
url string No URL associated with the event
venueAddress string No Address of the venue
venueCountry string No Country of the venue
venueDescription string No Description of the venue
venueId string No Unique identifier for the venue
googlePlacesId string Yes Google Places ID for the venue
venueImageUrl string Yes URL of the venue image
htmlDescription string Yes HTML-formatted description
venueInfoDescription string Yes Additional description of the venue
venueInfoSchedule string Yes Schedule information for the venue
venueInfoUrl string Yes URL with more information about the venue
venueInfoPhone string Yes Phone number of the venue
venueInfoEmail string Yes Email address of the venue
venueInfoMap string Yes Map information or URL for the venue
venueInfoAddress string Yes Detailed address of the venue
venueInfoCity string Yes City of the venue
venueInfoState string Yes State or region of the venue
venueInfoZip string Yes ZIP or postal code of the venue
venueInfoCountry string Yes Country of the venue
widget boolean No Indicates if a widget is available
seoCanBeIndexed boolean Yes Indicates if the event can be indexed for SEO
pixels Pixel[] Yes Array of Pixel objects for tracking
recaptchaSiteKey string Yes Site key for reCAPTCHA
widgetImageUrl string Yes URL of the image used in the widget
headerImageUrl string Yes URL of the header image
privacyPolicyUrl string Yes URL of the privacy policy
termsOfServiceUrl string Yes URL of the terms of service