@omeron/ota-bre-angular-sdk (1.0.1)

Published 2026-04-17 05:48:19 +00:00 by omeron-admin

Installation

@omeron:registry=
npm install @omeron/ota-bre-angular-sdk@1.0.1
"@omeron/ota-bre-angular-sdk": "1.0.1"

About this package

@omeron/ota-bre-angular-sdk

Angular SDK for OTA Business Rules Engine API

Installation

npm install @omeron/ota-bre-angular-sdk

API Base URL

Environment URL
Production https://api.taas.omeron.com/api
Development http://localhost:8092/api

Setup

1. Import Module

import { NgModule } from '@angular/core';
import { OtaBreModule } from '@omeron/ota-bre-angular-sdk';

@NgModule({
  imports: [
    OtaBreModule.forRoot({
      apiUrl: 'http://localhost:8092/api',
      defaultDomainId: 'your-domain-id', // Optional
      apiKey: 'your-product-api-key', // Required for booking ingestion
    }),
  ],
})
export class AppModule {}

2. Use Services

import { Component } from '@angular/core';
import {
  AuthService,
  DomainService,
  GfsRuleService,
} from '@omeron/ota-bre-angular-sdk';

@Component({
  selector: 'app-login',
  template: `...`,
})
export class LoginComponent {
  constructor(private authService: AuthService) {}

  login() {
    this.authService
      .login({
        email: 'user@example.com',
        password: 'password',
      })
      .subscribe((response) => {
        console.log('Logged in:', response.user);
      });
  }
}

Available Services

AuthService

  • login(credentials) - Login and get JWT token
  • logout() - Logout and clear tokens
  • refreshToken() - Refresh access token
  • getCurrentUser() - Get current user details
  • isAuthenticated() - Check if user is authenticated
  • setDomain(domainId) - Switch current domain
  • getCurrentDomainId() - Get current domain ID

DomainService

  • findAll(params?) - Get all domains with pagination
  • findById(id) - Get domain by ID
  • create(domain) - Create new domain
  • update(id, domain) - Update domain
  • delete(id) - Delete domain
  • getConnectorSettings(id) - Get domain connector settings
  • updateConnectorSettings(id, settings) - Update connector settings
  • testSftpConnection(id, settings) - Test SFTP connection

GfsRuleService

  • findAll(params?) - Get all GFS rules with pagination
  • findById(id) - Get rule by ID
  • create(rule) - Create new rule
  • update(id, rule) - Update rule
  • delete(id) - Delete rule
  • updateSequence(id, sequence) - Update rule sequence
  • enable(id) - Enable rule
  • disable(id) - Disable rule

PartnerService

  • findAll(params?) - Get all partners
  • findById(id) - Get partner by ID
  • create(partner) - Create new partner
  • update(id, partner) - Update partner
  • delete(id) - Delete partner

ApiKeyService

  • findAll() - Get all API keys
  • create(name, expiresAt?) - Create new API key
  • revoke(id) - Revoke API key
  • enable(id) - Enable API key
  • disable(id) - Disable API key

BookingService (API Key Auth)

  • upsert(request, domainId?) - Upsert a booking event (create or update by PNR)
  • getStatus(pnrId) - Get booking status by PNR ID
  • createBooking(request, domainId?) - Create a new booking
  • cancelBooking(pnrId, statusChange?, domainId?) - Cancel a booking
  • voidBooking(pnrId, reason?, domainId?) - Void a booking
  • refundBooking(pnrId, statusChange?, domainId?) - Refund a booking
  • exchangeBooking(request, domainId?) - Exchange/rebook a booking

Supported Event Types

Type Description
CREATED New booking
MODIFIED Booking update
CANCELLED Cancellation
VOIDED Void (same-day cancel)
REFUNDED Refund processed
EXCHANGED Rebooked to new PNR

Example: Complete Login Flow

import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from '@omeron/ota-bre-angular-sdk';

@Component({
  selector: 'app-login',
  template: `
    <form (ngSubmit)="onSubmit()">
      <input [(ngModel)]="email" type="email" placeholder="Email" />
      <input [(ngModel)]="password" type="password" placeholder="Password" />
      <button type="submit">Login</button>
      <div *ngIf="error">{{ error }}</div>
    </form>
  `,
})
export class LoginComponent {
  email = '';
  password = '';
  error = '';

  constructor(
    private authService: AuthService,
    private router: Router,
  ) {}

