Skip to content

Commit

Permalink
Routing form support
Browse files Browse the repository at this point in the history
  • Loading branch information
LoBrs committed Sep 23, 2022
1 parent 8e26404 commit 8920b3e
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 7 deletions.
36 changes: 36 additions & 0 deletions src/Models/RoutingForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace LoBrs\Calendly\Models;

use LoBrs\Calendly\Exceptions\ApiErrorException;
use LoBrs\Calendly\Exceptions\InvalidArgumentException;
use LoBrs\Calendly\Traits\Listable;
use LoBrs\Calendly\Traits\Timeable;
use LoBrs\Calendly\Utils\PaginatedList;

/**
* @property string $uri
* @property string $organization
* @property string $name
* @property array $questions
*/
class RoutingForm extends BaseModel
{
static string $resource = "routing_forms";

use Timeable;
use Listable;

/**
* View routing form submissions associated with the routing form's URI.
*
* @param array $options
* @return PaginatedList<RoutingFormSubmission>
* @throws ApiErrorException|InvalidArgumentException
*/
public function getRoutingFormSubmissions(array $options = []): PaginatedList {
return RoutingFormSubmission::paginate(array_merge([
"form" => $this->uri,
], $options));
}
}
25 changes: 25 additions & 0 deletions src/Models/RoutingFormSubmission.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace LoBrs\Calendly\Models;

use LoBrs\Calendly\Traits\Listable;
use LoBrs\Calendly\Traits\Timeable;

/**
* Routing form submission from users. Includes questions and answers.
*
* @property string $uri
* @property string $routing_form
* @property array $questions_and_answers
* @property $tracking
* @property $result
* @property string $submitter
* @property string $submitter_type
*/
class RoutingFormSubmission extends BaseModel
{
static string $resource = "routing_form_submissions";

use Timeable;
use Listable;
}
35 changes: 28 additions & 7 deletions src/Webhooks/WebhookSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,62 @@

namespace LoBrs\Calendly\Webhooks;

use LoBrs\Calendly\Exceptions\ApiErrorException;
use LoBrs\Calendly\Exceptions\InternalServerErrorException;
use LoBrs\Calendly\Exceptions\InvalidArgumentException;
use LoBrs\Calendly\Models\BaseModel;
use LoBrs\Calendly\Models\User;
use LoBrs\Calendly\Traits\Deletable;
use LoBrs\Calendly\Traits\Listable;
use LoBrs\Calendly\Traits\Postable;
use LoBrs\Calendly\Traits\Timeable;

/**
* Webhook Subscription Object
*
* @property string $uri
* @property string $callback_url
* @property string $retry_started_at
* @property string $state
* @property array $events
* @property string $scope
* @property string $callback_url The callback URL to use when the event is triggered
* @property string $retry_started_at The date and time the webhook subscription is retried
* @property string $state "active" or "disabled"
* @property array $events A list of events to which the webhook is subscribed
* @property string $scope user or organization
* @property string $organization
* @property string $user
* @property string $creator
* @property string $creator The URI of the user who created the webhook subscription
*/
class WebhookSubscription extends BaseModel
{
public static string $resource = "webhook_subscriptions";

const EVENT_INVITEE_CREATED = "invitee.created";
const EVENT_INVITEE_CANCELED = "invitee.canceled";
const EVENT_ROUTING_FORM_SUBMISSION_CREATED = "routing_form_submission.created";

use Listable;
use Postable;
use Timeable;
use Deletable;

public function getRetryStartedDate() {
/**
* @return \DateTime|null
*/
public function getRetryStartedDate(): ?\DateTime {
if (!empty($this->retry_started_at)) {
return new \DateTime($this->retry_started_at);
}

return null;
}

/**
* @return User|null
* @throws ApiErrorException|InternalServerErrorException|InvalidArgumentException
*/
public function getCreator(): ?User {
if (empty($this->creator)) {
return null;
}
return User::get($this->creator);
}

}

0 comments on commit 8920b3e

Please sign in to comment.