2019-07-17 05:28:37 +00:00
|
|
|
package browsers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
2019-07-25 05:35:09 +00:00
|
|
|
func NewAPI(db *Database) *API {
|
|
|
|
return &API{db: db}
|
2019-07-17 05:28:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// API is class with methods available over RPC.
|
|
|
|
type API struct {
|
2019-07-25 05:35:09 +00:00
|
|
|
db *Database
|
2019-07-17 05:28:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (api *API) AddBrowser(ctx context.Context, browser Browser) error {
|
2019-07-25 05:35:09 +00:00
|
|
|
return api.db.InsertBrowser(browser)
|
2019-07-17 05:28:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (api *API) GetBrowsers(ctx context.Context) ([]*Browser, error) {
|
2019-07-25 05:35:09 +00:00
|
|
|
return api.db.GetBrowsers()
|
2019-07-17 05:28:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (api *API) DeleteBrowser(ctx context.Context, id string) error {
|
2019-07-25 05:35:09 +00:00
|
|
|
return api.db.DeleteBrowser(id)
|
2019-07-17 05:28:37 +00:00
|
|
|
}
|