62 lines
2.3 KiB
Plaintext
62 lines
2.3 KiB
Plaintext
{{#apiInfo}}
|
|
{{#apis}}
|
|
{{#operations}}
|
|
import { Injectable } from '@angular/core';
|
|
import { Observable } from 'rxjs';
|
|
import { map } from 'rxjs/operators';
|
|
|
|
import { environment } from '@environment';
|
|
|
|
import { MRepository } from '@mercadona/core/utils/repository';
|
|
|
|
import { {{classname}}Repository } from '@/domain/repositories/{{classFilename}}.repository.contract';
|
|
{{#imports}}
|
|
import { {{classname}}Dto } from '@/dtos/{{classFilename}}.dto';
|
|
import { {{classname}} } from '@/entities/models/{{classFilename}}.model';
|
|
import { {{classVarName}}Mapper } from '@/mappers/{{classFilename}}.mapper';
|
|
{{/imports}}
|
|
|
|
/**
|
|
* {{classname}} Repository Implementation
|
|
* Generated from OpenAPI tag: {{classname}}
|
|
*/
|
|
@Injectable()
|
|
export class {{classname}}RepositoryImpl extends MRepository implements {{classname}}Repository {
|
|
constructor() {
|
|
super(`${environment.modapApi.url}`);
|
|
}
|
|
|
|
{{#operation}}
|
|
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{^-last}}, {{/-last}}{{/allParams}}): Observable<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
|
|
{{#isListContainer}}
|
|
return this.{{httpMethod}}<{{{returnBaseType}}}Dto>('{{path}}'{{#hasQueryParams}}, {
|
|
params: { {{#queryParams}}{{paramName}}{{^-last}}, {{/-last}}{{/queryParams}} }
|
|
}{{/hasQueryParams}}{{#hasBodyParam}}, {{bodyParam}}{{/hasBodyParam}})
|
|
.pipe(
|
|
map((response) => response.{{#vendorExtensions}}{{x-response-property}}{{/vendorExtensions}}{{^vendorExtensions}}items{{/vendorExtensions}}.map({{{returnBaseTypeVarName}}}Mapper))
|
|
);
|
|
{{/isListContainer}}
|
|
{{^isListContainer}}
|
|
{{#returnType}}
|
|
return this.{{httpMethod}}<{{{returnType}}}Dto>('{{path}}'{{#hasQueryParams}}, {
|
|
params: { {{#queryParams}}{{paramName}}{{^-last}}, {{/-last}}{{/queryParams}} }
|
|
}{{/hasQueryParams}}{{#hasBodyParam}}, {{bodyParam}}{{/hasBodyParam}})
|
|
.pipe(
|
|
map({{{returnTypeVarName}}}Mapper)
|
|
);
|
|
{{/returnType}}
|
|
{{^returnType}}
|
|
return this.{{httpMethod}}<void>('{{path}}'{{#hasQueryParams}}, {
|
|
params: { {{#queryParams}}{{paramName}}{{^-last}}, {{/-last}}{{/queryParams}} }
|
|
}{{/hasQueryParams}}{{#hasBodyParam}}, {{bodyParam}}{{/hasBodyParam}});
|
|
{{/returnType}}
|
|
{{/isListContainer}}
|
|
}
|
|
|
|
{{/operation}}
|
|
}
|
|
|
|
{{/operations}}
|
|
{{/apis}}
|
|
{{/apiInfo}}
|