customerio.go
func (c *CustomerIO) AddDevice(customerID string, deviceID string, platform string, data map[string]interface{}) error {
	if customerID == "" {
		return errors.New("customerID is a required field")
	}
	if deviceID == "" {
		return errors.New("deviceID is a required field")
	}
	if platform == "" {
		return errors.New("platform is a required field")
	}

	body := map[string]map[string]interface{}{"device": {"id": deviceID, "platform": platform}}
	for k, v := range data {
		body["device"][k] = v
	}
	j, err := json.Marshal(body)

	if err != nil {
		return err
	}

	status, responseBody, err := c.request("PUT", c.deviceURL(customerID), j)

	if err != nil {
		return err
	} else if status != 200 {
		return &CustomerIOError{status, c.deviceURL(customerID), responseBody}
	}

	return nil
}
func (c *CustomerIO) AddDevice(customerID string, deviceID string, platform string, data map[string]interface{}) error {
	if customerID == "" {
		return errors.New("customerID is a required field")
	}
	if deviceID == "" {
		return errors.New("deviceID is a required field")
	}
	if platform == "" {
		return errors.New("platform is a required field")
	}

	body := map[string]map[string]interface{}{"device": {"id": deviceID, "platform": platform}}
	for k, v := range data {
		body["device"][k] = v
	}
	j, err := json.Marshal(body)

	if err != nil {
		return err
	}

	status, responseBody, err := c.request("PUT", c.deviceURL(customerID), j)

	if err != nil {
		return err
	} else if status != 200 {
		return &CustomerIOError{status, c.deviceURL(customerID), responseBody}
	}

	return nil
}
func ( c * CustomerIO ) AddDevice ( customerID string , deviceID string , platform string , data map [ string ] interface { } ) error { if customerID == " " { return errors . New ( " " ) } if deviceID == " " { return errors . New ( " " ) } if platform == " " { return errors . New ( " " ) } body := map [ string ] map [ string ] interface { } { " " : { " " : deviceID , " " : platform } } for k , v := range data { body [ " " ] [ k ] = v } j , err := json . Marshal ( body ) if err != nil { return err } status , responseBody , err := c . request ( " " , c . deviceURL ( customerID ) , j ) if err != nil { return err } else if status != 200 { return & CustomerIOError { status , c . deviceURL ( customerID ) , responseBody } } return nil }
// AddDevice adds a device for a customer
AddDevice adds a device for a customer