func NewSegment(listID int, conditions []*Condition, name, apiKey string) (*Segment, error) {
	payload, err := json.Marshal(Segment{
		ListID:     listID,
		Conditions: conditions,
		Name:       name,
	})
	if err != nil {
		return nil, err
	}

	response, err := SendPOSTRequest(apiKey, "/contactdb/segments", string(payload))
	if err != nil {
		return nil, err
	}

	segment := &Segment{}
	err = json.Unmarshal(response, segment)
	if err != nil {
		return nil, err
	}

	return segment, nil
}
// NewSegment creats a new segment. (POST)
NewSegment creats a new segment. (POST)
// NewSegment creats a new segment . ( POST )
func NewSegment(listID int, conditions []*Condition, name, apiKey string) (*Segment, error) {
	payload, err := json.Marshal(Segment{
		ListID:     listID,
		Conditions: conditions,
		Name:       name,
	})
	if err != nil {
		return nil, err
	}
	response, err := SendPOSTRequest(apiKey, "/contactdb/segments", string(payload))
	if err != nil {
		return nil, err
	}
	segment := &Segment{}
	err = json.Unmarshal(response, segment)
	if err != nil {
		return nil, err
	}
	return segment, nil
}
func NewSegment ( listID int , conditions [ ] * Condition , name , apiKey string ) ( * Segment , error ) { payload , err := json . Marshal ( Segment { ListID : listID , Conditions : conditions , Name : name , } ) if err != nil { return nil , err } response , err := SendPOSTRequest ( apiKey , " " , string ( payload ) ) if err != nil { return nil , err } segment := & Segment { } err = json . Unmarshal ( response , segment ) if err != nil { return nil , err } return segment , nil }
NewSegment creats a new segment.
NewSegment creats a new segment .