Created
September 20, 2022 16:16
-
-
Save newerton/3bf70bdd2c95bd075c2a5ab5478e50ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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