import { Identification } from "../interfaces/identification.interface" ; import GraphQL from "./graphql" ; import { IDENTIFY } from "../queries/queries" ; export default class Identifier { constructor ( private graphql ) { } param channel param requester param message param provider public async identify ( channel , requester , message , provider ? ) { return this . graphql . client . query ( { query : IDENTIFY , variables : { channel , requester , message , provider } , } ) . then ( ( res ) => { const identification = res . data . identify ; return { ... identification , songs : identification . songs . map ( ( song ) => { return { ... song , artists : ( song . artists as string [ ] ) . reduce ( ( acc , current , index ) => { return index === 0 ? `${ current }` : index === ( song . artists as string [ ] ) . length - 1 ? `${ acc } and ${ current }` : `${ acc }, ${ current }` ; } , "" ) , } ; } ) , } ; } ) ; } }