crud

package
v0.0.0-...-3a317aa Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Undefined = platform("UNDEFINED")
	IOS       = platform("IOS")
	Android   = platform("ANDROID")
)

Variables

View Source
var (
	// ErrInvalidEmail is used when user submitted email is wrong when performing login
	ErrInvalidEmail = errors.New("invalid email")

	// ErrInvalidPassword is used when user submitted password is wrong when performing login
	ErrInvalidPassword = errors.New("invalid password")

	// ErrInvalidPhone is used when user submitted phone is wrong when performing login
	ErrInvalidPhone = errors.New("invalid phone")

	// ErrInvalidUsername is used when user submitted username is wrong when performing login
	ErrInvalidUsername = errors.New("invalid username")
)
View Source
var (
	// ErrInvalidCredentials is used when user submitted email, username, phone or password is invalid
	ErrInvalidCredentials = errors.New("invalid email, phone, username or password")
)
View Source
var (
	// ErrMessageInternal is temporary error for chat message sending
	ErrMessageInternal = errors.New("request failed with status code 500 Internal Server Error, but message was sent")
)
View Source
var (
	// ErrUserNotFound used when searched user isn't found
	ErrUserNotFound = errors.New("user not found")
)

Functions

func CheckInternetConnection

func CheckInternetConnection() error

CheckInternetConnection is a utility function that checks if user has internet connection, if there is no connection then tool won't run.

func LoginByEmail

func LoginByEmail(email, password string, wd selenium.WebDriver) error

LoginByEmail performs a login to Acroplia using email

func LoginByPhone

func LoginByPhone(phone, password string, wd selenium.WebDriver) error

LoginByPhone performs a login to Acroplia using phone

func SendMessage

func SendMessage(fullname string, username string, message string, wd selenium.WebDriver) error

SendMessage to a user in Acroplia using web

func TextpadCreate

func TextpadCreate(title string, subtitle string, wd selenium.WebDriver) error

TextpadCreate creates a textpad in Acroplia using web

Types

type AuthResponse

type AuthResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
	Secret       string `json:"secret"`

	User *PrivateUser `json:"user"`
}

type CategoriesSettings

type CategoriesSettings struct {
	AccessChanging   string `json:"ACCESS_CHANGING"`   // Enum: ENABLED, DISABLED
	GroupAddContent  string `json:"GROUP_ADD_CONTENT"` // Enum: ENABLED, IMPORTANT_ONLY, DISABLED
	GroupMembership  string `json:"GROUP_MEMBERSHIP"`  // Enum: ENABLED, DISABLED
	GroupAssignments string `json:"GROUP_ASSIGNMENTS"` // Enum: ENABLED, DISABLED
	Mentions         string `json:"MENTIONS"`          // Enum: ENABLED, DISABLED
}

type Delta

type Delta struct {
	Ops []*Op `json:"ops"`
}

type Device

type Device struct {
	UUID      string     `json:"uuid"`
	Platform  platform   `json:"platform"` // Enum: UNDEFINED, IOS, ANDROID
	Vendor    string     `json:"vendor"`
	Model     string     `json:"model"`
	OsVersion string     `json:"osVersion"`
	Locale    string     `json:"locale"`
	Tokens    *PushToken `json:"tokens"`
	CreatedAt int        `json:"createdAt"`
	UpdatedAt int        `json:"updatedAt"`
}

Device is a struct that holds info about user's device, such as IOS, Android and etc

type JSONMediaDataJSONMediaDataSource

type JSONMediaDataJSONMediaDataSource struct {
	Type     string               `json:"type"` // Enum: IMAGE, AUDIO, VIDEO, DOCUMENT
	Metadata interface{}          `json:"metadata"`
	Source   *JSONMediaDataSource `json:"source"`
}

type JSONMediaDataSource

type JSONMediaDataSource struct {
	URL              string `json:"url"`
	FileSize         int    `json:"fileSize"`
	OriginalFileName string `json:"originalFileName"`
	Width            int    `json:"width"`
	Height           int    `json:"height"`
}

type Language

type Language struct {
	ID           int    `json:"id"`
	UUID         string `json:"uuid"`
	ISOCode      string `json:"isoCode"`
	Title        string `json:"title"`
	MaleVoiceID  string `json:"maleVoiceId"`
	SearchConfig string `json:"searchConfig"`
}

type MediaItem

