receiver

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func NewService

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

NewService returns service struct

func NewSlackHelper

func NewSlackHelper(httpClient Doer, encryptionKey string) (*slackHelper, error)

Types

type Channel

type Channel struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

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 Exchanger

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

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 MockReceiverRepository

type MockReceiverRepository struct {
	mock.Mock
}

MockReceiverRepository is an autogenerated mock type for the ReceiverRepository type

func (*MockReceiverRepository) Create

func (_m *MockReceiverRepository) Create(_a0 *Receiver) (*Receiver, error)

Create provides a mock function with given fields: _a0

func (*MockReceiverRepository) Delete

func (_m *MockReceiverRepository) Delete(_a0 uint64) error

Delete provides a mock function with given fields: _a0

func (*MockReceiverRepository) Get

func (_m *MockReceiverRepository) Get(_a0 uint64) (*Receiver, error)

Get provides a mock function with given fields: _a0

func (*MockReceiverRepository) List

func (_m *MockReceiverRepository) List() ([]*Receiver, error)

List provides a mock function with given fields:

func (*MockReceiverRepository) Migrate

func (_m *MockReceiverRepository) Migrate() error

Migrate provides a mock function with given fields:

func (*MockReceiverRepository) Update

func (_m *MockReceiverRepository) Update(_a0 *Receiver) (*Receiver, error)

Update provides a mock function with given fields: _a0

type MockSlackHelper

type MockSlackHelper struct {
	mock.Mock
}

MockSlackHelper is an autogenerated mock type for the SlackHelper type

func (*MockSlackHelper) Decrypt

func (_m *MockSlackHelper) Decrypt(_a0 string) (string, error)

Decrypt provides a mock function with given fields: _a0

func (*MockSlackHelper) Encrypt

func (_m *MockSlackHelper) Encrypt(_a0 string) (string, error)

Encrypt provides a mock function with given fields: _a0

func (*MockSlackHelper) PostTransform

func (_m *MockSlackHelper) PostTransform(_a0 *Receiver) (*Receiver, error)

PostTransform provides a mock function with given fields: _a0

func (*MockSlackHelper) PreTransform

func (_m *MockSlackHelper) PreTransform(_a0 *domain.Receiver) (*domain.Receiver, error)

PreTransform provides a mock function with given fields: _a0

type MockSlackRepository

type MockSlackRepository struct {
	mock.Mock
}

MockSlackRepository is an autogenerated mock type for the MockSlackRepository type

func (*MockSlackRepository) GetWorkspaceChannels

func (_m *MockSlackRepository) GetWorkspaceChannels(_a0 string) ([]Channel, error)

GetWorkspaceChannel provides a mock function with given fields: _a0

type Receiver

type Receiver struct {
	Id             uint64 `gorm:"primarykey"`
	Name           string
	Type           string
	Labels         StringStringMap    `gorm:"type:jsonb" sql:"type:jsonb" `
	Configurations StringInterfaceMap `gorm:"type:jsonb" sql:"type:jsonb" `
	Data           StringInterfaceMap `gorm:"-"`
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

type ReceiverRepository

type ReceiverRepository interface {
	Migrate() error
	List() ([]*Receiver, error)
	Create(*Receiver) (*Receiver, error)
	Get(uint64) (*Receiver, error)
	Update(*Receiver) (*Receiver, error)
	Delete(uint64) error
}

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) *Repository

NewRepository returns repository struct

func (Repository) Create

func (r Repository) Create(receiver *Receiver) (*Receiver, error)

func (Repository) Delete

func (r Repository) Delete(id uint64) error

func (Repository) Get

func (r Repository) Get(id uint64) (*Receiver, error)

func (Repository) List

func (r Repository) List() ([]*Receiver, error)

func (Repository) Migrate

func (r Repository) Migrate() error

func (Repository) Update

func (r Repository) Update(receiver *Receiver) (*Receiver, error)

type Service

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

Service handles business logic

func (Service) CreateReceiver

func (service Service) CreateReceiver(receiver *domain.Receiver) (*domain.Receiver, error)

func (Service) DeleteReceiver

func (service Service) DeleteReceiver(id uint64) error

func (Service) GetReceiver

func (service Service) GetReceiver(id uint64) (*domain.Receiver, error)

func (Service) ListReceivers

func (service Service) ListReceivers() ([]*domain.Receiver, error)

func (Service) Migrate

func (service Service) Migrate() error

func (Service) UpdateReceiver

func (service Service) UpdateReceiver(receiver *domain.Receiver) (*domain.Receiver, 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)

type SlackHelper

type SlackHelper interface {
	Transformer
	Encrypt(string) (string, error)
	Decrypt(string) (string, error)
}

type SlackRepository

type SlackRepository interface {
	GetWorkspaceChannels(string) ([]Channel, error)
}

func NewSlackRepository

func NewSlackRepository() SlackRepository

type StringInterfaceMap

type StringInterfaceMap map[string]interface{}

func (*StringInterfaceMap) Scan

func (m *StringInterfaceMap) Scan(value interface{}) error

func (StringInterfaceMap) Value

func (a StringInterfaceMap) Value() (driver.Value, error)

type StringStringMap

type StringStringMap map[string]string

func (*StringStringMap) Scan

func (m *StringStringMap) Scan(value interface{}) error

func (StringStringMap) Value

func (a StringStringMap) Value() (driver.Value, error)

type Transformer

type Transformer interface {
	PreTransform(*domain.Receiver) (*domain.Receiver, error)
	PostTransform(*Receiver) (*Receiver, error)
}

Jump to

Keyboard shortcuts

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