Skip to content

Commit

Permalink
feat: fix linting violations
Browse files Browse the repository at this point in the history
  • Loading branch information
skoch-intershop committed Jul 29, 2022
1 parent 220385a commit 25ea52a
Show file tree
Hide file tree
Showing 33 changed files with 449 additions and 409 deletions.
4 changes: 2 additions & 2 deletions src/app/core/configuration.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { NgModule } from '@angular/core';

import { SPECIAL_HTTP_ERROR_HANDLER } from './interceptors/icm-error-mapper.interceptor';
import { createPaymentErrorHandler } from './utils/http-error/create-payment.error-handler';
import { dataRequestErrorHandler } from './utils/http-error/data-request.error-handler';
import { editPasswordErrorHandler } from './utils/http-error/edit-password.error-handler';
import { gdprDataRequestErrorHandler } from './utils/http-error/gdpr-data-request.error-handler';
import { LoginUserErrorHandler } from './utils/http-error/login-user.error-handler';
import { requestReminderErrorHandler } from './utils/http-error/request-reminder.error-handler';
import { updatePasswordErrorHandler } from './utils/http-error/update-password.error-handler';
Expand All @@ -13,7 +13,7 @@ import { updatePasswordErrorHandler } from './utils/http-error/update-password.e
{ provide: SPECIAL_HTTP_ERROR_HANDLER, useValue: updatePasswordErrorHandler, multi: true },
{ provide: SPECIAL_HTTP_ERROR_HANDLER, useClass: LoginUserErrorHandler, multi: true },
{ provide: SPECIAL_HTTP_ERROR_HANDLER, useValue: requestReminderErrorHandler, multi: true },
{ provide: SPECIAL_HTTP_ERROR_HANDLER, useValue: dataRequestErrorHandler, multi: true },
{ provide: SPECIAL_HTTP_ERROR_HANDLER, useValue: gdprDataRequestErrorHandler, multi: true },
{ provide: SPECIAL_HTTP_ERROR_HANDLER, useValue: editPasswordErrorHandler, multi: true },
{ provide: SPECIAL_HTTP_ERROR_HANDLER, useValue: createPaymentErrorHandler, multi: true },
],
Expand Down
24 changes: 12 additions & 12 deletions src/app/core/facades/account.facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { map, switchMap, take, tap } from 'rxjs/operators';
import { Address } from 'ish-core/models/address/address.model';
import { Credentials } from 'ish-core/models/credentials/credentials.model';
import { Customer, CustomerRegistrationType, SsoRegistrationType } from 'ish-core/models/customer/customer.model';
import { DataRequest } from 'ish-core/models/data-request/data-request.model';
import { GDPRDataRequest } from 'ish-core/models/gdpr-data-request/gdpr-data-request.model';
import { HttpError } from 'ish-core/models/http-error/http-error.model';
import { PasswordReminderUpdate } from 'ish-core/models/password-reminder-update/password-reminder-update.model';
import { PasswordReminder } from 'ish-core/models/password-reminder/password-reminder.model';
Expand Down Expand Up @@ -53,12 +53,12 @@ import {
updateUserPassword,
updateUserPasswordByPasswordReminder,
} from 'ish-core/store/customer/user';
import { confirmDataRequest } from 'ish-core/store/general/data-request/data-request.actions';
import { gdprConfirmDataRequest } from 'ish-core/store/general/gdpr-data-request/gdpr-data-request.actions';
import {
getDataRequestError,
getDataRequestLoading,
getDataRequest,
} from 'ish-core/store/general/data-request/data-request.selectors';
getGDPRDataRequestError,
getGDPRDataRequestLoading,
isFirstTime,
} from 'ish-core/store/general/gdpr-data-request/gdpr-data-request.selectors';
import { whenTruthy } from 'ish-core/utils/operators';

/* eslint-disable @typescript-eslint/member-ordering */
Expand All @@ -73,14 +73,14 @@ export class AccountFacade {
store.pipe(select(getUserError)).subscribe(this.internalUserError$);
}

// confirmation data request
// confirmation gdpr data request

