Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/sdk_generation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ jobs:
with:
php-version: "8.3"

- name: Setup yq
# scripts/generate.sh rewrites the spec with yq (mikefarah v4) before
# generation. Pin and verify the binary instead of relying on whatever
# the runner image ships; fail closed on checksum mismatch.
run: |
curl -fsSL -o /tmp/yq \
https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64
echo "a2c097180dd884a8d50c956ee16a9cec070f30a7947cf4ebf87d5f36213e9ed7 /tmp/yq" | sha256sum -c -
sudo install -m 0755 /tmp/yq /usr/local/bin/yq

- name: Regenerate client
run: ./scripts/generate.sh

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ use Convoy\Client\Model\ModelsCreateEvent;

$config = (new Configuration())
->setHost('https://us.getconvoy.cloud/api')
->setApiKeyPrefix('Authorization', 'Bearer')
->setApiKey('Authorization', $apiKey);
->setAccessToken($apiKey); // the client adds the Bearer prefix

// Pin the API version this client was generated from.
$http = new \GuzzleHttp\Client([
Expand Down
19 changes: 18 additions & 1 deletion scripts/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail
# (php), then sync it into src/Client/ without touching the hand-written SDK
# code (the rest of src/, incl. webhook verify).
#
# Requires: java 17+, rsync, curl. Run from the repo root.
# Requires: java 17+, rsync, curl, yq (mikefarah v4). Run from the repo root.

SPEC_URL="${SPEC_URL:-https://raw.githubusercontent.com/frain-dev/convoy/main/docs/v3/openapi3.yaml}"
# Pin so regeneration output is reproducible; bump deliberately.
Expand Down Expand Up @@ -33,6 +33,23 @@ echo "${GENERATOR_SHA256} ${GENERATOR_JAR}" | shasum -a 256 -c - >/dev/null ||

curl -fsSL "$SPEC_URL" -o "$tmp/openapi3.yaml"

# The spec marks portal link endpoints_metadata items nullable via
# {allOf: [{$ref: ...}], nullable: true} so strict clients tolerate [null]
# elements from the server. OpenAPI Generator's php generator mangles that
# wrapper into a namespace-less class reference (\ConvoyClientModel...), which
# breaks ObjectSerializer at runtime
# (https://github.com/OpenAPITools/openapi-generator/issues/23141). Unwrap the
# single-$ref nullable items back to a plain $ref before generation: the PHP
# runtime already tolerates null array elements (ObjectSerializer::deserialize
# returns null before instantiating the class), so nothing is lost. No-op when
# the spec stops using the wrapper shape.
yq -i '
(.components.schemas[] | select(has("properties")) | .properties[]
| select(has("items")) | .items
| select(has("allOf") and .nullable == true and (.allOf | length) == 1 and (.allOf[0] | has("$ref")))
) |= .allOf[0]
' "$tmp/openapi3.yaml"

java -jar "$GENERATOR_JAR" generate \
-i "$tmp/openapi3.yaml" \
-g php \
Expand Down
14 changes: 6 additions & 8 deletions src/Client/Api/DeliveryAttemptsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,9 @@ public function getDeliveryAttemptRequest($project_id, $event_delivery_id, $deli
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down Expand Up @@ -792,10 +791,9 @@ public function getDeliveryAttemptsRequest($project_id, $event_delivery_id, stri
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down
63 changes: 27 additions & 36 deletions src/Client/Api/EndpointsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,9 @@ public function activateEndpointRequest($project_id, $endpoint_id, string $conte
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down Expand Up @@ -792,10 +791,9 @@ public function createEndpointRequest($project_id, $models_create_endpoint, stri
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down Expand Up @@ -1127,10 +1125,9 @@ public function deleteEndpointRequest($project_id, $endpoint_id, string $content
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down Expand Up @@ -1481,10 +1478,9 @@ public function expireSecretRequest($project_id, $endpoint_id, $models_expire_se
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down Expand Up @@ -1816,10 +1812,9 @@ public function getEndpointRequest($project_id, $endpoint_id, string $contentTyp
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down Expand Up @@ -2236,10 +2231,9 @@ public function getEndpointsRequest($project_id, $direction = null, $next_page_c
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down Expand Up @@ -2571,10 +2565,9 @@ public function pauseEndpointRequest($project_id, $endpoint_id, string $contentT
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down Expand Up @@ -2905,10 +2898,9 @@ public function testOAuth2ConnectionRequest($project_id, $models_test_o_auth2_re
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down Expand Up @@ -3259,10 +3251,9 @@ public function updateEndpointRequest($project_id, $endpoint_id, $models_update_
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down
35 changes: 15 additions & 20 deletions src/Client/Api/EventDeliveriesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,10 +621,9 @@ public function batchRetryEventDeliveryRequest($project_id, $direction = null, $
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down Expand Up @@ -955,10 +954,9 @@ public function forceResendEventDeliveriesRequest($project_id, $models_ids, stri
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down Expand Up @@ -1465,10 +1463,9 @@ public function getEventDeliveriesPagedRequest($project_id, $direction = null, $
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down Expand Up @@ -1800,10 +1797,9 @@ public function getEventDeliveryRequest($project_id, $event_delivery_id, string
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down Expand Up @@ -2135,10 +2131,9 @@ public function resendEventDeliveryRequest($project_id, $event_delivery_id, stri
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down
35 changes: 15 additions & 20 deletions src/Client/Api/EventTypesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,9 @@ public function createEventTypeRequest($project_id, $models_create_event_type, s
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down Expand Up @@ -780,10 +779,9 @@ public function deprecateEventTypeRequest($project_id, $event_type_id, string $c
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down Expand Up @@ -1095,10 +1093,9 @@ public function getEventTypesRequest($project_id, string $contentType = self::co
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down Expand Up @@ -1429,10 +1426,9 @@ public function importOpenApiSpecRequest($project_id, $models_import_open_api_sp
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down Expand Up @@ -1783,10 +1779,9 @@ public function updateEventTypeRequest($project_id, $event_type_id, $models_upda
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
if ($apiKey !== null) {
$headers['Authorization'] = $apiKey;
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
Expand Down
Loading