This repository was archived by the owner on Jul 20, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorder.service.ts
More file actions
42 lines (36 loc) · 1.29 KB
/
Copy pathorder.service.ts
File metadata and controls
42 lines (36 loc) · 1.29 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
import { AccountService } from './account.service';
@Injectable({
providedIn: 'root'
})
export class OrderService {
private apiUrl = '/api/v1';
constructor(private http: HttpClient, private accountService: AccountService) {}
private get authHeaders(): HttpHeaders {
return new HttpHeaders({
'Authorization': `Bearer ${this.accountService.token}`
});
}
placeOrder(order: any): Observable<{ success: boolean; message: string; data: { id: number } }> {
return this.http.post<{ success: boolean; message: string; data: { id: number } }>(
`${this.apiUrl}/invoices`,
order,
{ headers: this.authHeaders }
);
}
updateInvoiceStatus(id: number, status: string): Observable<{ success: boolean; message: string }> {
return this.http.put<{ success: boolean; message: string }>(
`${this.apiUrl}/invoices/${id}`,
{ status },
{ headers: this.authHeaders }
);
}
getInvoices(): Observable<{ success: boolean; message: string; data: any[] }> {
return this.http.get<{ success: boolean; message: string; data: any[] }>(
`${this.apiUrl}/invoices`,
{ headers: this.authHeaders }
);
}
}