Skip to content

Commit

Permalink
Extracts duplicated code to class method
Browse files Browse the repository at this point in the history
  • Loading branch information
craigpaul committed Nov 22, 2019
1 parent 43e250a commit 198022e
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/resources/appointment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,8 @@ export default class Appointment extends Conditional implements AppointmentResou
}

protected addParams(): AddAttendeeParameters | object {
const attendees = (this.relationships.attendees as AttendeeModel[]).map(
(attendee: AttendeeModel): object => {
return attendee.transform();
}
);

return {
data: attendees,
data: this.transformAttendees(),
}
}

Expand All @@ -281,17 +275,11 @@ export default class Appointment extends Conditional implements AppointmentResou
return {};
}

const attendees = (this.relationships.attendees as AttendeeModel[]).map(
(attendee: AttendeeModel): object => {
return attendee.transform();
},
);

let params: AppointmentParameters = {
data: {
relationships: {
attendees: {
data: attendees,
data: this.transformAttendees(),
},
},
type: 'appointments',
Expand Down Expand Up @@ -366,4 +354,12 @@ export default class Appointment extends Conditional implements AppointmentResou

return params;
}

protected transformAttendees() {
return (this.relationships.attendees as AttendeeModel[]).map(
(attendee: AttendeeModel): object => {
return attendee.transform();
}
);
}
}

0 comments on commit 198022e

Please sign in to comment.