@@ -11,74 +11,74 @@ import (
11
11
)
12
12
13
13
type StemmingDictionariesInterface interface {
14
- Upsert (ctx context.Context , dictionaryId string , wordRootCombinations []api.StemmingDictionaryWord ) ([]* api.StemmingDictionaryWord , error )
15
- UpsertJsonl (ctx context.Context , dictionaryId string , body io.Reader ) (io.ReadCloser , error )
16
- Retrieve (ctx context.Context ) (* api.ListStemmingDictionariesResponse , error )
14
+ Upsert (ctx context.Context , dictionaryId string , wordRootCombinations []api.StemmingDictionaryWord ) ([]* api.StemmingDictionaryWord , error )
15
+ UpsertJsonl (ctx context.Context , dictionaryId string , body io.Reader ) (io.ReadCloser , error )
16
+ Retrieve (ctx context.Context ) (* api.ListStemmingDictionariesResponse , error )
17
17
}
18
18
19
19
type stemmingDictionaries struct {
20
- apiClient APIClientInterface
20
+ apiClient APIClientInterface
21
21
}
22
22
23
23
func (s * stemmingDictionaries ) Upsert (ctx context.Context , dictionaryId string , wordRootCombinations []api.StemmingDictionaryWord ) ([]* api.StemmingDictionaryWord , error ) {
24
- var buf bytes.Buffer
25
- jsonEncoder := json .NewEncoder (& buf )
26
- for _ , combo := range wordRootCombinations {
27
- if err := jsonEncoder .Encode (combo ); err != nil {
28
- return nil , err
29
- }
30
- }
24
+ var buf bytes.Buffer
25
+ jsonEncoder := json .NewEncoder (& buf )
26
+ for _ , combo := range wordRootCombinations {
27
+ if err := jsonEncoder .Encode (combo ); err != nil {
28
+ return nil , err
29
+ }
30
+ }
31
31
32
- response , err := s .UpsertJsonl (ctx , dictionaryId , & buf )
33
- if err != nil {
34
- return nil , err
35
- }
32
+ response , err := s .UpsertJsonl (ctx , dictionaryId , & buf )
33
+ if err != nil {
34
+ return nil , err
35
+ }
36
36
37
- var result []* api.StemmingDictionaryWord
38
- jsonDecoder := json .NewDecoder (response )
39
- for jsonDecoder .More () {
40
- var docResult * api.StemmingDictionaryWord
41
- if err := jsonDecoder .Decode (& docResult ); err != nil {
42
- return result , err
43
- }
44
- result = append (result , docResult )
45
- }
37
+ var result []* api.StemmingDictionaryWord
38
+ jsonDecoder := json .NewDecoder (response )
39
+ for jsonDecoder .More () {
40
+ var docResult * api.StemmingDictionaryWord
41
+ if err := jsonDecoder .Decode (& docResult ); err != nil {
42
+ return result , err
43
+ }
44
+ result = append (result , docResult )
45
+ }
46
46
47
- return result , nil
47
+ return result , nil
48
48
}
49
49
50
50
func (s * stemmingDictionaries ) UpsertJsonl (ctx context.Context , dictionaryId string , body io.Reader ) (io.ReadCloser , error ) {
51
- params := & api.ImportStemmingDictionaryParams {
52
- Id : dictionaryId ,
53
- }
54
-
55
- response , err := s .apiClient .ImportStemmingDictionaryWithBody (ctx ,
56
- params , "application/octet-stream" , body )
57
- if err != nil {
58
- return nil , err
59
- }
60
- if response .StatusCode != http .StatusOK {
61
- defer response .Body .Close ()
62
- body , _ := io .ReadAll (response .Body )
63
- return nil , & HTTPError {Status : response .StatusCode , Body : body }
64
- }
65
- return response .Body , nil
51
+ params := & api.ImportStemmingDictionaryParams {
52
+ Id : dictionaryId ,
53
+ }
54
+
55
+ response , err := s .apiClient .ImportStemmingDictionaryWithBody (ctx ,
56
+ params , "application/octet-stream" , body )
57
+ if err != nil {
58
+ return nil , err
59
+ }
60
+ if response .StatusCode != http .StatusOK {
61
+ defer response .Body .Close ()
62
+ body , _ := io .ReadAll (response .Body )
63
+ return nil , & HTTPError {Status : response .StatusCode , Body : body }
64
+ }
65
+ return response .Body , nil
66
66
}
67
67
68
68
func (s * stemmingDictionaries ) Retrieve (ctx context.Context ) (* api.ListStemmingDictionariesResponse , error ) {
69
- response , err := s .apiClient .ListStemmingDictionariesWithResponse (ctx )
70
- if err != nil {
71
- return nil , err
72
- }
73
- if response .JSON200 == nil {
74
- emptySlice := make ([]string , 0 )
75
- return & api.ListStemmingDictionariesResponse {
76
- JSON200 : & struct {
77
- Dictionaries * []string `json:"dictionaries,omitempty"`
78
- }{
79
- Dictionaries : & emptySlice ,
80
- },
81
- }, nil
82
- }
83
- return response , nil
84
- }
69
+ response , err := s .apiClient .ListStemmingDictionariesWithResponse (ctx )
70
+ if err != nil {
71
+ return nil , err
72
+ }
73
+ if response .JSON200 == nil {
74
+ emptySlice := make ([]string , 0 )
75
+ return & api.ListStemmingDictionariesResponse {
76
+ JSON200 : & struct {
77
+ Dictionaries * []string `json:"dictionaries,omitempty"`
78
+ }{
79
+ Dictionaries : & emptySlice ,
80
+ },
81
+ }, nil
82
+ }
83
+ return response , nil
84
+ }
0 commit comments