codeexchange

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const OAuthServerEndpoint = "https://slack.com/api/oauth.v2.access"

Variables

This section is empty.

Functions

func NewService

func NewService(db *gorm.DB, httpClient Doer, slackAppConfig domain.SlackApp, encryptionKey string) (domain.CodeExchangeService, error)

NewService returns repository struct

Types

type AccessToken

type AccessToken struct {
	ID          uint `gorm:"primarykey"`
	CreatedAt   time.Time
	UpdatedAt   time.Time
	AccessToken string
	Workspace   string
}

type CodeExchangeHTTPResponse

type CodeExchangeHTTPResponse struct {
	AccessToken string `json:"access_token"`
	Team        struct {
		Name string `json:"name"`
	} `json:"team"`
	Ok bool `json:"ok"`
}

type Doer

type Doer interface {
	Do(req *http.Request) (*http.Response, error)
}

type DoerMock

type DoerMock struct {
	mock.Mock
}

DoerMock is an autogenerated mock type for the Doer type

func (*DoerMock) Do

func (_m *DoerMock) Do(req *http.Request) (*http.Response, error)

Do provides a mock function with given fields: req

type ExchangeRepository

type ExchangeRepository interface {
	Upsert(*AccessToken) error
	Get(string) (string, error)
	Migrate() error
}

type Exchanger

type Exchanger interface {
	Exchange(string, string, string) (CodeExchangeHTTPResponse, error)
}

type MockExchangeRepository

type MockExchangeRepository struct {
	mock.Mock
}

MockExchangeRepository is an autogenerated mock type for the MockExchangeRepository type

func (*MockExchangeRepository) Get

func (_m *MockExchangeRepository) Get(_a0 string) (string, error)

Get provides a mock function with given fields: _a0

func (*MockExchangeRepository) Migrate

func (_m *MockExchangeRepository) Migrate() error

Migrate provides a mock function with given fields:

func (*MockExchangeRepository) Upsert

func (_m *MockExchangeRepository) Upsert(_a0 *AccessToken) error

Upsert provides a mock function with given fields: _a0

type MockExchanger

type MockExchanger struct {
	mock.Mock
}

MockExchanger is an autogenerated mock type for the Exchanger type

func (*MockExchanger) Exchange

func (_m *MockExchanger) Exchange(_a0 string, _a1 string, _a2 string) (CodeExchangeHTTPResponse, error)

Exchange provides a mock function with given fields: _a0, _a1, _a2

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository talks to the store to read or insert data

func NewRepository

func NewRepository(db *gorm.DB, encryptionKey string) (*Repository, error)

NewRepository returns repository struct

func (Repository) Get

func (r Repository) Get(workspace string) (string, error)

func (Repository) Migrate

func (r Repository) Migrate() error

func (Repository) Upsert

func (r Repository) Upsert(accessToken *AccessToken) error

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service handles business logic

func (Service) Exchange

func (service Service) Exchange(payload domain.OAuthPayload) (*domain.OAuthExchangeResponse, error)

func (Service) GetToken

func (service Service) GetToken(workspace string) (string, error)

func (Service) Migrate

func (service Service) Migrate() error

type SlackClient

type SlackClient struct {
	// contains filtered or unexported fields
}

func NewSlackClient

func NewSlackClient(doer Doer) *SlackClient

func (*SlackClient) Exchange

func (c *SlackClient) Exchange(code, clientID, clientSecret string) (CodeExchangeHTTPResponse, error)

Jump to

Keyboard shortcuts

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