type MediaItem struct {
	ID   int                               `json:"id"`
	UUID string                            `json:"uuid"`
	Type string                            `json:"type"` // Enum: IMAGE, AUDIO, VIDEO, DOCUMENT
	Data *JSONMediaDataJSONMediaDataSource `json:"data"`
}

type Op

type Op struct {
	Insert     string      `json:"insert"`
	Delete     int         `json:"delete,omitempty"`
	Retain     int         `json:"retain,omitempty"`
	Attributes interface{} `json:"attributes,omitempty"`
}

type PathItem

type PathItem struct {
	UUID  string `json:"uuid"`
	Title string `json:"title"`
}

type PrivateUser

type PrivateUser struct {
	UUID                  string                     `json:"uuid"`
	ID                    int                        `json:"id"`
	Email                 string                     `json:"email"`
	Phone                 string                     `json:"phone"`
	RealName              string                     `json:"realName"`
	DisplayName           string                     `json:"displayName"`
	FirstName             string                     `json:"firstName"`
	LastName              string                     `json:"lastName"`
	ImageMediaItem        *MediaItem                 `json:"imageMediaItem"`
	UserName              string                     `json:"userName"`
	NotificationsSettings *UserNotificationsSettings `json:"notificationsSettings"`
	Roles                 []*Role                    `json:"roles"`
	BirthDate             int                        `json:"birthDate"`
	HasPassword           bool                       `json:"hasPassword"`
	IsOnline              bool                       `json:"isOnline"`
	IsGuest               bool                       `json:"isGuest"`
	IsTutor               bool                       `json:"isTutor"`
	IsTutorOnline         bool                       `json:"isTutorOnline"`
	IsActive              bool                       `json:"isActive"`
}

func (*PrivateUser) ToPublic

func (priv *PrivateUser) ToPublic() *PublicUser

ToPublic converts PrivateUser struct to PublicUser

type PublicUser

type PublicUser struct {
	ID             int        `json:"id"`
	UUID           string     `json:"uuid"`
	Online         bool       `json:"online"`
	UserName       string     `json:"userName"`
	FirstName      string     `json:"firstName"`
	LastName       string     `json:"lastName"`
	Tutor          bool       `json:"tutor"`
	TutorOnline    bool       `json:"tutorOnline"`
	ImageMediaItem *MediaItem `json:"imageMediaItem"`
	Guest          bool       `json:"guest"`
}

type PushToken

type PushToken struct {
	FCMToken  string `json:"fcmToken"`
	APNSToken string `json:"apnsToken"`
}

PushToken are tokens used to send push notification to target's device

type RespUserMessageEntity

type RespUserMessageEntity struct {
	Data *UserMessageEntity `json:"data"`
}

type ResponseAuthResponse

type ResponseAuthResponse struct {
	Data *AuthResponse `json:"data"`
}

type ResponseTextpad

type ResponseTextpad struct {
	Data *Textpad `json:"data"`
}

type Role

type Role struct {
	ID   string `json:"id"`   // uuid
	Type string `json:"type"` // Enum: UNDEFINED, ANONYMOUS_USER, AUTHORIZED_USER, USER, GUEST, WORKSPACE_GUEST, WORKSPACE_MEMBER, WORKSPACE_ADMIN, NODE_OWNER, MODERATOR, PAID_MEMBER, BACK_OFFICER, NODE_BUYER, GXB_USER, COMMUNITY_GUEST, COMMUNITY_MEMBER, COMMUNITY_ADMIN, COMMUNITY_TASK_MANAGER
}

type SignInEmailRequest

type SignInEmailRequest struct {
	Email    string  `json:"email"`
	Password string  `json:"password"`
	Redirect string  `json:"redirect"`
	Device   *Device `json:"device"`
}

SignInEmailRequest is a struct that is ised for login by email requests

func NewSignInEmailRequest

func NewSignInEmailRequest(email string, password string) *SignInEmailRequest

NewSignInEmailRequest is a constructor for SignInEmailRequest type.

It sets Device by default to null.

func (*SignInEmailRequest) LoginByEmail

func (s *SignInEmailRequest) LoginByEmail() (*ResponseAuthResponse, error)

LoginByEmail makes a login request by email and password

path: /v1/users/sessions

method: post

type SignInPhoneRequest

type SignInPhoneRequest struct {
	Phone    string  `json:"phone"`
	Password string  `json:"password"`
	Redirect string  `json:"redirect"`
	Device   *Device `json:"device"`
}