  onSubmit() {
    this.authService
      .login({ email: this.email, password: this.password })
      .subscribe({
        next: (response) => {
          console.log('Login successful:', response.user);
          this.router.navigate(['/dashboard']);
        },
        error: (err) => {
          this.error = err.error?.message || 'Login failed';
        },
      });
  }
}

Example: Working with Rules

import { Component, OnInit } from '@angular/core';
import { GfsRuleService, GFSRule } from '@omeron/ota-bre-angular-sdk';

@Component({
  selector: 'app-rules',
  template: `
    <div *ngFor="let rule of rules">
      <h3>{{ rule.name }}</h3>
      <p>Sequence: {{ rule.sequenceNumber }}</p>
      <button (click)="toggleRule(rule)">
        {{ rule.enabled ? 'Disable' : 'Enable' }}
      </button>
    </div>
  `,
})
export class RulesComponent implements OnInit {
  rules: GFSRule[] = [];

  constructor(private gfsRuleService: GfsRuleService) {}

  ngOnInit() {
    this.loadRules();
  }

  loadRules() {
    this.gfsRuleService.findAll({ page: 0, size: 20 }).subscribe((response) => {
      this.rules = response.content;
    });
  }

  toggleRule(rule: GFSRule) {
    const action$ = rule.enabled
      ? this.gfsRuleService.disable(rule.id)
      : this.gfsRuleService.enable(rule.id);

    action$.subscribe(() => this.loadRules());
  }
}

Example: Booking Ingestion

import { Component } from '@angular/core';
import {
  BookingService,
  BookingEventRequest,
} from '@omeron/ota-bre-angular-sdk';

@Component({
  selector: 'app-booking-push',
  template: `
    <button (click)="pushBooking()">Push Booking</button>
    <div *ngIf="result">{{ result }}</div>
  `,
})
export class BookingPushComponent {
  result = '';

  constructor(private bookingService: BookingService) {}

  pushBooking() {
    const request: BookingEventRequest = {
      event_type: 'CREATED',
      pnr_id: 'ABC123',
      source: {
        pos: 'UK',
        gds: 'AMADEUS',
        airline_code: 'BA',
        airline_name: 'British Airways',
        cabin_class: 'Y',
      },
      travel: {
        departure_city: 'LHR',
        arrival_city: 'JFK',
        trip_type: 'RETURN',
        departure_date: '2026-04-01',
      },
      passengers: { pax_count: 2, segments_per_pax: 2 },
      financials: {
        currency: 'GBP',
        grand_total: 1250.0,
        total_cost: 1100.0,
      },
    };

    this.bookingService.createBooking(request).subscribe({
      next: (response) => {
        this.result = `Booking ${response.action_taken}: ${response.booking_id}`;
      },
      error: (err) => {
        this.result = `Error: ${err.error?.message || err.message}`;
      },
    });
  }

  cancelBooking(pnrId: string) {
    this.bookingService
      .cancelBooking(pnrId, {
        cancellation_date: '2026-03-15',
        cancellation_fee: 75.0,
        reason: 'Customer request',
      })
      .subscribe({
        next: (response) => {
          this.result = `Booking cancelled: ${response.booking_id}`;
        },
      });
  }
}

Authentication

The SDK automatically handles JWT token storage and injection via HTTP interceptor. Tokens are stored in localStorage:

  • ota_bre_access_token - JWT access token
  • ota_bre_refresh_token - Refresh token
  • ota_bre_domain_id - Current domain ID

All API requests automatically include:

  • Authorization: Bearer <token> header
  • X-Domain-ID header (if domain is set)

Error Handling

All services return RxJS Observables. Handle errors using the standard RxJS error handling:

this.domainService.findById('invalid-id').subscribe({
  next: (domain) => console.log(domain),
  error: (err) => {
    if (err.status === 404) {
      console.error('Domain not found');
    } else if (err.status === 401) {
      console.error('Unauthorized');
    }
  },
});

License

MIT

Dependencies

Development Dependencies

ID Version
@angular/common ^17.0.0
@angular/core ^17.0.0
@types/node ^20.0.0
rxjs ^7.8.0
typescript ^5.0.0

Peer Dependencies

ID Version
@angular/common >=14.0.0
@angular/core >=14.0.0
rxjs >=7.0.0

Keywords

ota business-rules angular sdk api-client
Details
npm
2026-04-17 05:48:19 +00:00
0
Omeron
MIT
latest
15 KiB
Assets (1)
Versions (2) View all
1.0.1 2026-04-17
1.0.0 2026-04-16