bootdesk/chat-sdk

GitHubAdapter
in package
implements Adapter, HandlesSlashCommands, HasAuthorInfo, SupportsDeleteMessages, SupportsEditMessages

Table of Contents

Interfaces

Adapter
HandlesSlashCommands
HasAuthorInfo
SupportsDeleteMessages
SupportsEditMessages

Constants

EMOJI_MAP  : mixed = ['👍' => '+1', '+1' => '+1', 'thumbs_up' => '+1'...

Properties

$apiUrl  : string
$appId  : string|null
$authToken  : string|null
$botUserId  : string|null
$fileUploadConverter  : FileUploadConverter
$formatConverter  : GitHubFormatConverter
$httpClient  : ClientInterface
$installationId  : string|null
$installationIds  : array<string, string>
$installationTokenCache  : array<string, array{token: string, expiresAt: int}>
$privateKey  : string|null
$psrFactory  : Psr17Factory|null
$webhookVerifier  : GitHubWebhookVerifier

Methods

__construct()  : mixed
addReaction()  : void
channelIdFromThreadId()  : string
createResponse()  : ResponseInterface|null
decodeThreadId()  : mixed
deleteMessage()  : void
disconnect()  : void
editMessage()  : SentMessage
encodeThreadId()  : string
fetchChannelInfo()  : ChannelInfo|null
fetchMessages()  : FetchResult
fetchThread()  : ThreadInfo
getAuthorInfo()  : Author
getBotUserId()  : string|null
getFormatConverter()  : FormatConverter|null
getName()  : string
getUser()  : UserInfo|null
initialize()  : void
openDM()  : string|null
parseSlashCommand()  : Author, command: string, text: string, userId: string, isBot: bool, isMe: bool, channelId: string, triggerId: ?string, raw: mixed}|null
parseWebhook()  : Message
postMessage()  : SentMessage
removeReaction()  : void
startTyping()  : void
stream()  : SentMessage|null
verifyWebhook()  : ResponseInterface|null
apiCall()  : array<string|int, mixed>
appendAttachments()  : string
base64urlEncode()  : string
deriveChannelId()  : string
exchangeInstallationToken()  : array<string|int, mixed>
generateJWT()  : string
getAuthToken()  : string
getInstallationToken()  : string
jsonResponse()  : ResponseInterface
parseIssueComment()  : Message
parseReviewComment()  : Message
renderBody()  : string

Constants

EMOJI_MAP

protected mixed EMOJI_MAP = ['👍' => '+1', '+1' => '+1', 'thumbs_up' => '+1', '👎' => '-1', '-1' => '-1', 'thumbs_down' => '-1', '😄' => 'laugh', 'laugh' => 'laugh', 'smile' => 'laugh', '😕' => 'confused', 'confused' => 'confused', 'thinking' => 'confused', '❤️' => 'heart', 'heart' => 'heart', 'love_eyes' => 'heart', '🎉' => 'hooray', 'hooray' => 'hooray', 'party' => 'hooray', 'confetti' => 'hooray', '🚀' => 'rocket', 'rocket' => 'rocket', '👀' => 'eyes', 'eyes' => 'eyes']

Properties

$apiUrl read-only

protected string $apiUrl = 'https://api.github.com'

$authToken read-only

protected string|null $authToken = null

$installationId read-only

protected string|null $installationId = null

$installationIds

protected array<string, string> $installationIds = []

owner/repo → installation ID

$installationTokenCache

protected array<string, array{token: string, expiresAt: int}> $installationTokenCache = []

installation ID → cached token

$privateKey read-only

protected string|null $privateKey = null

$psrFactory read-only

protected Psr17Factory|null $psrFactory = null

Methods

__construct()

public __construct(ClientInterface $httpClient, string $webhookSecret[, string|null $authToken = null ][, string $apiUrl = 'https://api.github.com' ][, string|null $appId = null ][, string|null $installationId = null ][, Psr17Factory|null $psrFactory = null ][, FileUploadConverter|null $fileUploadConverter = null ][, string|null $privateKey = null ]) : mixed
Parameters
$httpClient : ClientInterface
$webhookSecret : string
$authToken : string|null = null
$apiUrl : string = 'https://api.github.com'
$appId : string|null = null
$installationId : string|null = null
$psrFactory : Psr17Factory|null = null
$fileUploadConverter : FileUploadConverter|null = null
$privateKey : string|null = null

