diff --git a/pit.go b/pit.go index 22871309..e6594bf0 100644 --- a/pit.go +++ b/pit.go @@ -17,11 +17,14 @@ type PointInTime struct { } // NewPointInTime creates a new PointInTime. -func NewPointInTime(id, keepAlive string) *PointInTime { - return &PointInTime{ +func NewPointInTime(id string, keepAlive ...string) *PointInTime { + pit := &PointInTime{ Id: id, - KeepAlive: keepAlive, } + if len(keepAlive) > 1 { + pit.KeepAlive = keepAlive[0] + } + return pit } // Source generates the JSON serializable fragment for the PointInTime. @@ -29,8 +32,13 @@ func (pit *PointInTime) Source() (interface{}, error) { if pit == nil { return nil, nil } - return map[string]interface{}{ - "id": pit.Id, - "keep_alive": pit.KeepAlive, - }, nil + source := map[string]interface{}{ + "id": pit.Id, + } + + if pit.KeepAlive != "" { + source["keep_alive"] = pit.KeepAlive + } + + return source, nil }