dataTypes.go (2443B)
1 // Copyright © 2018 MTRNord <info@nordgedanken.de> 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package matrix 16 17 import ( 18 "github.com/matrix-org/gomatrix" 19 "time" 20 ) 21 22 // User defines a Interface to allow multiple User type Implementations 23 type User interface { 24 SetCli(cli *gomatrix.Client) 25 SetMXID(id string) 26 SetDisplayName(roomID string, name string) 27 SetAvatar(roomID string, avatar []byte) 28 29 GetMXID() string 30 GetDisplayName(roomID string) (string, error) 31 GetAvatar(roomID string) ([]byte, error) 32 GetCli() (cli *gomatrix.Client) 33 34 //Implement MarshalJSON() (b []byte, e error) as in http://gregtrowbridge.com/golang-json-serialization-with-interfaces/ to support json 35 } 36 37 // Room defines a Interface to allow multiple Room type Implementations 38 type Room interface { 39 // Handled using global "own User" 40 //SetCli(cli *gomatrix.Client) 41 SetRoomID(id string) 42 SetRoomAliases(aliases []string) 43 SetName(name string) 44 SetAvatar(avatar []byte) 45 SetTopic(topic string) 46 SetMessages(messages []Message) 47 48 GetRoomID() string 49 GetRoomAliases() []string 50 GetName() (string, error) 51 GetAvatar() ([]byte, error) 52 GetTopic() (string, error) 53 GetMessages() []Message 54 55 //Implement MarshalJSON() (b []byte, e error) as in http://gregtrowbridge.com/golang-json-serialization-with-interfaces/ to support json 56 } 57 58 // Message defines a Interface to allow multiple Message type Implementations 59 type Message interface { 60 // Handled using global "own User" 61 //SetCli(cli *gomatrix.Client) 62 SetEventID(id string) 63 SetEvent(event *gomatrix.Event) 64 SetAuthorMXID(mxid string) 65 SetMessage(message string) 66 SetTimestamp(ts *time.Time) 67 68 GetEventID() (id string) 69 GetEvent() (event *gomatrix.Event) 70 GetAuthorMXID() (mxid string) 71 GetMessage() (message string) 72 GetTimestamp() (ts *time.Time) 73 74 Show() error 75 76 //Implement MarshalJSON() (b []byte, e error) as in http://gregtrowbridge.com/golang-json-serialization-with-interfaces/ to support json 77 }