Skip to content

Commit f5aa472

Browse files
authored
Merge pull request #7 from knocklabs/jazambuja-kno-3536-php-sdk-add-schedules-support
feat(kno-3536): add support for schedules API
2 parents 5f7606e + ca3e7f0 commit f5aa472

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

src/Api/Objects.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ public function getMessages(string $collection, string $objectId, array $params
3838
return $this->getRequest($url, $params, $headers);
3939
}
4040

41+
/**
42+
* @param string $collection
43+
* @param string $objectId
44+
* @param array $params
45+
* @param array $headers
46+
* @return array
47+
* @throws Exception
48+
*/
49+
public function getSchedules(string $collection, string $objectId, array $params = [], array $headers = []): array
50+
{
51+
$url = $this->url('/objects/%s/%s/schedules', $collection, $objectId);
52+
53+
return $this->getRequest($url, $params, $headers);
54+
}
55+
4156
/**
4257
* @param string $collection
4358
* @param string $objectId

src/Api/Users.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ public function getMessages(string $userId, array $params = [], array $headers =
5151
return $this->getRequest($url, $params, $headers);
5252
}
5353

54+
/**
55+
* @param string $userId
56+
* @param array $params
57+
* @param array $headers
58+
* @return array
59+
* @throws Exception
60+
*/
61+
public function getSchedules(string $userId, array $params = [], array $headers = []): array
62+
{
63+
$url = $this->url('/users/%s/schedules', $userId);
64+
65+
return $this->getRequest($url, $params, $headers);
66+
}
67+
5468
/**
5569
* @param string $userId
5670
* @param array $body

src/Api/Workflows.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,63 @@ public function cancel(string $key, array $body, array $headers = [])
3333

3434
return $this->postRequest($url, $body, $headers);
3535
}
36+
37+
/**
38+
* @param string $key
39+
* @param array $schedule_attrs
40+
* @param array $headers
41+
* @return array
42+
* @throws Exception
43+
*/
44+
public function createSchedules(string $key, array $schedule_attrs, array $headers = []): array
45+
{
46+
$url = $this->url('/schedules');
47+
$schedule_attrs['workflow'] = $key;
48+
49+
return $this->postRequest($url, $schedule_attrs, $headers);
50+
}
51+
52+
/**
53+
* @param array $schedule_ids
54+
* @param array $schedule_attrs
55+
* @param array $headers
56+
* @return array
57+
* @throws Exception
58+
*/
59+
public function updateSchedules(array $schedule_ids, array $schedule_attrs, array $headers = []): array
60+
{
61+
$url = $this->url('/schedules');
62+
$schedule_attrs['schedule_ids'] = $schedule_ids;
63+
64+
return $this->putRequest($url, $schedule_attrs, $headers);
65+
}
66+
67+
/**
68+
* @param array $schedule_ids
69+
* @param array $headers
70+
* @return array
71+
* @throws Exception
72+
*/
73+
public function deleteSchedules(array $schedule_ids, array $headers = []): array
74+
{
75+
$url = $this->url('/schedules');
76+
$body = ['schedule_ids' => $schedule_ids];
77+
78+
return $this->deleteRequest($url, $body, $headers);
79+
}
80+
81+
/**
82+
* @param string $key
83+
* @param array $params
84+
* @param array $headers
85+
* @return array
86+
* @throws Exception
87+
*/
88+
public function listSchedules(string $key, array $params = [], array $headers = []): array
89+
{
90+
$params['workflow'] = $key;
91+
$url = $this->url('/schedules');
92+
93+
return $this->getRequest($url, $params, $headers);
94+
}
3695
}

0 commit comments

Comments
 (0)