| 1 | + | <h1 align="center">cspam.go</h1> |
| 2 | + | <p align="center"> |
| 3 | + | <a href="https://crash.fyi">crash.fyi</a> API Client for Go and CLI tool |
| 4 | + | </p> |
| 5 | + | <div align="center"></div> |
| 6 | + | |
| 7 | + | [crash.link](https://crash.fyi/) **Disposable email service** |
| 8 | + | |
| 9 | + | This package provides a basic REST client for crash.fyi |
| 10 | + | For API details, please refer [official documentation](https://docs.crash.fyi). |
| 11 | + | |
| 12 | + | ``` |
| 13 | + | $ go get -u crash.software/crash.fyi/cspam.go |
| 14 | + | ``` |
| 15 | + | |
| 16 | + | ## Usage |
| 17 | + | |
| 18 | + | #### type Client |
| 19 | + | |
| 20 | + | ```go |
| 21 | + | type Client struct { |
| 22 | + | } |
| 23 | + | ``` |
| 24 | + | |
| 25 | + | Client accesses crash.fyi REST API v1 |
| 26 | + | |
| 27 | + | #### func New |
| 28 | + | |
| 29 | + | ```go |
| 30 | + | func New(baseURL string) (*Client, error) |
| 31 | + | ``` |
| 32 | + | New creates a new v1 REST API client given the base URL of the server, |
| 33 | + | ex: "https://crash.fyi" |
| 34 | + | |
| 35 | + | #### func (*Client) DeleteMessage |
| 36 | + | |
| 37 | + | ```go |
| 38 | + | func (c *Client) DeleteMessage(name, id string) error |
| 39 | + | ``` |
| 40 | + | DeleteMessage deletes a single message given the mailbox name and message ID. |
| 41 | + | |
| 42 | + | #### func (*Client) GetMessage |
| 43 | + | |
| 44 | + | ```go |
| 45 | + | func (c *Client) GetMessage(name, id string) (message *Message, err error) |
| 46 | + | ``` |
| 47 | + | GetMessage returns the message details given a mailbox name and message ID. |
| 48 | + | |
| 49 | + | #### func (*Client) GetMessageSource |
| 50 | + | |
| 51 | + | ```go |
| 52 | + | func (c *Client) GetMessageSource(name, id string) (*bytes.Buffer, error) |
| 53 | + | ``` |
| 54 | + | GetMessageSource returns the message source given a mailbox name and message ID. |
| 55 | + | |
| 56 | + | #### func (*Client) ListMailbox |
| 57 | + | |
| 58 | + | ```go |
| 59 | + | func (c *Client) ListMailbox(name string) (headers []*MessageHeader, err error) |
| 60 | + | ``` |
| 61 | + | ListMailbox returns a list of messages for the requested mailbox |
| 62 | + | |
| 63 | + | #### func (*Client) MarkSeen |
| 64 | + | |
| 65 | + | ```go |
| 66 | + | func (c *Client) MarkSeen(name, id string) error |
| 67 | + | ``` |
| 68 | + | MarkSeen marks the specified message as having been read. |
| 69 | + | |
| 70 | + | #### func (*Client) PurgeMailbox |
| 71 | + | |
| 72 | + | ```go |
| 73 | + | func (c *Client) PurgeMailbox(name string) error |
| 74 | + | ``` |
| 75 | + | PurgeMailbox deletes all messages in the given mailbox |
| 76 | + | |
| 77 | + | #### type Message |
| 78 | + | |
| 79 | + | ```go |
| 80 | + | type Message struct { |
| 81 | + | *model.JSONMessageV1 |
| 82 | + | } |
| 83 | + | ``` |
| 84 | + | |
| 85 | + | Message represents a crash.fyi message including content |
| 86 | + | |
| 87 | + | #### func (*Message) Delete |
| 88 | + | |
| 89 | + | ```go |
| 90 | + | func (m *Message) Delete() error |
| 91 | + | ``` |
| 92 | + | Delete deletes this message from the mailbox |
| 93 | + | |
| 94 | + | #### func (*Message) GetSource |
| 95 | + | |
| 96 | + | ```go |
| 97 | + | func (m *Message) GetSource() (*bytes.Buffer, error) |
| 98 | + | ``` |
| 99 | + | GetSource returns the source for this message |
| 100 | + | |
| 101 | + | #### type MessageHeader |
| 102 | + | |
| 103 | + | ```go |
| 104 | + | type MessageHeader struct { |
| 105 | + | *model.JSONMessageHeaderV1 |
| 106 | + | } |
| 107 | + | ``` |
| 108 | + | |
| 109 | + | MessageHeader represents a crash.fyi message sans content |
| 110 | + | |
| 111 | + | #### func (*MessageHeader) Delete |
| 112 | + | |
| 113 | + | ```go |
| 114 | + | func (h *MessageHeader) Delete() error |
| 115 | + | ``` |
| 116 | + | Delete deletes this message from the mailbox |
| 117 | + | |
| 118 | + | #### func (*MessageHeader) GetMessage |
| 119 | + | |
| 120 | + | ```go |
| 121 | + | func (h *MessageHeader) GetMessage() (message *Message, err error) |
| 122 | + | ``` |
| 123 | + | GetMessage returns this message with content |
| 124 | + | |
| 125 | + | #### func (*MessageHeader) GetSource |
| 126 | + | |
| 127 | + | ```go |
| 128 | + | func (h *MessageHeader) GetSource() (*bytes.Buffer, error) |
| 129 | + | ``` |
| 130 | + | GetSource returns the source for this message |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | ## CLI |
| 135 | + | |
| 136 | + | ``` |
| 137 | + | $ go install crash.software/crash.fyi/cspam.go/cmd/cspam |
| 138 | + | ``` |
| 139 | + | |
| 140 | + | |
| 141 | + | ``` |
| 142 | + | ❯ cspam --help |
| 143 | + | |
| 144 | + | Usage: cspam <flags> <subcommand> <subcommand args> |
| 145 | + | |
| 146 | + | Subcommands: |
| 147 | + | commands list all command names |
| 148 | + | flags describe all known top-level flags |
| 149 | + | help describe subcommands and their syntax |
| 150 | + | list list contents of mailbox |
| 151 | + | match output messages matching criteria |
| 152 | + | mbox output mailbox in mbox format |
| 153 | + | |
| 154 | + | Top-level flags (use "client flags" for a full list): |
| 155 | + | -host=crash.fyi: host/IP of crash.fyi server |
| 156 | + | -port=443: HTTPS port of crash.fyi server |
| 157 | + | ``` |
| 158 | + | |
| 159 | + | ### Author |
| 160 | + | |
| 161 | + | **James Hillyerd** |
| 162 | + | |
| 163 | + | ### Copyright and License |
| 164 | + | |
| 165 | + | Copyright (c) 2012 James Hillyerd |
| 166 | + | |
| 167 | + | Code released under [the MIT license](LICENSE). |
| 168 | + | |