summaryrefslogtreecommitdiff
path: root/golang/pkg/api/register.go
blob: d6c185cd63a69f581590448b2c7a78b216a94fb4 (plain)
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
package api

import (
	"net/url"

	"git.adyxax.org/adyxax/spacetraders/v2/pkg/model"
)

func (c *Client) Register(faction, symbol string) (*model.Register, error) {
	type RegisterRequest struct {
		Faction string `json:"faction"`
		Symbol  string `json:"symbol"`
	}
	uriRef := url.URL{Path: "register"}
	payload := RegisterRequest{
		Faction: faction,
		Symbol:  symbol,
	}
	var response model.Register
	err := c.Send("POST", &uriRef, payload, &response)
	if err != nil {
		return nil, err
	}
	return &response, nil
}