Skip to content

Service Ordering Management API

This API provides Service Order Management capabilities through a REST API interface, following the TMF641 standard.

Installation

npm install @dnext-angular/service-ordering

Setup

Import the required modules and services in your Angular application:

import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { 
  ServiceOrderService,
  CancelServiceOrderService 
} from '@dnext-angular/service-ordering';

@NgModule({
  imports: [
    HttpClientModule
  ],
  providers: [
    ServiceOrderService,
    CancelServiceOrderService
  ]
})
export class AppModule { }

Configuration

Configure your environment with the service ordering API endpoint:

// environment.ts
export const environment = {
  serviceOrderingManagementApi: 'https://api.example.com/service-ordering'
};

Services

ServiceOrderService

Handles service order operations including creation, retrieval, updates, and deletion.

Methods

  • createServiceOrder()
  • retrieveServiceOrder()
  • listServiceOrder()
  • patchServiceOrder()
  • deleteServiceOrder()

CancelServiceOrderService

Manages service order cancellation operations.

Methods

  • createCancelOrder()
  • retrieveCancelOrder()
  • listCancelOrder()

Implementation Examples

1. Service Order Management Component

import { Component } from '@angular/core';
import { 
  ServiceOrderService,
  ServiceOrderCreate,
  ServiceOrder 
} from '@dnext-angular/service-ordering';

@Component({
  selector: 'app-service-order',
  template: `
    <div>
      <h2>Service Orders</h2>
      <button (click)="createOrder()">Create Order</button>
      <button (click)="listOrders()">List Orders</button>
    </div>
  `
})
export class ServiceOrderComponent {
  constructor(private serviceOrderService: ServiceOrderService) {}

  createOrder() {
    const newOrder: ServiceOrderCreate = {
      orderDate: new Date(),
      requestedStartDate: new Date(),
      requestedCompletionDate: new Date(),
      orderItem: [{
        action: 'add',
        id: '1',
        service: {
          name: 'Internet Service',
          state: 'active'
        }
      }]
    };

    this.serviceOrderService.createServiceOrder(newOrder)
      .subscribe({
        next: (response) => {
          console.log('Order created:', response);
        },
        error: (error) => {
          console.error('Error creating order:', error);
        }
      });
  }

  listOrders() {
    this.serviceOrderService.listServiceOrder()
      .subscribe({
        next: (orders) => {
          console.log('Orders:', orders);
        },
        error: (error) => {
          console.error('Error listing orders:', error);
        }
      });
  }
}

2. Cancel Service Order Component

import { Component } from '@angular/core';
import { 
  CancelServiceOrderService,
  CancelServiceOrderCreate 
} from '@dnext-angular/service-ordering';

@Component({
  selector: 'app-cancel-order',
  template: `
    <div>
      <h2>Cancel Service Order</h2>
      <button (click)="cancelOrder()">Cancel Order</button>
    </div>
  `
})
export class CancelOrderComponent {
  constructor(private cancelOrderService: CancelServiceOrderService) {}

  cancelOrder() {
    const cancelRequest: CancelServiceOrderCreate = {
      cancellationReason: 'Customer request',
      requestedCancellationDate: new Date(),
      serviceOrder: {
        id: 'order-123',
        href: '/serviceOrder/order-123'
      }
    };

    this.cancelOrderService.createCancelOrder(cancelRequest)
      .subscribe({
        next: (response) => {
          console.log('Cancellation request created:', response);
        },
        error: (error) => {
          console.error('Error creating cancellation:', error);
        }
      });
  }
}

3. Service Order Module

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ServiceOrderComponent } from './service-order.component';
import { CancelOrderComponent } from './cancel-order.component';
import { ServiceOrderRoutingModule } from './service-order-routing.module';

@NgModule({
  imports: [
    CommonModule,
    ServiceOrderRoutingModule
  ],
  declarations: [
    ServiceOrderComponent,
    CancelOrderComponent
  ],
  providers: [
    ServiceOrderService,
    CancelServiceOrderService
  ]
})
export class ServiceOrderModule { }

4. Error Handling Service

import { Injectable } from '@angular/core';
import { HttpErrorResponse } from '@angular/common/http';
import { throwError } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class ServiceOrderErrorHandler {
  handleError(error: HttpErrorResponse) {
    let errorMessage = 'An unknown error occurred!';

    if (error.error instanceof ErrorEvent) {
      errorMessage = `Error: ${error.error.message}`;
    } else {
      errorMessage = `Error Code: ${error.status}\nMessage: ${error.message}`;
    }

    console.error(errorMessage);
    return throwError(() => new Error(errorMessage));
  }
}

Dependencies

  • @angular/core: >=18.0.1
  • @angular/common: >=18.0.1
  • @dnext-angular/http: 1.2.2
  • @dnext-angular/common: 1.1.1
  • rxjs: ^7.0.0

License

DNext PiAGroup