import { DirectParseProvider } from '../provider/BaseProvider' ; import gravatar from 'gravatar' ; /**
 * https://devcenter.heroku.com/articles/app-webhooks
 */ export class Heroku extends DirectParseProvider { public getName ( ) { return 'Heroku' ; } public async parseData ( ) { this . setEmbedColor ( 0xC9C3E6 ) ; const action = this . actionAsPastTense ( this . body . action ) ; const type = this . typeAsReadable ( this . body . webhook_metadata . event . include ) ; const authorName = this . body . actor . email ; let name = this . body . data . name ; if ( name == null ) { name = this . body . data . app . name ; } this . addEmbed ( { title : `${ authorName } ${ action } ${ type }. App: ${ name }` , url : this . body . data . web_url , author : { name : authorName , icon_url : gravatar . url ( this . body . actor . email , { s : '100' , r : 'x' , d : 'retro' } , true ) } , } ) ; } private actionAsPastTense ( action ) { switch ( action ) { case 'create' : return 'created' ; case 'destroy' : return 'destroyed' ; case 'update' : return 'updated' ; } return 'unknown' ; } private typeAsReadable ( type ) { return type . split ( 'api:' ) [ 1 ] ; } }