aboutsummaryrefslogtreecommitdiff
path: root/model
diff options
context:
space:
mode:
Diffstat (limited to 'model')
-rw-r--r--model/app.go19
-rw-r--r--model/session.go23
2 files changed, 42 insertions, 0 deletions
diff --git a/model/app.go b/model/app.go
new file mode 100644
index 0000000..52ebdf5
--- /dev/null
+++ b/model/app.go
@@ -0,0 +1,19 @@
+package model
+
+import "errors"
+
+var (
+ ErrAppNotFound = errors.New("app not found")
+)
+
+type App struct {
+ InstanceURL string
+ ClientID string
+ ClientSecret string
+}
+
+type AppRepository interface {
+ Add(app App) (err error)
+ Update(instanceURL string, clientID string, clientSecret string) (err error)
+ Get(instanceURL string) (app App, err error)
+}
diff --git a/model/session.go b/model/session.go
new file mode 100644
index 0000000..43628ee
--- /dev/null
+++ b/model/session.go
@@ -0,0 +1,23 @@
+package model
+
+import "errors"
+
+var (
+ ErrSessionNotFound = errors.New("session not found")
+)
+
+type Session struct {
+ ID string
+ InstanceURL string
+ AccessToken string
+}
+
+type SessionRepository interface {
+ Add(session Session) (err error)
+ Update(sessionID string, accessToken string) (err error)
+ Get(sessionID string) (session Session, err error)
+}
+
+func (s Session) IsLoggedIn() bool {
+ return len(s.AccessToken) > 0
+}