confirmationLoading$ = this.store.pipe(select(getDataRequestLoading));
confirmationError$ = this.store.pipe(select(getDataRequestError));
gdprConfirmationLoading$ = this.store.pipe(select(getGDPRDataRequestLoading));
gdprConfirmationError$ = this.store.pipe(select(getGDPRDataRequestError));
isFirstTime$ = this.store.pipe(select(isFirstTime));

confirmDataRequest(data: DataRequest) {
this.store.dispatch(confirmDataRequest({ data }));
return this.store.pipe(select(getDataRequest));
confirmGDPRDataRequest(data: GDPRDataRequest) {
this.store.dispatch(gdprConfirmDataRequest({ data }));
}

// USER
Expand Down
18 changes: 0 additions & 18 deletions src/app/core/models/data-request/data-request.interface.ts

This file was deleted.

20 changes: 0 additions & 20 deletions src/app/core/models/data-request/data-request.mapper.spec.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/app/core/models/data-request/data-request.mapper.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/app/core/models/data-request/data-request.model.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* response data type for confirm data request
*/
export interface GDPRDataRequestData {
data?: [
{
hash: string;
}
];
infos?: GDPRDataRequestInfo[];
}

export interface GDPRDataRequestInfo {
causes?: GDPRDataRequestCauses[];
}

interface GDPRDataRequestCauses {
code: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { GDPRDataRequestData, GDPRDataRequestInfo } from './gdpr-data-request.interface';
import { GDPRDataRequestMapper } from './gdpr-data-request.mapper';
import { GDPRDataRequest } from './gdpr-data-request.model';

describe('Gdpr Data Request Mapper', () => {
describe('fromData', () => {
it(`should return DataRequest when getting DataRequestData with request id`, () => {
const payloadData = {
infos: [{ causes: [{ code: 'already confirmed' }] } as GDPRDataRequestInfo],
} as GDPRDataRequestData;
const requestData = { hash: 'test_hash', requestID: 'test_ID' } as GDPRDataRequest;
const dataRequest = GDPRDataRequestMapper.fromData(payloadData, requestData);

expect(dataRequest.requestID).toEqual(requestData.requestID);
expect(dataRequest.hash).toEqual(requestData.hash);
expect(dataRequest.status).toEqual('already confirmed');
});
});
});
15 changes: 15 additions & 0 deletions src/app/core/models/gdpr-data-request/gdpr-data-request.mapper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { GDPRDataRequestData } from './gdpr-data-request.interface';
import { GDPRDataRequest } from './gdpr-data-request.model';

export class GDPRDataRequestMapper {
/**
* Map data request payload to data request model
*/
static fromData(payload: GDPRDataRequestData, requestData: GDPRDataRequest): GDPRDataRequest {
return {
requestID: requestData.requestID,
hash: requestData.hash,
status: payload.infos[0].causes[0].code,
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface GDPRDataRequest {
requestID: string;
hash: string;
status?: string;
}
21 changes: 12 additions & 9 deletions src/app/core/services/user/user.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import { Address } from 'ish-core/models/address/address.model';
import { Credentials } from 'ish-core/models/credentials/credentials.model';
import { CustomerData } from 'ish-core/models/customer/customer.interface';
import { Customer, CustomerRegistrationType, CustomerUserType } from 'ish-core/models/customer/customer.model';
import { DataRequestData, DataRequestInfo } from 'ish-core/models/data-request/data-request.interface';
import { DataRequest } from 'ish-core/models/data-request/data-request.model';
import {
GDPRDataRequestData,
GDPRDataRequestInfo,
} from 'ish-core/models/gdpr-data-request/gdpr-data-request.interface';
import { GDPRDataRequest } from 'ish-core/models/gdpr-data-request/gdpr-data-request.model';
import { User } from 'ish-core/models/user/user.model';
import { ApiService, AvailableOptions } from 'ish-core/services/api/api.service';
import { getUserPermissions } from 'ish-core/store/customer/authorization';
Expand Down Expand Up @@ -374,10 +377,10 @@ describe('User Service', () => {
it('should return an error when called with undefined', done => {
when(apiServiceMock.put(anything(), anything())).thenReturn(of({}));

userService.confirmDataRequest(undefined).subscribe({
userService.confirmGDPRDataRequest(undefined).subscribe({
next: fail,
error: err => {
expect(err).toMatchInlineSnapshot(`[Error: confirmDataRequest() called without data body]`);
expect(err).toMatchInlineSnapshot(`[Error: confirmGDPRDataRequest() called without data body]`);
done();
},
});
Expand All @@ -389,17 +392,17 @@ describe('User Service', () => {
const requestData = {
requestID: 'test_ID',
hash: 'test_hash',
} as DataRequest;
} as GDPRDataRequest;
const payloadData = {
infos: [{ status: 200, code: 'already confirmed' } as DataRequestInfo],
} as DataRequestData;
infos: [{ causes: [{ code: 'already confirmed' }] } as GDPRDataRequestInfo],
} as GDPRDataRequestData;

when(apiServiceMock.put(anything(), anything(), anything())).thenReturn(of(payloadData));

userService.confirmDataRequest(requestData).subscribe(payload => {
userService.confirmGDPRDataRequest(requestData).subscribe(payload => {
verify(apiServiceMock.put('gdpr-requests/test_ID/confirmations', anything(), anything())).once();
expect(capture(apiServiceMock.put).last()[0]).toMatchInlineSnapshot(`"gdpr-requests/test_ID/confirmations"`);
expect(payload).toHaveProperty('status', payloadData.infos[0].status);
expect(payload).toHaveProperty('status', 'already confirmed');
done();
});
});
Expand Down
14 changes: 7 additions & 7 deletions src/app/core/services/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import {
CustomerRegistrationType,
CustomerUserType,
} from 'ish-core/models/customer/customer.model';
import { DataRequestData } from 'ish-core/models/data-request/data-request.interface';
import { DataRequestMapper } from 'ish-core/models/data-request/data-request.mapper';
import { DataRequest } from 'ish-core/models/data-request/data-request.model';
import { GDPRDataRequestData } from 'ish-core/models/gdpr-data-request/gdpr-data-request.interface';
import { GDPRDataRequestMapper } from 'ish-core/models/gdpr-data-request/gdpr-data-request.mapper';
import { GDPRDataRequest } from 'ish-core/models/gdpr-data-request/gdpr-data-request.model';
import { PasswordReminderUpdate } from 'ish-core/models/password-reminder-update/password-reminder-update.model';
import { PasswordReminder } from 'ish-core/models/password-reminder/password-reminder.model';
import { UserCostCenter } from 'ish-core/models/user-cost-center/user-cost-center.model';
Expand Down Expand Up @@ -330,22 +330,22 @@ export class UserService {
* @param data The DataRequest model includes request id and hash.
* @returns The enriched DataRequest model includes additional response status and code of the request.
*/
confirmDataRequest(data: DataRequest): Observable<DataRequest> {
confirmGDPRDataRequest(data: GDPRDataRequest): Observable<GDPRDataRequest> {
if (!data) {
return throwError(() => new Error('confirmDataRequest() called without data body'));
return throwError(() => new Error('confirmGDPRDataRequest() called without data body'));
}

const dataRequestHeaderV1 = new HttpHeaders()
.set('content-type', 'application/json')
.set('Accept', 'application/vnd.intershop.gdpr.v1+json');

return this.apiService
.put<DataRequestData>(
.put<GDPRDataRequestData>(
`gdpr-requests/${data.requestID}/confirmations`,
{ hash: data.hash },
{ headers: dataRequestHeaderV1 }
)
.pipe(map(payload => DataRequestMapper.fromData(payload, data)));
.pipe(map(payload => GDPRDataRequestMapper.fromData(payload, data)));
}

/**
Expand Down
13 changes: 0 additions & 13 deletions src/app/core/store/general/data-request/data-request.actions.ts

This file was deleted.

This file was deleted.

Loading

1 comment on commit 25ea52a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Azure Demo Servers are available:

Please sign in to comment.