@fleetbase/dev-engine
Version:
Fleetbase Developers extension provides a module for managing developer resources such as API keys, webhooks, sockets, events and logs.
99 lines (83 loc) • 2.74 kB
JavaScript
import Model, { attr, belongsTo } from '@ember-data/model';
import { computed } from '@ember/object';
import { format as formatDate, isValid as isValidDate, formatDistanceToNow } from 'date-fns';
export default class WebhookRequestLogModel extends Model {
/** @ids */
public_id;
company_uuid;
webhook_uuid;
api_credential_uuid;
api_event_uuid;
/** @relationships */
api_event;
/** @attributes */
method;
status_code;
reason_phrase;
url;
attempt;
duration;
response;
headers;
meta;
/** @dates */
sent_at;
deleted_at;
created_at;
updated_at;
/** @computed */
get result() {
return this.status_code.startsWith('2') ? 'succeeded' : 'failed';
}
get status() {
return `${this.status_code} ${this.reason_phrase}`;
}
get updatedAgo() {
if (!isValidDate(this.updated_at)) {
return null;
}
return formatDistanceToNow(this.updated_at);
}
get updatedAt() {
if (!isValidDate(this.updated_at)) {
return null;
}
return formatDate(this.updated_at, 'yyyy-MM-dd HH:mm');
}
get updatedAtShort() {
if (!isValidDate(this.updated_at)) {
return null;
}
return formatDate(this.updated_at, 'MMM dd, yyyy HH:mm');
}
get createdAgo() {
if (!isValidDate(this.created_at)) {
return null;
}
return formatDistanceToNow(this.created_at);
}
get createdAt() {
if (!isValidDate(this.created_at)) {
return null;
}
return formatDate(this.created_at, 'yyyy-MM-dd HH:mm');
}
get createdAtShort() {
if (!isValidDate(this.created_at)) {
return null;
}
return formatDate(this.created_at, 'MMM dd, yyyy HH:mm');
}
get sentAgo() {
if (!isValidDate(this.sent_at)) {
return null;
}
return formatDistanceToNow(this.sent_at);
}
get sentAt() {
if (!isValidDate(this.sent_at)) {
return null;
}
return formatDate(this.sent_at, 'yyyy-MM-dd HH:mm');
}
}