module.exports = Self => {
    Self.remoteMethodCtx('invoiceInEmail', {
        description: 'Sends the invoice in email with an attached PDF',
        accessType: 'WRITE',
        accepts: [
            {
                arg: 'id',
                type: 'number',
                required: true,
                description: 'The invoice id',
                http: {source: 'path'}
            },
            {
                arg: 'recipient',
                type: 'string',
                description: 'The recipient email',
                required: true,
            },
            {
                arg: 'recipientId',
                type: 'number',
                description: 'The recipient id to send to the recipient preferred language',
                required: false
            }
        ],
        returns: {
            type: ['object'],
            root: true
        },
        http: {
            path: '/:id/invoice-in-email',
            verb: 'POST'
        }
    });

    Self.invoiceInEmail = ctx => Self.sendTemplate(ctx, 'invoiceIn');
};