messages

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AttachmentCmd = &cobra.Command{
	Use:   "attachment <mailbox-resource-id> <folder> <uid> <attachment-id>",
	Short: "Download message attachment",
	Long:  "Download a message attachment as `application/octet-stream`.",
	Args:  cobra.MatchAll(cobra.ExactArgs(4)),
	Run: func(cmd *cobra.Command, args []string) {
		r, err := api.Request().GetMessageAttachmentWithResponse(context.TODO(), args[0], args[1], utils.StringToInt(args[2]), args[3])
		if err != nil {
			log.Fatal(err)
		}

		output.Format(cmd, r.Body, r.StatusCode())
	},
}
View Source
var DeleteAllCmd = &cobra.Command{
	Use:   "delete-all <mailbox-resource-id> <folder>",
	Short: "Delete all messages",
	Long:  "Permanently delete every message in a folder (empty the folder).",
	Args:  cobra.MatchAll(cobra.ExactArgs(2)),
	Run: func(cmd *cobra.Command, args []string) {
		r, err := api.Request().DeleteAllMessagesWithResponse(context.TODO(), args[0], args[1])
		if err != nil {
			log.Fatal(err)
		}

		output.Format(cmd, r.Body, r.StatusCode())
	},
}
View Source
var DeleteBulkCmd = &cobra.Command{
	Use:   "delete-bulk <mailbox-resource-id> <folder>",
	Short: "Delete messages",
	Long:  "Permanently delete multiple messages from a folder.",
	Args:  cobra.MatchAll(cobra.ExactArgs(2)),
	Run: func(cmd *cobra.Command, args []string) {
		payload, err := json.Marshal(deleteBulkBody(cmd))
		if err != nil {
			log.Fatal(err)
		}
		r, err := api.Request().DeleteMessagesWithBodyWithResponse(context.TODO(), args[0], args[1], "application/json", bytes.NewReader(payload))
		if err != nil {
			log.Fatal(err)
		}

		output.Format(cmd, r.Body, r.StatusCode())
	},
}
View Source
var DeleteCmd = &cobra.Command{
	Use:   "delete <mailbox-resource-id> <folder> <uid>",
	Short: "Delete message",
	Long:  "Permanently delete a single message.",
	Args:  cobra.MatchAll(cobra.ExactArgs(3)),
	Run: func(cmd *cobra.Command, args []string) {
		r, err := api.Request().DeleteMessageWithResponse(context.TODO(), args[0], args[1], utils.StringToInt(args[2]))
		if err != nil {
			log.Fatal(err)
		}

		output.Format(cmd, r.Body, r.StatusCode())
	},
}
View Source
var GetCmd = &cobra.Command{
	Use:   "get <mailbox-resource-id> <folder> <uid>",
	Short: "Get message",
	Long:  "Retrieve a single message by UID.",
	Args:  cobra.MatchAll(cobra.ExactArgs(3)),
	Run: func(cmd *cobra.Command, args []string) {
		r, err := api.Request().GetMessageWithResponse(context.TODO(), args[0], args[1], utils.StringToInt(args[2]))
		if err != nil {
			log.Fatal(err)
		}

		output.Format(cmd, r.Body, r.StatusCode())
	},
}
View Source
var GroupCmd = &cobra.Command{
	Use:   "messages",
	Short: "Messages commands",
}
View Source
var ListCmd = &cobra.Command{
	Use:   "list <mailbox-resource-id> <folder>",
	Short: "List messages",
	Long:  "List messages in a folder. Use POST /search for filtering. Sort fields: uid, date, size (prefix with `-` for descending). Default `-uid`.",
	Args:  cobra.MatchAll(cobra.ExactArgs(2)),
	Run: func(cmd *cobra.Command, args []string) {
		r, err := api.Request().ListMessagesWithResponse(context.TODO(), args[0], args[1], listParams(cmd))
		if err != nil {
			log.Fatal(err)
		}

		output.Format(cmd, r.Body, r.StatusCode())
	},
}
View Source
var MoveBulkCmd = &cobra.Command{
	Use:   "move-bulk <mailbox-resource-id> <folder>",
	Short: "Move messages",
	Long:  "Move multiple messages from a source folder to a target folder.",
	Args:  cobra.MatchAll(cobra.ExactArgs(2)),
	Run: func(cmd *cobra.Command, args []string) {
		payload, err := json.Marshal(moveBulkBody(cmd))
		if err != nil {
			log.Fatal(err)
		}
		r, err := api.Request().MoveMessagesWithBodyWithResponse(context.TODO(), args[0], args[1], "application/json", bytes.NewReader(payload))
		if err != nil {
			log.Fatal(err)
		}

		output.Format(cmd, r.Body, r.StatusCode())
	},
}
View Source
var MoveCmd = &cobra.Command{
	Use:   "move <mailbox-resource-id> <folder> <uid>",
	Short: "Move message",
	Long:  "Move a single message to a target folder.",
	Args:  cobra.MatchAll(cobra.ExactArgs(3)),
	Run: func(cmd *cobra.Command, args []string) {
		payload, err := json.Marshal(moveBody(cmd))
		if err != nil {
			log.Fatal(err)
		}
		r, err := api.Request().MoveMessageWithBodyWithResponse(context.TODO(), args[0], args[1], utils.StringToInt(args[2]), "application/json", bytes.NewReader(payload))
		if err != nil {
			log.Fatal(err)
		}

		output.Format(cmd, r.Body, r.StatusCode())
	},
}
View Source
var PatchCmd = &cobra.Command{
	Use:   "patch <mailbox-resource-id> <folder> <uid>",
	Short: "Update message flags",
	Long:  "Add and/or remove flags on a single message. Returns the updated message.",
	Args:  cobra.MatchAll(cobra.ExactArgs(3)),
	Run: func(cmd *cobra.Command, args []string) {
		payload, err := json.Marshal(patchBody(cmd))
		if err != nil {
			log.Fatal(err)
		}
		r, err := api.Request().PatchMessageWithBodyWithResponse(context.TODO(), args[0], args[1], utils.StringToInt(args[2]), "application/json", bytes.NewReader(payload))
		if err != nil {
			log.Fatal(err)
		}

		output.Format(cmd, r.Body, r.StatusCode())
	},
}
View Source
var SearchCmd = &cobra.Command{
	Use:   "search <mailbox-resource-id> <folder>",
	Short: "Search messages",
	Long:  "Search messages in a folder. Filters in body; pagination and sort via query (`page`, `perPage`, `sort`).",
	Args:  cobra.MatchAll(cobra.ExactArgs(2)),
	Run: func(cmd *cobra.Command, args []string) {
		payload, err := json.Marshal(searchBody(cmd))
		if err != nil {
			log.Fatal(err)
		}
		r, err := api.Request().SearchMessagesWithBodyWithResponse(context.TODO(), args[0], args[1], searchParams(cmd), "application/json", bytes.NewReader(payload))
		if err != nil {
			log.Fatal(err)
		}

		output.Format(cmd, r.Body, r.StatusCode())
	},
}
View Source
var SourceCmd = &cobra.Command{
	Use:   "source <mailbox-resource-id> <folder> <uid>",
	Short: "Get message source",
	Long:  "Retrieve raw RFC822 source of a message as `message/rfc822` attachment.",
	Args:  cobra.MatchAll(cobra.ExactArgs(3)),
	Run: func(cmd *cobra.Command, args []string) {
		r, err := api.Request().GetMessageSourceWithResponse(context.TODO(), args[0], args[1], utils.StringToInt(args[2]))
		if err != nil {
			log.Fatal(err)
		}

		output.Format(cmd, r.Body, r.StatusCode())
	},
}
View Source
var TextCmd = &cobra.Command{
	Use:   "text <mailbox-resource-id> <folder> <uid>",
	Short: "Get message text content",
	Long:  "Retrieve rendered text (plain + HTML) of a message. Marks message as `\\Seen`.",
	Args:  cobra.MatchAll(cobra.ExactArgs(3)),
	Run: func(cmd *cobra.Command, args []string) {
		r, err := api.Request().GetMessageTextWithResponse(context.TODO(), args[0], args[1], utils.StringToInt(args[2]))
		if err != nil {
			log.Fatal(err)
		}

		output.Format(cmd, r.Body, r.StatusCode())
	},
}
View Source
var UpdateFlagsCmd = &cobra.Command{
	Use:   "update-flags <mailbox-resource-id> <folder>",
	Short: "Update message flags",
	Long:  "Add and/or remove flags on multiple messages. Returns 200 when all UIDs succeed, 207 with per-UID outcome when some fail.",
	Args:  cobra.MatchAll(cobra.ExactArgs(2)),
	Run: func(cmd *cobra.Command, args []string) {
		payload, err := json.Marshal(updateFlagsBody(cmd))
		if err != nil {
			log.Fatal(err)
		}
		r, err := api.Request().UpdateMessageFlagsWithBodyWithResponse(context.TODO(), args[0], args[1], "application/json", bytes.NewReader(payload))
		if err != nil {
			log.Fatal(err)
		}

		output.Format(cmd, r.Body, r.StatusCode())
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL