diff --git a/src/MeetingOccurrence.php b/src/MeetingOccurrence.php index fd3f316..ce1b560 100644 --- a/src/MeetingOccurrence.php +++ b/src/MeetingOccurrence.php @@ -7,14 +7,16 @@ class MeetingOccurrence extends Model { protected $updateResource = 'MacsiDigital\Zoom\Requests\UpdateOccurrence'; - - protected $endPoint = 'meetings'; + + protected $endPoint = 'meetings/{meeting:id}'; protected $allowedMethods = ['find', 'get', 'patch', 'delete']; protected $apiDataField = ''; - protected $apiMultipleDataField = 'occurrences'; + protected $apiMultipleDataField = 'occurrences'; + + protected $primaryKey = 'occurrence_id'; public function registrants() { @@ -23,30 +25,30 @@ public function registrants() public function find($id) { - $occurence = $this->newQuery()->addQuery('occurrence_id', $id)->find($this->meeting_id); + $occurence = $this->newQuery()->addQuery('occurrence_id', $id)->getOne(); $occurence->meeting_id = $this->meeting_id; $occurence->occurrence_id = $id; return $occurence; } - public function beforeUpdating($query) + public function getPatchEndPoint() { - If(!$this->hasKey()){ - return false; - } - return $query->where('occurrence_id', $this->id); + if($this->hasCustomEndPoint('patch')){ + return $this->getCustomEndPoint('patch').$this->getKeyForEndPoint(); + } + return $this->endPoint.'?occurrence_id='.$this->getKey(); } - public function delete($scheduleForReminder=true) + public function getDeleteEndPoint() { - return $this->newQuery()->addQuery('schedule_for_reminder', $scheduleForReminder)->delete(); + if($this->hasCustomEndPoint('delete')){ + return $this->getCustomEndPoint('delete').$this->getKeyForEndPoint(); + } + return $this->endPoint.'?occurrence_id='.$this->getKey(); } - public function beforeDeleting($query) + public function delete($scheduleForReminder=true) { - If(!$this->hasKey()){ - return false; - } - return $query->where('occurrence_id', $this->id); + return $this->newQuery()->addQuery('schedule_for_reminder', $scheduleForReminder)->delete(); } } diff --git a/src/WebinarOccurrence.php b/src/WebinarOccurrence.php index 71351b2..c2e5367 100644 --- a/src/WebinarOccurrence.php +++ b/src/WebinarOccurrence.php @@ -7,14 +7,16 @@ class WebinarOccurrence extends Model { protected $updateResource = 'MacsiDigital\Zoom\Requests\UpdateOccurrence'; - + protected $endPoint = 'webinars/{webinar:id}'; protected $allowedMethods = ['find', 'get', 'patch', 'delete']; protected $apiDataField = ''; - protected $apiMultipleDataField = 'occurrences'; + protected $apiMultipleDataField = 'occurrences'; + + protected $primaryKey = 'occurrence_id'; public function registrants() { @@ -23,30 +25,31 @@ public function registrants() public function find($id) { - $occurence = $this->newQuery()->addQuery('occurrence_id', $id)->find($this->webinar_id); + $occurence = $this->newQuery()->addQuery('occurrence_id', $id)->getOne(); $occurence->webinar_id = $this->webinar_id; $occurence->occurrence_id = $id; return $occurence; } - public function beforeUpdating($query) + public function getPatchEndPoint() { - If(!$this->hasKey()){ - return false; + if($this->hasCustomEndPoint('patch')){ + return $this->getCustomEndPoint('patch').$this->getKeyForEndPoint(); } - return $query->where('occurrence_id', $this->id); + return $this->endPoint.'?occurrence_id='.$this->getKey(); } - public function delete($scheduleForReminder=true) + public function getDeleteEndPoint() { - return $this->newQuery()->addQuery('schedule_for_reminder', $scheduleForReminder)->delete(); + if($this->hasCustomEndPoint('delete')){ + return $this->getCustomEndPoint('delete').$this->getKeyForEndPoint(); + } + return $this->endPoint.'?occurrence_id='.$this->getKey(); } - public function beforeDeleting($query) + public function delete($scheduleForReminder=true) { - If(!$this->hasKey()){ - return false; - } - return $query->where('occurrence_id', $this->id); + return $this->newQuery()->addQuery('schedule_for_reminder', $scheduleForReminder)->delete(); } + }