addReaction()

public addReaction(string $threadId, string $messageId, string $emoji) : void
Parameters
$threadId : string
$messageId : string
$emoji : string

channelIdFromThreadId()

public channelIdFromThreadId(string $threadId) : string
Parameters
$threadId : string
Return values
string

createResponse()

public createResponse() : ResponseInterface|null
Return values
ResponseInterface|null

decodeThreadId()

public decodeThreadId(string $threadId) : mixed
Parameters
$threadId : string

deleteMessage()

public deleteMessage(string $threadId, string $messageId) : void
Parameters
$threadId : string
$messageId : string

encodeThreadId()

public encodeThreadId(mixed $platformData) : string
Parameters
$platformData : mixed
Return values
string

getBotUserId()

public getBotUserId() : string|null
Return values
string|null

openDM()

public openDM(string $userId) : string|null
Parameters
$userId : string
Return values
string|null

parseSlashCommand()

public parseSlashCommand(ServerRequestInterface $request) : Author, command: string, text: string, userId: string, isBot: bool, isMe: bool, channelId: string, triggerId: ?string, raw: mixed}|null
Parameters
$request : ServerRequestInterface
Return values
Author, command: string, text: string, userId: string, isBot: bool, isMe: bool, channelId: string, triggerId: ?string, raw: mixed}|null

parseWebhook()

public parseWebhook(ServerRequestInterface $request) : Message
Parameters
$request : ServerRequestInterface
Return values
Message

removeReaction()

public removeReaction(string $threadId, string $messageId, string $emoji) : void
Parameters
$threadId : string
$messageId : string
$emoji : string

startTyping()

public startTyping(string $threadId) : void
Parameters
$threadId : string

stream()

public stream(string $threadId, iterable<string|int, mixed> $textStream[, array<string|int, mixed> $options = [] ]) : SentMessage|null
Parameters
$threadId : string
$textStream : iterable<string|int, mixed>
$options : array<string|int, mixed> = []
Return values
SentMessage|null

verifyWebhook()

public verifyWebhook(ServerRequestInterface $request) : ResponseInterface|null
Parameters
$request : ServerRequestInterface
Return values
ResponseInterface|null

apiCall()

protected apiCall(string $endpoint, array<string|int, mixed> $params[, string $method = 'POST' ][, array<string|int, mixed> $queryParams = [] ]) : array<string|int, mixed>
Parameters
$endpoint : string
$params : array<string|int, mixed>
$method : string = 'POST'
$queryParams : array<string|int, mixed> = []
Return values
array<string|int, mixed>

base64urlEncode()

protected base64urlEncode(string $data) : string
Parameters
$data : string
Return values
string

deriveChannelId()

protected deriveChannelId(array<string|int, mixed> $payload, string $event) : string
Parameters
$payload : array<string|int, mixed>
$event : string
Return values
string

exchangeInstallationToken()

protected exchangeInstallationToken(string $installationId) : array<string|int, mixed>
Parameters
$installationId : string
Return values
array<string|int, mixed>

generateJWT()

protected generateJWT() : string
Return values
string

getAuthToken()

protected getAuthToken(string $owner, string $repo) : string
Parameters
$owner : string
$repo : string
Return values
string

getInstallationToken()

protected getInstallationToken(string $installationId) : string
Parameters
$installationId : string
Return values
string

jsonResponse()

protected jsonResponse(int $status, string $message) : ResponseInterface
Parameters
$status : int
$message : string
Return values
ResponseInterface

parseIssueComment()

protected parseIssueComment(array<string|int, mixed> $payload, string $rawBody) : Message
Parameters
$payload : array<string|int, mixed>
$rawBody : string
Return values
Message

parseReviewComment()

protected parseReviewComment(array<string|int, mixed> $payload, string $rawBody) : Message
Parameters
$payload : array<string|int, mixed>
$rawBody : string
Return values
Message
On this page

Search results