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 27 28 29 30 31 32 33 34 35 | 3x 3x 3x 3x 3x 2x 1x 1x 1x 1x | import { Injectable } from '@angular/core';
import { pick } from 'lodash-es';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { Contact } from 'ish-core/models/contact/contact.model';
import { ApiService, AvailableOptions, unpackEnvelope } from 'ish-core/services/api/api.service';
@Injectable({ providedIn: 'root' })
export class ContactService {
constructor(private apiService: ApiService) {}
/**
* Get the possible contact subjects, which the customer can select for his request
*/
getContactSubjects(): Observable<string[]> {
return this.apiService.get(`contact`).pipe(
unpackEnvelope<{ type: string; subject: string }>(),
map(el => el.map(e => e.subject))
);
}
/**
* Send contact us request, when a customer want to get in contact with the shop
*/
createContactRequest(contactData: Contact): Observable<void> {
const options: AvailableOptions = {
skipApiErrorHandling: true,
captcha: pick(contactData, ['captcha', 'captchaAction']),
};
return this.apiService.post(`contact`, { ...contactData, captcha: undefined, captchaAction: undefined }, options);
}
}
|