package module
v0.10.3 Latest Latest

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

Go to latest
Published: Jul 10, 2021 License: MIT Imports: 15 Imported by: 1


iCity SDK

Go Reference

An iCity SDK on Golang.

🔨 Work in progress...




This section is empty.


This section is empty.


func Logout

func Logout(user *User) error

Logout logouts user from iCity

func WriteConfig

func WriteConfig(config *Config, filepath string) (err error)

WriteConfig writes config to file.


type Comment

type Comment struct {
	Nickname string
	UserID   string
	Content  string
	Date     time.Time

type Config

type Config struct {
	Username string `json:"username"`
	Password string `json:"password"`

func ReadConfig

func ReadConfig(filepath string) (config Config, err error)

ReadConfig reads config from file.

type Conversation added in v0.2.0

type Conversation struct {
	// Messages includes the message in the conversation.
	Messages []Message
	// MoreMessages is a link to get more message in the conversation.
	MoreMessages string

Conversation defines one conversation and the messages.

type ConversationItem added in v0.2.0

type ConversationItem struct {
	ID          string
	Nickname    string
	LastMessage string
	LastDate    time.Time

ConversationItem defines every conversation in the conversation list.

type Device added in v0.9.0

type Device struct {
	App      string
	Hardware string
	LastUsed time.Time

	// RemoveLink is the link to remove device.
	RemoveLink string

type Diary

type Diary struct {
	ID       string
	Nickname string
	UserID   string

	Title    string
	Photos   []string
	Content  string
	Location string
	Date     time.Time

type DiaryPrivacy

type DiaryPrivacy int
const (
	Public DiaryPrivacy = iota + 1

func (DiaryPrivacy) Data

func (p DiaryPrivacy) Data() string

func (DiaryPrivacy) String

func (p DiaryPrivacy) String() string
type Header struct {
	Key   string
	Value string

type InvisibleType

type InvisibleType int
const (
	// NotInvisible shows all your diaries to everyone.
	NotInvisible InvisibleType = iota + 1

	// ToStrangers shows your diaries to your friends.

	// ToAll show your diaries to yourself.

func (InvisibleType) Data

func (i InvisibleType) Data() string

func (InvisibleType) String

func (i InvisibleType) String() string

type Message added in v0.2.0

type Message struct {
	Type      MessageType
	Content   string
	Timestamp string

Message defines the message in the conversation.

type MessageType added in v0.2.0

type MessageType string

MessageType defines who send the message.

const (
	// TypeMe means message send by myself.
	TypeMe MessageType = "Me"
	// TypeTa means message send by others.
	TypeTa MessageType = "Ta"

type Option added in v0.1.1

type Option func(*Options)

func WithSaveCookies added in v0.1.1

func WithSaveCookies(filepath string) Option

type Options added in v0.1.1

type Options struct {
	Cookies     []*http.Cookie
	CookiesPath string

type Response

type Response struct {
	// Success is operation status.
	Success bool `json:"success"`

	// ActivityToken is the id of diary.
	ActivityToken string `json:"activity_token,omitempty"`

type Setting

type Setting struct {
	Key   string
	Value string

type SettingsPrivacy

type SettingsPrivacy struct {
	// DefaultPrivacy sets your new diary default access.
	DefaultPrivacy DiaryPrivacy

	// InvisibleMode sets invisible mode.
	InvisibleMode InvisibleType

	// UnWorld sets if your diary publish to world
	UnWorld WorldType

	// AboutMe sets who can access your about me page.
	AboutMe ViewAccess

	// Followings sets who can access your followings list.
	Followings ViewAccess

	// Followers sets who can access your followers list.
	Followers ViewAccess

	// AllowComment sets who can comment your diary.
	AllowComment ViewAccess

	// Allow Like sets who can like your diary.
	AllowLike ViewAccess

	// AllowMessage sets who can send you private message.
	AllowMessage ViewAccess

type User

type User struct {
	Username string
	Password string

	UserID   string
	Nickname string
	Bio      string
	Location string

	SettingsPrivacy SettingsPrivacy
	// contains filtered or unexported fields

func Login

func Login(username, password string, opts ...Option) *User

Login logins user to iCity. If set true to saveCookies, then will write cookies to cookies.json, then will login to iCity with exists cookies.

func LoginWithConfig

func LoginWithConfig(filepath string, opts ...Option) *User

LoginWithConfig login iCity by config file.

func LoginWithCookies added in v0.2.1

func LoginWithCookies(filepath string) *User

LoginWithCookies login iCity by cookies file.

func NewUser

func NewUser(username, password string) *User

NewUser creates a User instance.

func (*User) ChangePassword added in v0.8.3

func (user *User) ChangePassword(currentPassword, newPassword, confirmPassword string) bool

ChangePassword changes my password.

func (*User) DeleteComment

func (user *User) DeleteComment(commentID, diaryID string) (deleteResp Response)

DeleteComment deletes a comment by comment id.

func (*User) DeleteDiary

func (user *User) DeleteDiary(diaryId string) (deleteResp Response)

DeleteDiary deletes the diary with given diary id.

func (*User) Follow

func (user *User) Follow(userID string) bool

Follow follows one user by user id.

func (*User) GetComments

func (user *User) GetComments(diaryID string) []Comment

GetComments gets diary comments by diary id.

func (*User) GetConversation added in v0.2.0

func (user *User) GetConversation(conversationID string) *Conversation

GetConversation gets one conversation details.

func (*User) GetConversationsList added in v0.2.0

func (user *User) GetConversationsList() []ConversationItem

GetConversationsList gets all conversations we have started.

func (*User) GetDevices added in v0.9.0

func (user *User) GetDevices() []Device

GetDevices gets devices we have login iCity.

func (*User) GetFriends added in v0.10.0

func (user *User) GetFriends() []Diary

func (*User) GetMoreMessages added in v0.2.0

func (user *User) GetMoreMessages(conversation *Conversation) *Conversation

GetMoreMessages gets more messages in the conversation.

func (*User) GetMyAllDiaries added in v0.8.1

func (user *User) GetMyAllDiaries() []Diary

GetMyAllDiaries gets my all diaries.

func (*User) GetMyDiaries added in v0.8.0

func (user *User) GetMyDiaries() []Diary

GetMyDiaries gets my index page diaries.

func (*User) GetUserAllDiaries added in v0.8.2

func (user *User) GetUserAllDiaries(userID string) []Diary

GetUserAllDiaries gets user all diaries.

func (*User) GetUserDiaries added in v0.8.2

func (user *User) GetUserDiaries(userID string) []Diary

GetUserDiaries gets user index page diaries.

func (*User) GetWorld

func (user *User) GetWorld() []Diary

GetWorld gets world diaries.

func (*User) Like

func (user *User) Like(diaryId string) bool

Like likes a diary with given diary id.

func (*User) NewComment

func (user *User) NewComment(diaryID, comment string) (newResp Response)

NewComment creates a new comment of a diary by diary id.

func (*User) NewDiary

func (user *User) NewDiary(title, content string, privacy DiaryPrivacy) (newResp Response)

NewDiary creates a new diary with title, content and privacy.

func (*User) RemoveDevice added in v0.9.0

func (user *User) RemoveDevice(device Device) bool

RemoveDevice removes one device.

func (*User) ReplyComment

func (user *User) ReplyComment(userID, diaryID, comment string) Response

ReplyComment replies user by user id and diary id.

func (*User) SendMessage added in v0.2.0

func (user *User) SendMessage(conversationID, content string) bool

SendMessage sends a message in the conversation by conversation id.

func (*User) SetAboutMeAccess

func (user *User) SetAboutMeAccess(setting ViewAccess) bool

SetAboutMeAccess sets AboutMe access.

func (*User) SetAllowComment

func (user *User) SetAllowComment(setting ViewAccess) bool

SetAllowComment sets AllowComment access.

func (*User) SetAllowLike

func (user *User) SetAllowLike(setting ViewAccess) bool

SetAllowLike sets AllowLike access.

func (*User) SetAllowMessage

func (user *User) SetAllowMessage(setting ViewAccess) bool

SetAllowMessage sets AllowMessage access.

func (*User) SetBio

func (user *User) SetBio(bio string) bool

SetBio sets user bio.

func (*User) SetDefaultPrivacy

func (user *User) SetDefaultPrivacy(setting DiaryPrivacy) bool

SetDefaultPrivacy sets DefaultPrivacy access.

func (*User) SetFollowersAccess

func (user *User) SetFollowersAccess(setting ViewAccess) bool

SetFollowersAccess sets Followers access.

func (*User) SetFollowingsAccess

func (user *User) SetFollowingsAccess(setting ViewAccess) bool

SetFollowingsAccess sets Followings access.

func (*User) SetInvisibleMode

func (user *User) SetInvisibleMode(setting InvisibleType) bool

SetInvisibleMode sets InvisibleMode.

func (*User) SetLocation

func (user *User) SetLocation(location string) bool

SetLocation sets user location.

func (*User) SetNickName

func (user *User) SetNickName(nickname string) bool

SetNickName sets user nickname.

func (*User) SetOnlyFriend

func (user *User) SetOnlyFriend(id string) bool

SetOnlyFriend sets diary privacy to OnlyFriend.

func (*User) SetPrivate

func (user *User) SetPrivate(id string) bool

SetPrivate sets diary privacy to Private.

func (*User) SetPublic

func (user *User) SetPublic(id string) bool

SetPublic sets diary privacy to Public.

func (*User) SetSocialBattlenet

func (user *User) SetSocialBattlenet(battlenet string) bool

func (*User) SetSocialDribbble

func (user *User) SetSocialDribbble(dribbble string) bool

func (*User) SetSocialFacebook

func (user *User) SetSocialFacebook(facebook string) bool

func (*User) SetSocialGithub

func (user *User) SetSocialGithub(github string) bool

func (*User) SetSocialHomePage

func (user *User) SetSocialHomePage(homepage string) bool

func (*User) SetSocialInstagram

func (user *User) SetSocialInstagram(instagram string) bool

func (*User) SetSocialLink1

func (user *User) SetSocialLink1(link1 string) bool

func (*User) SetSocialLink2

func (user *User) SetSocialLink2(link2 string) bool

func (*User) SetSocialLink3

func (user *User) SetSocialLink3(link3 string) bool

func (*User) SetSocialNS

func (user *User) SetSocialNS(ns string) bool

func (*User) SetSocialNintendo

func (user *User) SetSocialNintendo(nintendo string) bool

func (*User) SetSocialPSN

func (user *User) SetSocialPSN(psn string) bool

func (*User) SetSocialPixiv

func (user *User) SetSocialPixiv(pixiv string) bool

func (*User) SetSocialQQ

func (user *User) SetSocialQQ(qq string) bool

func (*User) SetSocialSteam

func (user *User) SetSocialSteam(steam string) bool

func (*User) SetSocialTelegram

func (user *User) SetSocialTelegram(telegram string) bool

func (*User) SetSocialTumblr

func (user *User) SetSocialTumblr(tumblr string) bool

func (*User) SetSocialTwitter

func (user *User) SetSocialTwitter(twitter string) bool

func (*User) SetSocialWechat

func (user *User) SetSocialWechat(wechat string) bool

func (*User) SetSocialWeibo

func (user *User) SetSocialWeibo(weibo string) bool

func (*User) SetSocialXBox

func (user *User) SetSocialXBox(xbox string) bool

func (*User) SetUnWorld

func (user *User) SetUnWorld(setting WorldType) bool

SetUnWorld sets UnWorld type.

func (*User) Unfollow

func (user *User) Unfollow(userID string) bool

Unfollow unfollows one user by user id.

func (*User) Unlike

func (user *User) Unlike(diaryId string) bool

Unlike unlikes a diary with given diary id.

type ViewAccess

type ViewAccess int
const (
	// Everyone means everyone on iCity have access.
	Everyone ViewAccess = iota + 1

	// Friend means only your friend have access.

	// Self means only yourself have access.

func (ViewAccess) Data

func (v ViewAccess) Data() string

func (ViewAccess) String

func (v ViewAccess) String() string

type WorldType

type WorldType int
const (
	// Show publishes your diary to world.
	Show WorldType = iota

	// NotShow doesn't publish your diary to world.

func (WorldType) Data

func (w WorldType) Data() string

func (WorldType) String

func (w WorldType) String() string


Path Synopsis

Jump to

Keyboard shortcuts

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