Commit 5ef0bac3 authored by Sybren A. Stüvel's avatar Sybren A. Stüvel

Fixed issue when we get device ID 0

parent f3af392d
......@@ -41,10 +41,10 @@ type Credentials struct {
APIMode string `yaml:"apiMode"` // "production" or "sandbox"
APIKey string `yaml:"apiKey"`
InstallationToken string `yaml:"installationToken"`
ServerPublicKey string `yaml:"serverPublicKey"`
InstallationToken string `yaml:"installationToken,omitempty"`
ServerPublicKey string `yaml:"serverPublicKey,omitempty"`
serverPublicKey *rsa.PublicKey
DeviceID int `yaml:"deviceID"`
DeviceID *int `yaml:"deviceID,omitempty"`
// LoadCredentials loads credentials from a YAML file.
......@@ -40,8 +40,8 @@ type deviceServerResponse struct {
// CheckDeviceServer registers this device with bunq if we don't have a device ID yet.
func (c *Client) CheckDeviceServer(description string, permittedIPs []string) {
if c.creds.DeviceID != 0 {
log.WithField("deviceID", c.creds.DeviceID).Debug("device ID is known")
if c.creds.DeviceID != nil {
log.WithField("deviceID", *c.creds.DeviceID).Debug("device ID is known")
c.PostDeviceServer(description, permittedIPs)
......@@ -63,7 +63,7 @@ func (c *Client) PostDeviceServer(description string, permittedIPs []string) {
response := deviceServerResponse{}
MergeStructs(wrappedResponse.Response, &response)
c.creds.DeviceID = response.ID.ID
c.creds.DeviceID = &response.ID.ID
log.WithField("id", c.creds.DeviceID).Info("registered device device ID")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment