@omeron/ota-bre-angular-sdk (1.0.0)
Published 2026-04-16 17:05:42 +00:00 by omeron-admin
Installation
@omeron:registry=npm install @omeron/ota-bre-angular-sdk@1.0.0"@omeron/ota-bre-angular-sdk": "1.0.0"About this package
@omeron/ota-bre-angular-sdk
Angular SDK for OTA Business Rules Engine API
Installation
npm install @omeron/ota-bre-angular-sdk
Setup
1. Import Module
import { NgModule } from '@angular/core';
import { OtaBreModule } from '@omeron/ota-bre-angular-sdk';
@NgModule({
imports: [
OtaBreModule.forRoot({
apiUrl: 'http://localhost:8081/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 tokenlogout()- Logout and clear tokensrefreshToken()- Refresh access tokengetCurrentUser()- Get current user detailsisAuthenticated()- Check if user is authenticatedsetDomain(domainId)- Switch current domaingetCurrentDomainId()- Get current domain ID
DomainService
findAll(params?)- Get all domains with paginationfindById(id)- Get domain by IDcreate(domain)- Create new domainupdate(id, domain)- Update domaindelete(id)- Delete domaingetConnectorSettings(id)- Get domain connector settingsupdateConnectorSettings(id, settings)- Update connector settingstestSftpConnection(id, settings)- Test SFTP connection
GfsRuleService
findAll(params?)- Get all GFS rules with paginationfindById(id)- Get rule by IDcreate(rule)- Create new ruleupdate(id, rule)- Update ruledelete(id)- Delete ruleupdateSequence(id, sequence)- Update rule sequenceenable(id)- Enable ruledisable(id)- Disable rule
PartnerService
findAll(params?)- Get all partnersfindById(id)- Get partner by IDcreate(partner)- Create new partnerupdate(id, partner)- Update partnerdelete(id)- Delete partner
ApiKeyService
findAll()- Get all API keyscreate(name, expiresAt?)- Create new API keyrevoke(id)- Revoke API keyenable(id)- Enable API keydisable(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 IDcreateBooking(request, domainId?)- Create a new bookingcancelBooking(pnrId, statusChange?, domainId?)- Cancel a bookingvoidBooking(pnrId, reason?, domainId?)- Void a bookingrefundBooking(pnrId, statusChange?, domainId?)- Refund a bookingexchangeBooking(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.00,
total_cost: 1100.00
}
};
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.00,
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 tokenota_bre_refresh_token- Refresh tokenota_bre_domain_id- Current domain ID
All API requests automatically include:
Authorization: Bearer <token>headerX-Domain-IDheader (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