Documentation
¶
Index ¶
- Constants
- Variables
- func GetToken(ctx context.Context) *oauth2.Token
- func SetToken(ctx context.Context, token *oauth2.Token) context.Context
- type AuthData
- type AuthRepo
- type AuthUsecase
- type Calendar
- type CalendarRepo
- type CalendarUseCase
- type ChangeTypeEnum
- type ChatUseCase
- type Event
- type EventHistory
- type EventHistoryRepo
- type EventHistoryUseCase
- type EventRepo
- type EventUseCase
- func (uc *EventUseCase) Create(ctx context.Context, event *Event) (*Event, error)
- func (uc *EventUseCase) Delete(ctx context.Context, event *Event) error
- func (uc *EventUseCase) Get(ctx context.Context, event *Event) (*Event, error)
- func (uc *EventUseCase) List(ctx context.Context, calendarID uuid.UUID) ([]*Event, error)
- func (uc *EventUseCase) Sync(ctx context.Context, calendarID uuid.UUID, events []*Event) error
- func (uc *EventUseCase) Update(ctx context.Context, event *Event) (*Event, error)
- type GoogleListEventsOption
- type GoogleRepo
- type GoogleUseCase
- func (uc *GoogleUseCase) AuthCodeURL(state string) string
- func (uc *GoogleUseCase) ListCalendarEvents(ctx context.Context, token *oauth2.Token, calendarID string, ...) ([]*Event, error)
- func (uc *GoogleUseCase) ListUserCalendars(ctx context.Context, token *oauth2.Token) ([]*Calendar, error)
- func (uc *GoogleUseCase) TokenExchange(ctx context.Context, code string) (*oauth2.Token, error)
- func (uc *GoogleUseCase) TokenSource(ctx context.Context, refreshToken string) (*oauth2.Token, error)
- func (uc *GoogleUseCase) UserInfo(ctx context.Context, token *oauth2.Token) (*User, error)
- type OpenAIUseCase
- type User
- type UserRepo
- type UserUseCase
- func (uc *UserUseCase) Create(ctx context.Context, user *User) error
- func (uc *UserUseCase) Get(ctx context.Context, user *User) (*User, error)
- func (uc *UserUseCase) GetUserByID(ctx context.Context, id string) (*User, error)
- func (uc *UserUseCase) GetUserByTGID(ctx context.Context, tgid string) (*User, error)
- func (uc *UserUseCase) List(ctx context.Context) ([]*User, error)
Constants ¶
const (
STATE_KEY_DURATION = time.Second * 300
)
const (
TOKEN_KEY = "token"
)
Variables ¶
var ProviderSet = wire.NewSet( NewAuthUsecase, NewUserUseCase, NewCalendarUseCase, NewEventUseCase, NewEventHistoryUseCase, NewGoogleUseCase, NewOpenAIUseCase, NewChatUseCase, )
ProviderSet is biz providers.
Functions ¶
Types ¶
type AuthUsecase ¶
type AuthUsecase struct {
// contains filtered or unexported fields
}
func NewAuthUsecase ¶
func NewAuthUsecase(repo AuthRepo, logger log.Logger) *AuthUsecase
func (*AuthUsecase) CheckState ¶
type CalendarRepo ¶
type CalendarRepo interface { Create(ctx context.Context, calendar *Calendar) error Update(ctx context.Context, calendar *Calendar) error Delete(ctx context.Context, calendar *Calendar) error Get(ctx context.Context, calendar *Calendar) (*Calendar, error) List(ctx context.Context, userID uuid.UUID) ([]*Calendar, error) }
type CalendarUseCase ¶
type CalendarUseCase struct {
// contains filtered or unexported fields
}
func NewCalendarUseCase ¶
func NewCalendarUseCase(repo CalendarRepo, logger log.Logger) *CalendarUseCase
func (*CalendarUseCase) ListUserCalendars ¶
func (uc *CalendarUseCase) ListUserCalendars(ctx context.Context, userID uuid.UUID) ([]*Calendar, error)
ListUserCalendars List lists calendars from database.
func (*CalendarUseCase) Sync ¶
Sync syncs down calendars. It will take incoming calendars and compare them to the ones in the database. If the calendar exists in the database, it will update it. If it doesn't exist, it will create it. If the calendar exists in the database but not in the incoming calendars, it will delete it.
type ChangeTypeEnum ¶
type ChangeTypeEnum string
const ( CREATED ChangeTypeEnum = "CREATED" UPDATED ChangeTypeEnum = "UPDATED" DELETED ChangeTypeEnum = "DELETED" )
type ChatUseCase ¶
type ChatUseCase struct {
// contains filtered or unexported fields
}
func NewChatUseCase ¶
func NewChatUseCase(cfg *conf.OpenAI, logger log.Logger, gr GoogleRepo, cr CalendarRepo, er EventRepo) *ChatUseCase
NewChatUseCase .
type Event ¶
type Event struct { ID uuid.UUID `json:"id,omitempty"` CalendarID uuid.UUID `json:"calendar_id,omitempty"` GoogleID string `json:"google_id,omitempty"` Summary string `json:"title,omitempty"` Location string `json:"location,omitempty"` StartTime time.Time `json:"start_time,omitempty"` EndTime time.Time `json:"end_time,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` IsAllDay bool `json:"is_all_day,omitempty"` }
type EventHistory ¶
type EventHistory struct { ID uuid.UUID `json:"history_id,omitempty"` EventID uuid.UUID `json:"event_id,omitempty"` CalendarID uuid.UUID `json:"calendar_id,omitempty"` ChangeType ChangeTypeEnum `json:"change_type_enum,omitempty"` ChangeTime time.Time `json:"change_time,omitempty"` PrevEvent Event `json:"prev_event"` NewEvent Event `json:"new_event"` }
type EventHistoryRepo ¶
type EventHistoryUseCase ¶
type EventHistoryUseCase struct {
// contains filtered or unexported fields
}
func NewEventHistoryUseCase ¶
func NewEventHistoryUseCase(repo EventHistoryRepo, logger log.Logger) *EventHistoryUseCase
func (*EventHistoryUseCase) DeleteCalendarEventHistory ¶
func (*EventHistoryUseCase) ListCalendarEventHistory ¶
func (uc *EventHistoryUseCase) ListCalendarEventHistory(ctx context.Context, calendarID uuid.UUID) ([]*EventHistory, error)
type EventRepo ¶
type EventRepo interface { Get(ctx context.Context, event *Event) (*Event, error) Create(ctx context.Context, event *Event) (*Event, error) Update(ctx context.Context, event *Event) (*Event, error) Delete(ctx context.Context, event *Event) error List(ctx context.Context, calendarID uuid.UUID) ([]*Event, error) }
EventRepo .
type EventUseCase ¶
type EventUseCase struct {
// contains filtered or unexported fields
}
func NewEventUseCase ¶
func NewEventUseCase(repo EventRepo, logger log.Logger) *EventUseCase
func (*EventUseCase) Delete ¶
func (uc *EventUseCase) Delete(ctx context.Context, event *Event) error
Delete deletes an event
type GoogleListEventsOption ¶
type GoogleListEventsOption struct { TimeMin string TimeMax string UpdatedMin string MaxResults int64 OrderByUpdateTime bool }
GoogleListEventsOption is the option for list events
func (*GoogleListEventsOption) ListEventsCallWithOpts ¶
func (o *GoogleListEventsOption) ListEventsCallWithOpts(call *calendarAPI.EventsListCall) *calendarAPI.EventsListCall
ListEventsCallWithOpts returns a call to list events
func (*GoogleListEventsOption) ListEventsInstancesCallWithOpts ¶
func (o *GoogleListEventsOption) ListEventsInstancesCallWithOpts(call *calendarAPI.EventsInstancesCall) *calendarAPI.EventsInstancesCall
ListEventsInstancesCallWithOpts returns a call to list events instances
type GoogleRepo ¶
type GoogleRepo interface { AuthCodeURL(state string) string TokenExchange(ctx context.Context, code string) (*oauth2.Token, error) TokenSource(ctx context.Context, refreshToken string) (*oauth2.Token, error) UserInfo(ctx context.Context, token *oauth2.Token) (*User, error) ListUserCalendars(ctx context.Context, token *oauth2.Token) ([]*Calendar, error) CreateNewCalendar(ctx context.Context, token *oauth2.Token, calendarName string) (*Calendar, error) CreateCalendarEvent(ctx context.Context, token *oauth2.Token, event *Event, calendarID string) (*Event, error) UpdateCalendarEvent(ctx context.Context, token *oauth2.Token, event *Event, calendarID string) (*Event, error) GetCalendarEvent(ctx context.Context, token *oauth2.Token, event *Event, calendarID string) (*Event, error) DeleteCalendarEvent(ctx context.Context, token *oauth2.Token, event *Event, calendarID string) error ListCalendarEvents(ctx context.Context, token *oauth2.Token, calendarID string, opts *GoogleListEventsOption) ([]*Event, error) }
type GoogleUseCase ¶
type GoogleUseCase struct {
// contains filtered or unexported fields
}
func NewGoogleUseCase ¶
func NewGoogleUseCase(repo GoogleRepo, logger log.Logger) *GoogleUseCase
func (*GoogleUseCase) AuthCodeURL ¶
func (uc *GoogleUseCase) AuthCodeURL(state string) string
AuthCodeURL returns the URL to OAuth 2.0 provider's consent page
func (*GoogleUseCase) ListCalendarEvents ¶
func (uc *GoogleUseCase) ListCalendarEvents(ctx context.Context, token *oauth2.Token, calendarID string, opts *GoogleListEventsOption) ([]*Event, error)
ListCalendarEvents lists calendar events with options
func (*GoogleUseCase) ListUserCalendars ¶
func (uc *GoogleUseCase) ListUserCalendars(ctx context.Context, token *oauth2.Token) ([]*Calendar, error)
ListUserCalendars lists user calendars
func (*GoogleUseCase) TokenExchange ¶
TokenExchange exchanges an authorization code for a token
func (*GoogleUseCase) TokenSource ¶
func (uc *GoogleUseCase) TokenSource(ctx context.Context, refreshToken string) (*oauth2.Token, error)
TokenSource returns a token source
type OpenAIUseCase ¶
type OpenAIUseCase struct {
// contains filtered or unexported fields
}
func NewOpenAIUseCase ¶
func NewOpenAIUseCase(cfg *conf.OpenAI, logger log.Logger, gr GoogleRepo) *OpenAIUseCase
NewOpenAIUseCase .
func (*OpenAIUseCase) GenerateCalendarEvents ¶
type UserUseCase ¶
type UserUseCase struct {
// contains filtered or unexported fields
}
func NewUserUseCase ¶
func NewUserUseCase(repo UserRepo, logger log.Logger) *UserUseCase
func (*UserUseCase) Create ¶
func (uc *UserUseCase) Create(ctx context.Context, user *User) error
Create creates user in database
func (*UserUseCase) GetUserByID ¶
GetUserByID gets user from database by ID string
func (*UserUseCase) GetUserByTGID ¶
GetUserByTGID gets user from database by TGID string