PHP Class Maknz\Slack\Client

Afficher le fichier Open project: maknz/slack Class Usage Examples

Protected Properties

Свойство Type Description
$allow_markdown boolean Whether message text should be formatted with Slack's Markdown-like language.
$channel string The default channel to send messages to.
$endpoint string The Slack incoming webhook endpoint.
$guzzle GuzzleHttp\Client The Guzzle HTTP client instance.
$icon string The default icon to send messages with.
$link_names boolean Whether to link names like @regan or leave them as plain text.
$markdown_in_attachments array The attachment fields which should be formatted with Slack's Markdown-like language.
$unfurl_links boolean Whether Slack should unfurl text-based URLs.
$unfurl_media boolean Whether Slack should unfurl media URLs.
$username string The default username to send messages as.

Méthodes publiques

Méthode Description
__call ( string $name, array $arguments ) : Message Pass any unhandled methods through to a new Message instance.
__construct ( string $endpoint, array $attributes = [], Client $guzzle = null ) : void Instantiate a new Client.
createMessage ( ) : Message Create a new message with defaults.
getAllowMarkdown ( ) : boolean Get whether message text should be formatted with Slack's Markdown-like language.
getDefaultChannel ( ) : string Get the default channel messages will be created for.
getDefaultIcon ( ) : string Get the default icon messages will be created with.
getDefaultUsername ( ) : string Get the default username messages will be created for.
getEndpoint ( ) : string Get the Slack endpoint.
getLinkNames ( ) : boolean Get whether messages sent will have names (like @regan) will be converted into links.
getMarkdownInAttachments ( ) : array Get the attachment fields which should be formatted in Slack's Markdown-like language.
getUnfurlLinks ( ) : boolean Get whether text links should be unfurled.
getUnfurlMedia ( ) : boolean Get whether media links should be unfurled.
preparePayload ( Message $message ) : array Prepares the payload to be sent to the webhook.
sendMessage ( Message $message ) : void Send a message.
setAllowMarkdown ( boolean $value ) : void Set whether message text should be formatted with Slack's Markdown-like language.
setDefaultChannel ( string $channel ) : void Set the default channel messages will be created for.
setDefaultIcon ( string $icon ) : void Set the default icon messages will be created with.
setDefaultUsername ( string $username ) : void Set the default username messages will be created for.
setEndpoint ( string $endpoint ) : void Set the Slack endpoint.
setLinkNames ( boolean $value ) : void Set whether messages sent will have names (like @regan) will be converted into links.
setMarkdownInAttachments ( array $fields ) : void Set the attachment fields which should be formatted in Slack's Markdown-like language.
setUnfurlLinks ( boolean $value ) : void Set whether text links should be unfurled.
setUnfurlMedia ( boolean $value ) : void Set whether media links should be unfurled.

Méthodes protégées

Méthode Description
getAttachmentsAsArrays ( Message $message ) : array Get the attachments in array form.

Method Details

__call() public méthode

Pass any unhandled methods through to a new Message instance.
public __call ( string $name, array $arguments ) : Message
$name string The name of the method
$arguments array The method arguments
Résultat Message

__construct() public méthode

Instantiate a new Client.
public __construct ( string $endpoint, array $attributes = [], Client $guzzle = null ) : void
$endpoint string
$attributes array
$guzzle GuzzleHttp\Client
Résultat void

createMessage() public méthode

Create a new message with defaults.
public createMessage ( ) : Message
Résultat Message

getAllowMarkdown() public méthode

Get whether message text should be formatted with Slack's Markdown-like language.
public getAllowMarkdown ( ) : boolean
Résultat boolean

getAttachmentsAsArrays() protected méthode

Get the attachments in array form.
protected getAttachmentsAsArrays ( Message $message ) : array
$message Message
Résultat array

getDefaultChannel() public méthode

Get the default channel messages will be created for.
public getDefaultChannel ( ) : string
Résultat string

getDefaultIcon() public méthode

Get the default icon messages will be created with.
public getDefaultIcon ( ) : string
Résultat string

getDefaultUsername() public méthode

Get the default username messages will be created for.
public getDefaultUsername ( ) : string
Résultat string

getEndpoint() public méthode

Get the Slack endpoint.
public getEndpoint ( ) : string
Résultat string

getLinkNames() public méthode

Get whether messages sent will have names (like @regan) will be converted into links.
public getLinkNames ( ) : boolean
Résultat boolean

getMarkdownInAttachments() public méthode

Get the attachment fields which should be formatted in Slack's Markdown-like language.
public getMarkdownInAttachments ( ) : array
Résultat array

getUnfurlMedia() public méthode

Get whether media links should be unfurled.
public getUnfurlMedia ( ) : boolean
Résultat boolean

preparePayload() public méthode

Prepares the payload to be sent to the webhook.
public preparePayload ( Message $message ) : array
$message Message The message to send
Résultat array

sendMessage() public méthode

Send a message.
public sendMessage ( Message $message ) : void
$message Message
Résultat void

setAllowMarkdown() public méthode

Set whether message text should be formatted with Slack's Markdown-like language.
public setAllowMarkdown ( boolean $value ) : void
$value boolean
Résultat void

setDefaultChannel() public méthode

Set the default channel messages will be created for.
public setDefaultChannel ( string $channel ) : void
$channel string
Résultat void

setDefaultIcon() public méthode

Set the default icon messages will be created with.
public setDefaultIcon ( string $icon ) : void
$icon string
Résultat void

setDefaultUsername() public méthode

Set the default username messages will be created for.
public setDefaultUsername ( string $username ) : void
$username string
Résultat void

setEndpoint() public méthode

Set the Slack endpoint.
public setEndpoint ( string $endpoint ) : void
$endpoint string
Résultat void

setLinkNames() public méthode

Set whether messages sent will have names (like @regan) will be converted into links.
public setLinkNames ( boolean $value ) : void
$value boolean
Résultat void

setMarkdownInAttachments() public méthode

Set the attachment fields which should be formatted in Slack's Markdown-like language.
public setMarkdownInAttachments ( array $fields ) : void
$fields array
Résultat void

setUnfurlMedia() public méthode

Set whether media links should be unfurled.
public setUnfurlMedia ( boolean $value ) : void
$value boolean
Résultat void

Property Details

$allow_markdown protected_oe property

Whether message text should be formatted with Slack's Markdown-like language.
protected bool $allow_markdown
Résultat boolean

$channel protected_oe property

The default channel to send messages to.
protected string $channel
Résultat string

$endpoint protected_oe property

The Slack incoming webhook endpoint.
protected string $endpoint
Résultat string

$guzzle protected_oe property

The Guzzle HTTP client instance.
protected Client,GuzzleHttp $guzzle
Résultat GuzzleHttp\Client

$icon protected_oe property

The default icon to send messages with.
protected string $icon
Résultat string

$markdown_in_attachments protected_oe property

The attachment fields which should be formatted with Slack's Markdown-like language.
protected array $markdown_in_attachments
Résultat array

$unfurl_media protected_oe property

Whether Slack should unfurl media URLs.
protected bool $unfurl_media
Résultat boolean

$username protected_oe property

The default username to send messages as.
protected string $username
Résultat string