diff options
| author | Shulhan <ms@kilabit.info> | 2021-01-31 04:56:36 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-01-31 06:16:54 +0700 |
| commit | 6c7bfd42bc1128f5969e9e40b23d6b828601f7cb (patch) | |
| tree | 8138149fde47f135b965be0837b4f8b83421728f /client.go | |
| parent | 734ce643ecbc992834a8f78b44904b82b09bc84b (diff) | |
| download | kamusku-6c7bfd42bc1128f5969e9e40b23d6b828601f7cb.tar.xz | |
all: rewrite the server
This commit move the directClient to different repository called kamusku
and changes the module name from kamusku to kamusd.
Diffstat (limited to 'client.go')
| -rw-r--r-- | client.go | 40 |
1 files changed, 20 insertions, 20 deletions
@@ -1,11 +1,13 @@ -// Copyright 2020, Shulhan <m.shulhan@gmail.com>. All rights reserved. +// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package kamusku +package kamusd import ( "fmt" + + "git.sr.ht/~shulhan/kamusku" ) // @@ -14,7 +16,7 @@ import ( type Client struct { active activeClient api *apiClient - direct *directClient + kbbic *kamusku.KbbiClient } // @@ -23,7 +25,7 @@ type Client struct { func NewClient() (cl *Client, err error) { cl = &Client{} - cl.direct, err = newDirectClient() + cl.kbbic, err = kamusku.NewKbbiClient() if err != nil { return nil, err } @@ -31,7 +33,7 @@ func NewClient() (cl *Client, err error) { cl.api = newAPIClient("") if cl.IsAuthenticated() { - cl.active = cl.direct + cl.active = cl.kbbic } else { cl.active = cl.api } @@ -40,18 +42,16 @@ func NewClient() (cl *Client, err error) { } // -// CariDefinisi lookup definition of words. +// Lookup lookup definition of words. // -func (cl *Client) CariDefinisi(words []string) ( - res DefinisiResponse, err error, -) { +func (cl *Client) Lookup(words []string) (res kamusku.LookupResponse, err error) { if cl.active != nil { - return cl.active.CariDefinisi(words) + return cl.active.Lookup(words) } - res, err = cl.api.CariDefinisi(words) + res, err = cl.api.Lookup(words) if err != nil { - return cl.direct.CariDefinisi(words) + return cl.kbbic.Lookup(words) } return res, nil @@ -62,20 +62,20 @@ func (cl *Client) CariDefinisi(words []string) ( // server. // func (cl *Client) IsAuthenticated() bool { - return cl.direct.isAuthenticated() + return cl.kbbic.IsAuthenticated() } // -// ListKataDasar list all of the root words in dictionary. +// ListRootWords list all of the root words in dictionary. // -func (cl *Client) ListKataDasar() (res DaftarKata, err error) { +func (cl *Client) ListRootWords() (res kamusku.Words, err error) { if cl.active != nil { - return cl.active.ListKataDasar() + return cl.active.ListRootWords() } - res, err = cl.api.ListKataDasar() + res, err = cl.api.ListRootWords() if err != nil { - return cl.direct.ListKataDasar() + return cl.kbbic.ListRootWords() } return res, nil @@ -86,12 +86,12 @@ func (cl *Client) ListKataDasar() (res DaftarKata, err error) { // server. // func (cl *Client) Login(user, pass string) (err error) { - err = cl.direct.login(user, pass) + err = cl.kbbic.Login(user, pass) if err != nil { return fmt.Errorf("Login: %w", err) } - cl.active = cl.direct + cl.active = cl.kbbic return nil } |
