Plentymarkets interface documentation

Messenger

Contracts

MessengerRepositoryContract

The MessengerRepositoryContract is the interface for the messenger repository. This interface defines methods to add and show/list messages.

Namespace

Plenty\Modules\Messenger\Contracts

Methods
public add($data):Plenty\Modules\Messenger\Models\Message
Return type: Message

Creates a new message.

Parameters

Name

Type

Description

$data

array

The message data to be loaded

public show($uuid):void

Gets a message with all its successors.

Parameters

Name

Type

Description

$uuid

string

The UUID5 of the message

public list($uuid = null, $successors = true, $amount = self::DEFAULT_MESSAGES_AMOUNT):array

Lists messages. If no reference UUID5 is given, the method returns the $amount first messages. If $successor is set to FALSE, the messages older than the referenced message will be returned.

Parameters

Name

Type

Description

$uuid

string

The reference UUID5 of the message to start from (excluding). If not set, the uuid of the newest message will be used.

$successors

bool

If set to FALSE, the messages older than the referenced message will be returned.

$amount

int

The amount of messages to list (defaults to 50)

public getMessages($page = self::DEFAULT_PAGE_OF_MESSAGES, $itemsPerPage = self::DEFAULT_ITEMS_PER_PAGE_OF_MESSAGES):array

Lists messages.

Parameters

Name

Type

Description

$page

int

The number of the returned page of messages, default is 1 (the first)

$itemsPerPage

int

The amount of messages to list (defaults to 50)

public updateReadBy($readBy, $uuid):void

Updates the readBy array of the message.

Parameters

Name

Type

Description

$readBy

int

The ID of the user who read the message

$uuid

string

The UUID of the message

public updateTags($tags, $uuid):void

Updates the tags of the message.

Parameters

Name

Type

Description

$tags

array

Array of tag IDs of the message

$uuid

string

The UUID of the message

public updateVisibility($data, $uuid):void

Updates the visibility of the message. Attributes that are updated are Message.visibility, Message.linkedTo and Message.accessFor.

Parameters

Name

Type

Description

$data

array

The message with the data to be updated

$uuid

string

The UUID of the messages

public updateControls($data, $uuid):Plenty\Modules\Messenger\Models\Message
Return type: Message

Updates the message ui control options in the message meta data and returns the message.

Parameters

Name

Type

Description

$data

array

The controls data to be updated.

$uuid

string

The uuid of the message.

public setDone($doneAt = null, $uuid):void

Sets the doneAt date in the message. If $doneAt is NULL, the doneAt date will be reset.

Parameters

Name

Type

Description

$doneAt

string

The doneAt date as ISO date string

$uuid

string

The UUID of the message

public delete($uuid):int

Deletes a message stream by the UUID. Returns the count of messages deleted.

Parameters

Name

Type

Description

$uuid

string

The UUID of the message

public getAttachment($uuid, $filename):Plenty\Modules\Messenger\Models\Attachment
Return type: Attachment

Gets a message attachment.

Parameters

Name

Type

Description

$uuid

string

The UUID of the message

$filename

string

The file name of the attachment

public getAllAttachments($uuid):Plenty\Modules\Messenger\Models\Attachment
Return type: Attachment

Gets all message attachments as zip.

Parameters

Name

Type

Description

$uuid

string

The UUID of the message

public updateMetaData($uuid, $metaData):Plenty\Modules\Messenger\Models\Message
Return type: Message

Updates the meta data of the message.

Parameters

Name

Type

Description

$uuid

string

The UUID of the message

$metaData

array

The meta data of the message

public getTotalEntries():int

Returns total message entries

public setFilters($filters = []):void

Sets the filter array.

Parameters

Name

Type

Description

$filters

array

public getFilters():void

Returns the filter array.

public getConditions():void

Returns a collection of parsed filters as Condition object

public clearFilters():void

Clears the filter array.

Events

MessageCreated

The event is triggered after a new message was created.

Namespace

Plenty\Modules\Messenger\Events

Methods
public isFirstMessage():bool

If TRUE, the message is the first one. Otherwise, it is a reply message.

public broadcastWhen():void
public getMessage():Plenty\Modules\Messenger\Models\Message
Return type: Message

Get the message.

Models

Attachment

The Attachment model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties
Name Type Description

name

string

The file name of the attachment

message

string

The UUID of the message the attachment belongs to

size

int

The size of the attachment in bytes

contentType

string

The content type fo the attachment

content

string

The content of the attachment

createdAt

string

The createdAt date of the attachment

Methods
public toArray()

Returns this model as an array.

Message

The Message model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties
Name Type Description

uuid

string

The UUID5 identifier of the message

plentyIdHash

string

The plenty ID hash

parentUuid

string

The UUID5 of the parent message

conversationId

string

The UUID5 of the conversation

linkedTo

array

An array with MessageLinkedTo instances

from

MessageFrom

The sender of the message as MessageFrom instance.

to

MessageTo

The user and role IDs and emails receiving the message

whispered

bool

Whether the message is whispered (not visible for the contact/order linked to the message) or not

tags

array

An array with tag IDs assigned to the message

title

string

The title of the message

preview

string

The first two lines of the message without any markup

message

string

The content of the message

plainMessage

string

The content of the message as plain text

attachedFilesCount

int

The amount of attached files (readonly)

referrer

MessageReferrer

The message referrer

metaData

MessageMetaData

The meta data of the message

doneAt

string

The date the messages was set to done

createdAt

string

The creation date of the message

updatedAt

string

The date of the last update of the message

deletedAt

string

The date the message was deleted

deletedBy

int

The ID of the user who deleted the message

attachments

array

The message attachments

Methods
public toArray()

Returns this model as an array.

MessageFrom

The MessageFrom model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties
Name Type Description

type

string

The type of the from instance (one of {@link MessageTypesService::FROM_TYPE_USER}, {@link MessageTypesService::FROM_TYPE_CONTACT} and {@link MessageTypesService::FROM_TYPE_EMAIL})

value

The value of the instance. For type {@link MessageTypesService::FROM_TYPE_EMAIL} it is a string (the email) and the id of the user or the contact otherwise.

name

string

An optional name for the instance, e.g. the real name for type {@link MessageTypesService::FROM_TYPE_EMAIL}

Methods
public toArray()

Returns this model as an array.

MessageLinkedTo

The MessageLinkedTo model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties
Name Type Description

type

string

The type of the link (one of {@link MessageTypesService::LINKED_TO_TYPE_MESSAGE}, {@link MessageTypesService::LINKED_TO_TYPE_ORDER}, {@link MessageTypesService::LINKED_TO_TYPE_CONTACT} and {@link MessageTypesService::LINKED_TO_TYPE_PAYMENT})

value

The value of the link. For type {@link MessageTypesService::LINKED_TO_TYPE_MESSAGE} it is a string (uuid5) and an integer otherwise.

typeId

This can be the ID of a sub-type (e.g. the order subTypeId). (optional)

Methods
public toArray()

Returns this model as an array.

MessageMetaData

The MessageMetaData model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties
Name Type Description

readBy

array

The array of users

links

array

Array with links

notDoneByBackend

MessageMetaDataNotDone

deactivates the toggle button in the messenger ui (backend) also has optional tooltips (reason for the deactivated toggle)

controls

MessageMetaDataControls

An object with control options for the ui.

timeCapture

MessageMetaDataTimeCapture

An object of the message time capture data

plentyId

int

the plenty id of the related contact

Methods
public toArray()

Returns this model as an array.

MessageMetaDataControls

The message controls model. Currently supported controls: * <ul> * <li><tt>bool replyable</tt> * Indicates whether or not is allowed to reply to this message stream (default true). * It is a global control and effects only in the parent message of a stream.</li> * <li><tt>bool attachable</tt> * Indicates whether or not is allowed to attach files in a message (default true). * It is a global control and effects only in the parent message of a stream.</li> * <li><tt>bool linksDisabled</tt> * Indicates whether or not the message links should be disabled (default false). * It is a loacal control and effects every message.</li> * </ul>

Namespace

Plenty\Modules\Messenger\Models

Properties
Name Type Description

replyable

bool

Indicates whether or not is allowed to reply to this message stream (default true).

attachable

bool

Indicates whether or not is allowed to attach files in a message (default true).

linksDisabled

bool

Indicates whether or not the message links should be disabled (default false).

Methods
public toArray()

Returns this model as an array.

MessageMetaDataNotDone

The MessageMetaDataNotDone model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties
Name Type Description

deactivated

bool

Deactivates the toggle button for the UI

tooltips

array

Tooltips for the UI to show why the toggle is deactivated (if not set, show default values)

Methods
public toArray()

Returns this model as an array.

MessageMetaDataTimeCapture

The MessageMetaDataTimeCapture model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties
Name Type Description

chargeable

bool

minutes

int

Methods
public toArray()

Returns this model as an array.

The MessageMetaLink model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties
Name Type Description

image

string

An optional image URL for the link

caption

string

The caption to be shown for the link

url

string

The link URL <ul> <li>for {@link MessageMetaLink::TYPE_MAILTO} the email</li> <li>for {@link MessageMetaLink::TYPE_URL} the complete URL with protocol</li> <li>for {@link MessageMetaLink::TYPE_PLUGIN} the relative route to the backend</li> <li>not needed for {@link MessageMetaLink::TYPE_REPLY}</li> </ul>

type

string

One of the constants: <ul> <li>{@link MessageMetaLink::TYPE_MAILTO}</li> <li>{@link MessageMetaLink::TYPE_URL}</li> <li>{@link MessageMetaLink::TYPE_PLUGIN}</li> <li>{@link MessageMetaLink::TYPE_REPLY}</li> </ul>

content

string

The reply content, only needed for type {@link MessageMetaLink::TYPE_REPLY}

Methods
public toArray()

Returns this model as an array.

MessageReferrer

The MessageReferrer model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties
Name Type Description

type

string

The type of the from instance (one of {@link MessageTypesService::REFERRER_TYPE_SYSTEM}, {@link MessageTypesService::REFERRER_TYPE_BACKEND}, {@link MessageTypesService::REFERRER_TYPE_REST} and {@link MessageTypesService::REFERRER_TYPE_PLUGIN})

value

The value of the instance. It is an integer (the user id) for type {@link MessageTypesService::REFERRER_TYPE_SYSTEM}, {@link MessageTypesService::REFERRER_TYPE_EMAIL}, {@link MessageTypesService::REFERRER_TYPE_BACKEND} and {@link MessageTypesService::REFERRER_TYPE_REST} and a string (the plugin name) for type {@link MessageTypesService::REFERRER_TYPE_PLUGIN}.

name

string

An optional name for the instance. For type {@link MessageTypesService::REFERRER_TYPE_PLUGIN} it is the plugin namespace, the user name otherwise.

Methods
public toArray()

Returns this model as an array.

MessageTo

The MessageTo model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties
Name Type Description

user

array

An array with user IDs of users receiving the message

role

array

An array with user role IDs of user roles receiving the message

email

array

An array with emails receiving the message

allUsers

bool

Flag indicating that all system users receive the message

Methods
public toArray()

Returns this model as an array.

Services

MessageTypesService

Types and type validation for several types in the messenger.

Namespace

Plenty\Modules\Messenger\Services

Methods
public static getValidLinkedToTypes():array

Gets the valid types for "linked to" references.

public static isValidLinkedTo($linkType, $linkValue):bool

Checks whether the given link is valid or not.

Parameters

Name

Type

Description

$linkType

string

The link type

$linkValue

The link value

public static getValidFromTypes():array

Gets the valid types for "from" references.

public static isValidFrom($fromType, $fromValue):bool

Checks whether the given from is valid or not.

Parameters

Name

Type

Description

$fromType

string

The from type

$fromValue

The from value

public static getValidReferrerTypes():array

Gets the valid types for "referrer" references.

public static isValidReferrer($referrerType, $referrerValue, $referrerName = null):bool

Checks whether the given referrer reference is valid or not.

Parameters

Name

Type

Description

$referrerType

string

The reference to be checked

$referrerValue

The value of the reference

$referrerName

string

The name of the reference

public static getValidToTypes():array

Gets the valid key types for the 'to' array.

public static isValidTo($toKey):bool

Checks whether the given key has a valid value for to.

Parameters

Name

Type

Description

$toKey

string

The to key

MessagesSearchService

Search service for the messenger.

Namespace

Plenty\Modules\Messenger\Services

Methods
public find($uuid):Plenty\Modules\Messenger\Models\Message
Return type: Message

Gets the message with the given uuid.

Parameters

Name

Type

Description

$uuid

string

The UUID of the message

public findOrFail($uuid):Plenty\Modules\Messenger\Models\Message
Return type: Message

Gets the message with the given UUID.

Parameters

Name

Type

Description

$uuid

string

The UUID of the message

public findMany($uuid):array

Gets a stream of messages. The given UUID can be the UUID of the first message in the stream or one of the replied messages.

Parameters

Name

Type

Description

$uuid

string

The UUID of the message

Lists the messages for the given navigation page.

Parameters

Name

Type

Description

$page

int

The page of results to search for

$itemsPerPage

int

The number of items to list per page

public getTotalEntries():int

Returns total entries

public findByConversationId($conversationUuid):array

Gets a stream of messages. The given UUID can be the UUID of the first message in the stream or one of the replied messages.

Parameters

Name

Type

Description

$conversationUuid

string

The UUID of the message

public toArray():array
public process($data):array
Parameters

Name

Type

Description

$data

array

public getFilter():array
public getPostFilter():array
public getQuery():array
public getAggregations():array
public getSuggestions():array
public getSources():void
public addDependenciesToSource($sources):void
Parameters

Name

Type

Description

$sources

public getName():void
public setName($name):void
Parameters

Name

Type

Description

$name

public setIsSourceDisabled($isSourceDisabled):void
Parameters

Name

Type

Description

$isSourceDisabled

bool

public setTrackTotalHits($trackTotalHits):void
Parameters

Name

Type

Description

$trackTotalHits

bool

public addFilter($filter):Plenty\Modules\Cloud\ElasticSearch\Lib\Search\BaseSearch
Return type: BaseSearch
Parameters

Name

Type

Description

$filter

TypeInterface

public addPostFilter($filter):Plenty\Modules\Cloud\ElasticSearch\Lib\Search\BaseSearch
Return type: BaseSearch
Parameters

Name

Type

Description

$filter

TypeInterface

public addQuery($query):Plenty\Modules\Cloud\ElasticSearch\Lib\Search\BaseSearch
Return type: BaseSearch
Parameters

Name

Type

Description

$query

TypeInterface

public addSource($source):Plenty\Modules\Cloud\ElasticSearch\Lib\Search\BaseSearch
Return type: BaseSearch
Parameters

Name

Type

Description

$source

SourceInterface

public setSorting($sorting):Plenty\Modules\Cloud\ElasticSearch\Lib\Search\BaseSearch
Return type: BaseSearch
Parameters

Name

Type

Description

$sorting

SortingInterface

public addAggregation($aggregation):Plenty\Modules\Cloud\ElasticSearch\Lib\Search\BaseSearch
Return type: BaseSearch
Parameters

Name

Type

Description

$aggregation

AggregationInterface

public addSuggestion($suggestion):Plenty\Modules\Cloud\ElasticSearch\Lib\Search\BaseSearch
Return type: BaseSearch
Parameters

Name

Type

Description

$suggestion

SuggestionInterface

public setPage($page, $rowsPerPage):Plenty\Modules\Cloud\ElasticSearch\Lib\Search\BaseSearch
Return type: BaseSearch
Parameters

Name

Type

Description

$page

int

$rowsPerPage

int

public setPagination($pagination):void
Parameters

Name

Type

Description

$pagination

public setCollapse($collapse):void
Parameters

Name

Type

Description

$collapse

CollapseInterface

public setScoreModifier($scoreModifier):Plenty\Modules\Cloud\ElasticSearch\Lib\Search\BaseSearch
Return type: BaseSearch
Parameters

Name

Type

Description

$scoreModifier

ScoreModifierInterface

public setMaxResultWindow($maxResults = 10000):void
Parameters

Name

Type

Description

$maxResults

int

public setIndex($index):void
Parameters

Name

Type

Description

$index

public isSearchAfter():void
public getFilterRaw():void
public getQueriesRaw():void
public getAggregationsRaw():array
public getSorting():void
public getScoreModifier():void

NewMessengerStatusService

New messenger status checker service

Namespace

Plenty\Modules\Messenger\Services

Methods
public static isActive():void