SignInPhoneRequest is a struct that is used for login by phone requests

func NewSignInPhoneRequest

func NewSignInPhoneRequest(phone string, password string) *SignInPhoneRequest

NewSignInPhoneRequest is a constructor for SignInPhoneRequest type.

It sets Device by default to null.

func (*SignInPhoneRequest) LoginByPhone

func (s *SignInPhoneRequest) LoginByPhone() (*ResponseAuthResponse, error)

LoginByPhone makes a login request by phone and password

path: /v1/users/sessions/phone

method: post

type SignInUsernameRequest

type SignInUsernameRequest struct {
	Username string  `json:"username"`
	Password string  `json:"password"`
	Redirect string  `json:"redirect"`
	Device   *Device `json:"device"`
}

SignInUsernameRequest is a struct that is ised for login by username requests

func NewSignInUsernameRequest

func NewSignInUsernameRequest(username string, password string) *SignInUsernameRequest

NewSignInUsernameRequest is a constructor for SignInUsernameRequest type.

It sets Device by default to null.

func (*SignInUsernameRequest) LoginByUsername

func (s *SignInUsernameRequest) LoginByUsername() (*ResponseAuthResponse, error)

LoginByUsername makes a login request by username and password

path: /v1/users/sessions/username

method: post

type Textpad

type Textpad struct {
	Type           string      `json:"type"` // Enum: [ UNDEFINED, TEST, TEXTPAD, CANVAS, CANVAS_DOCUMENT, FOLDER, COLLECTION, LINK, WIKI, TASK_LIST, POST ]
	UUID           string      `json:"uuid"`
	Title          string      `json:"title"`
	Subtitle       string      `json:"subTitle"`
	User           *PublicUser `json:"user"`
	Owner          string      `json:"owner"`
	CreatedAt      int         `json:"createdAt,omitempty"`
	UpdatedAt      int         `json:"updatedAt,omitempty"`
	ImageMediaItem *MediaItem  `json:"imageMediaItem,omitempty"`
	// Tags []string `json:"tags"`
	Lang    *Language   `json:"language,omitempty"`
	Version int         `json:"version,omitempty"`
	Delta   *Delta      `json:"delta"`
	Path    []*PathItem `json:"path,omitempty"`
}

func NewTextpad

func NewTextpad(title, subtitle string, user *PrivateUser) *Textpad

NewTextpad is a constructor for Textpad.

func (*Textpad) Create

func (t *Textpad) Create(token string) (*ResponseTextpad, error)

Create creates a textpad. X-Auth-Token is needed for this request

path: /v1/textpads - /v1/library/{uuid}

method: post

type UserMessageEntity

type UserMessageEntity struct {
	UUID           string         `json:"uuid"`
	Type           string         `json:"type"` // Enum: UNDEFINED, USER_TEXT, USER_MEDIA, EVENT, DELETED
	Text           string         `json:"text"`
	Status         string         `json:"status"` // Enum: SENDING
	User           *PublicUser    `json:"user"`
	CreatedAt      int            `json:"createdAt,omitempty"`
	UpdatedAt      int            `json:"updatedAt,omitempty"`
	ReadMarks      map[string]int `json:"readMarks,omitempty"`
	Attachments    []struct{}     `json:"attachments"`
	ReplyToMessage string         `json:"replyToMessage,omitempty"`
}

func NewMessage

func NewMessage(text string, user *PrivateUser) *UserMessageEntity

NewMessage is a constructor for message to be sent in Acroplia

func (*UserMessageEntity) SendMessage

func (m *UserMessageEntity) SendMessage(chatUUID string, token string) (*RespUserMessageEntity, error)

SendMessage sends message to specified chat uuid. X-Auth-Token is needed for this request.

path: /v1/workspaces/{chat_uuid}/chat

method: post

type UserNotificationsSettings

type UserNotificationsSettings struct {
	SMS         string              `json:"sms"`    // Enum: ENABLED, DISABLED
	Email       string              `json:"email"`  // Enum: ENABLED, DAYLY_DIGEST
	Stream      string              `json:"stream"` // Enum: ENABLED, DISABLED
	Categories  *CategoriesSettings `json:"categories"`
	MutedGroups []string            `json:"mutedGroups"`
}

Jump to

Keyboard shortcuts

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