-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
41 lines (31 loc) · 900 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package client
import (
"context"
v1 "github.com/alexfalkowski/bezeichner/api/bezeichner/v1"
)
// Client for bezeichner.
type Client struct {
client v1.ServiceClient
}
// NewClient for bezeichner.
func NewClient(client v1.ServiceClient) *Client {
return &Client{client: client}
}
// GenerateIdentifiers for client.
func (c *Client) GenerateIdentifiers(ctx context.Context, app string, count uint64) ([]string, error) {
req := &v1.GenerateIdentifiersRequest{Application: app, Count: count}
resp, err := c.client.GenerateIdentifiers(ctx, req)
if err != nil {
return nil, err
}
return resp.GetIds(), nil
}
// MapIdentifiers for client.
func (c *Client) MapIdentifiers(ctx context.Context, ids []string) ([]string, error) {
req := &v1.MapIdentifiersRequest{Ids: ids}
resp, err := c.client.MapIdentifiers(ctx, req)
if err != nil {
return nil, err
}
return resp.GetIds(), nil
}