Skip to content

Instantly share code, notes, and snippets.

@newerton
Created September 20, 2022 16:16
Show Gist options
  • Save newerton/3bf70bdd2c95bd075c2a5ab5478e50ff to your computer and use it in GitHub Desktop.
Save newerton/3bf70bdd2c95bd075c2a5ab5478e50ff to your computer and use it in GitHub Desktop.
import { Injectable } from '@nestjs/common';
import { Book } from '../../../core/entities';
import { IDataServices, ICrmServices } from '../../../core/abstracts';
import { CreateBookDto, UpdateBookDto } from '../../../core/dtos';
import { BookFactoryService } from './book-factory.service';
@Injectable()
export class BookServices {
constructor(
private dataServices: IDataServices,
private crmServices: ICrmServices,
) {}
async createBook(book: Book): Promise<Book> {
try {
// call to our dependencies
const createdBook = await this.dataServices.books.create(book);
await this.crmServices.bookAdded(createdBook);
return createdBook;
} catch (error) {
throw error;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment