Documentation ¶
Overview ¶
Package core exposes an interface that allows making requests to the core Chatkit API to allow operations to be performed against Users, Rooms and Messages.
Index ¶
- Variables
- type Attachment
- type CreateRoomOptions
- type CreateUserOptions
- type DeleteMessageOptions
- type EditMessageOptions
- type EditMultipartMessageOptions
- type EditSimpleMessageOptions
- type FetchMultipartMessageOptions
- type FetchMultipartMessagesOptions
- type GetRoomMessagesOptions
- type GetRoomsOptions
- type GetUsersOptions
- type Message
- type MultipartMessage
- type NewAttachmentPart
- type NewInlinePart
- type NewPart
- type NewURLPart
- type Part
- type Room
- type RoomWithoutMembers
- type SendMessageOptions
- type SendMultipartMessageOptions
- type SendSimpleMessageOptions
- type Service
- type UpdateRoomOptions
- type UpdateUserOptions
- type User
Constants ¶
This section is empty.
Variables ¶
var ExplicitlyResetPushNotificationTitleOverride = "null"
ExplicitlyResetPushNotificationTitleOverride when used in the UpdateRoomOptions signifies that the override is to be removed entirely
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type CreateRoomOptions ¶
type CreateRoomOptions struct { ID *string `json:"id,omitempty"` Name string `json:"name"` PushNotificationTitleOverride *string `json:"push_notification_title_override,omitempty"` Private bool `json:"private"` UserIDs []string `json:"user_ids,omitempty"` // User ID's to be added to the room during creation CustomData interface{} `json:"custom_data,omitempty"` CreatorID string }
CreateRoomOptions contains parameters to pass when creating a new room.
type CreateUserOptions ¶
type CreateUserOptions struct { ID string `json:"id"` Name string `json:"name"` AvatarURL *string `json:"avatar_url,omitempty"` CustomData interface{} `json:"custom_data,omitempty"` }
CreateUserOptions contains parameters to pass when creating a new user.
type DeleteMessageOptions ¶
type EditMessageOptions ¶
type EditMessageOptions = EditSimpleMessageOptions
type EditSimpleMessageOptions ¶
EditSimpleMessageOption contains parameters to pass when editing an existing message.
type FetchMultipartMessageOptions ¶
FetchMultipartMessageOptions contains parameters to pass when fetching a single message from a room.
type FetchMultipartMessagesOptions ¶
type FetchMultipartMessagesOptions = fetchMessagesOptions
FetchMultipartMessagesOptions contains parameters to pass when fetching messages from a room.
type GetRoomMessagesOptions ¶
type GetRoomMessagesOptions = fetchMessagesOptions
GetRoomMessagesOptions contains parameters to pass when fetching messages from a room.
type GetRoomsOptions ¶
type GetRoomsOptions struct { FromID *string `json:"from_id,omitempty"` IncludePrivate bool `json:"include_private"` }
GetRoomsOptions contains parameters to pass to fetch rooms.
type GetUsersOptions ¶
GetUsersOptions contains parameters to pass when fetching users.
type Message ¶
type Message struct { ID uint `json:"id"` // Message ID UserID string `json:"user_id"` // User that sent the message RoomID string `json:"room_id"` // Room the message was sent to Text string `json:"text"` // Content of the message CreatedAt time.Time `json:"created_at"` // Creation timestamp UpdatedAt time.Time `json:"updated_at"` // Updation timestamp }
Message represents a message sent to a chatkit room.
type MultipartMessage ¶
type MultipartMessage struct { ID uint `json:"id"` // Message ID UserID string `json:"user_id"` // User that sent the message RoomID string `json:"room_id"` // Room the message was sent to Parts []Part `json:"parts"` // Parts composing the message CreatedAt time.Time `json:"created_at"` // Creation timestamp UpdatedAt time.Time `json:"updated_at"` // Updation timestamp }
MultipartMessage represents a message sent to a chatkit room.
type NewAttachmentPart ¶
NewAttachmentPart has no JSON annotations because it cannot be sent directly to the backend. The attachment must first be uploaded and a newAttachmentPartUploaded sent instead.
type NewInlinePart ¶
type NewURLPart ¶
type Part ¶
type Part struct { Type string `json:"type"` Content *string `json:"content,omitempty"` URL *string `json:"url,omitempty"` Attachment *Attachment `json:"attachment,omitempty"` }
type Room ¶
type Room struct { RoomWithoutMembers MemberUserIDs []string `json:"member_user_ids,omitempty"` // List of user id's in the room }
Room represents a chatkit room.
type RoomWithoutMembers ¶
type RoomWithoutMembers struct { ID string `json:"id"` // ID assigned to a room CreatedByID string `json:"created_by_id"` // User ID that created the room Name string `json:"name"` // Name assigned to the room PushNotificationTitleOverride *string `json:"push_notification_title_override,omitempty"` // Optionally override Push Notification title Private bool `json:"private"` // Indicates if room is private or not CustomData interface{} `json:"custom_data,omitempty"` // Custom data that can be added to rooms CreatedAt time.Time `json:"created_at"` // Creation timestamp UpdatedAt time.Time `json:"updated_at"` // Updation timestamp }
RoomWithoutMembers represents a chatkit room without listing its members.
type SendMessageOptions ¶
type SendMessageOptions = SendSimpleMessageOptions
SendMessageOptions contains parameters to pass when sending a new message.
type SendMultipartMessageOptions ¶
SendMultipartMessageOptions contains parameters to pass when sending a new message.
type SendSimpleMessageOptions ¶
SendSimpleMessageOptions contains parameters to pass when sending a new message.
type Service ¶
type Service interface { // Users GetUser(ctx context.Context, userID string) (User, error) GetUsers(ctx context.Context, options *GetUsersOptions) ([]User, error) GetUsersByID(ctx context.Context, userIDs []string) ([]User, error) CreateUser(ctx context.Context, options CreateUserOptions) error CreateUsers(ctx context.Context, users []CreateUserOptions) error UpdateUser(ctx context.Context, userID string, options UpdateUserOptions) error DeleteUser(ctx context.Context, userID string) error // Rooms GetRoom(ctx context.Context, roomID string) (Room, error) GetRooms(ctx context.Context, options GetRoomsOptions) ([]RoomWithoutMembers, error) GetUserRooms(ctx context.Context, userID string) ([]Room, error) GetUserJoinableRooms(ctx context.Context, userID string) ([]Room, error) CreateRoom(ctx context.Context, options CreateRoomOptions) (Room, error) UpdateRoom(ctx context.Context, roomID string, options UpdateRoomOptions) error DeleteRoom(ctx context.Context, roomID string) error AddUsersToRoom(ctx context.Context, roomID string, userIDs []string) error RemoveUsersFromRoom(ctx context.Context, roomID string, userIds []string) error // Messages SendMessage(ctx context.Context, options SendMessageOptions) (uint, error) SendMultipartMessage(ctx context.Context, options SendMultipartMessageOptions) (uint, error) SendSimpleMessage(ctx context.Context, options SendSimpleMessageOptions) (uint, error) GetRoomMessages( ctx context.Context, roomID string, options GetRoomMessagesOptions, ) ([]Message, error) FetchMultipartMessage( ctx context.Context, options FetchMultipartMessageOptions, ) (MultipartMessage, error) FetchMultipartMessages( ctx context.Context, roomID string, options FetchMultipartMessagesOptions, ) ([]MultipartMessage, error) DeleteMessage(ctx context.Context, options DeleteMessageOptions) error EditMessage(ctx context.Context, roomID string, messageID uint, options EditMessageOptions) error EditMultipartMessage(ctx context.Context, roomID string, messageID uint, options EditMultipartMessageOptions) error EditSimpleMessage(ctx context.Context, roomID string, messageID uint, options EditSimpleMessageOptions) error // Generic requests Request(ctx context.Context, options client.RequestOptions) (*http.Response, error) }
Service exposes methods to interact with the core chatkit service. This allows interacting with the messages, rooms and users API.
func NewService ¶
Returns a new coreService instance that conforms to the Service interface.
type UpdateRoomOptions ¶
type UpdateRoomOptions struct { Name *string `json:"name,omitempty"` PushNotificationTitleOverride *string `json:"push_notification_title_override,omitempty"` Private *bool `json:"private,omitempty"` CustomData interface{} `json:"custom_data,omitempty"` }
UpdateRoomOptions contains parameters to pass when updating a room.
type UpdateUserOptions ¶
type UpdateUserOptions struct { Name *string `json:"name,omitempty"` AvatarUrl *string `json:"avatar_url,omitempty"` CustomData interface{} `json:"custom_data,omitempty"` }
UpdateUserOptions contains parameters to pass when updating a user.
type User ¶
type User struct { ID string `json:"id"` // ID of the user Name string `json:"name"` // Name associated with the user AvatarURL string `json:"avatar_url,omitempty"` // Link to a photo/ image of the user CustomData map[string]interface{} `json:"custom_data,omitempty"` // A custom data object associated with the user CreatedAt time.Time `json:"created_at"` // Creation timestamp UpdatedAt time.Time `json:"updated_at"` // Updating timestamp }
User represents a chatkit user.