All files / src/app/core/services/promotions promotions.service.ts

77.77% Statements 7/9
60% Branches 3/5
66.66% Functions 2/3
87.5% Lines 7/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2719x 19x     19x     19x 2x                 1x       1x          
import { Injectable } from '@angular/core';
import { Observable, throwError } from 'rxjs';
 
import { Promotion } from 'ish-core/models/promotion/promotion.model';
import { ApiService } from 'ish-core/services/api/api.service';
 
@Injectable({ providedIn: 'root' })
export class PromotionsService {
  constructor(private apiService: ApiService) {}
 
  /**
   * Get the full Promotion data for the given Promotion ID.
   *
   * @param id  The Promotion ID for the promotion of interest.
   * @returns    The Promotion data.
   */
  getPromotion(id: string): Observable<Promotion> {
    Iif (!id) {
      return throwError(() => new Error('getPromotion() called without a id'));
    }
 
    return this.apiService.get<Promotion>(`promotions/${this.apiService.encodeResourceId(id)}`, {
      sendSPGID: true,
    });
  }
}