// BuildJson constructs the Json file with default subscription properties.
// It returns the encoded JSON.
BuildJson constructs the Json file with default subscription properties.
It returns the encoded JSON.
// BuildJson constructs the Json file with default subscription properties . // It returns the encoded JSON .
func (s SubscriptionProperties) BuildJson() ([]byte, error) {
	d := DefaultSubscriptionProperties()
	v := map[string]interface{}{
		"id":                s.Id,
		"keepaliveInterval": s.KeepaliveInterval,
		"publishInterval":   s.PublishInterval,
		"errorInterval":     s.ErrorInterval,
	}
	v["rules"] = make([]interface{}, 0)
	if s.QueueSize != d.QueueSize ||
		s.QueueBehaviour != d.QueueBehaviour {
		p := make(map[string]interface{})
		p["rule_type"] = "Queueing"
		r := make(map[string]interface{})
		p["rule"] = r
		r["queueSize"] = s.QueueSize
		r["behaviour"] = s.QueueBehaviour
		rs := v["rules"].([]interface{})
		rs = append(rs, p)
		v["rules"] = rs
	}
	if s.DeadBandValue != d.DeadBandValue {
		p := make(map[string]interface{})
		p["rule_type"] = "DataChangeFilter"
		r := make(map[string]interface{})
		p["rule"] = r
		r["deadBandValue"] = s.DeadBandValue
		rs := v["rules"].([]interface{})
		rs = append(rs, p)
		v["rules"] = rs
	}
	if s.DataChangeTrigger != d.DataChangeTrigger ||
		s.BrowseListChange != d.BrowseListChange ||
		s.MetaDataChange != d.MetaDataChange {
		p := make(map[string]interface{})
		p["rule_type"] = "ChangeEvents"
		r := make(map[string]interface{})
		p["rule"] = r
		switch s.DataChangeTrigger {
		case fbs.DataChangeTriggerStatus:
			r["valueChange"] = "Status"
		case fbs.DataChangeTriggerStatusValue:
			r["valueChange"] = "StatusValue"
		case fbs.DataChangeTriggerStatusValueTimestamp:
			r["valueChange"] = "StatusValueTimestamp"
		}
		r["browselistChange"] = s.BrowseListChange
		r["metadataChange"] = s.MetaDataChange
		rs := v["rules"].([]interface{})
		rs = append(rs, p)
		v["rules"] = rs
	}
	if s.CountingSubscriptions != d.CountingSubscriptions {
		p := make(map[string]interface{})
		p["rule_type"] = "Counting"
		r := make(map[string]interface{})
		p["rule"] = r
		r["countSubscriptions"] = s.CountingSubscriptions
		rs := v["rules"].([]interface{})
		rs = append(rs, p)
		v["rules"] = rs
	}
	return json.Marshal(v)
}
func ( s SubscriptionProperties ) BuildJson ( ) ( [ ] byte , error ) { d := DefaultSubscriptionProperties ( ) v := map [ string ] interface { } { " " : s . Id , " " : s . KeepaliveInterval , " " : s . PublishInterval , " " : s . ErrorInterval , } v [ " " ] = make ( [ ] interface { } , 0 ) if s . QueueSize != d . QueueSize || s . QueueBehaviour != d . QueueBehaviour { p := make ( map [ string ] interface { } ) p [ " " ] = " " r := make ( map [ string ] interface { } ) p [ " " ] = r r [ " " ] = s . QueueSize r [ " " ] = s . QueueBehaviour rs := v [ " " ] . ( [ ] interface { } ) rs = append ( rs , p ) v [ " " ] = rs } if s . DeadBandValue != d . DeadBandValue { p := make ( map [ string ] interface { } ) p [ " " ] = " " r := make ( map [ string ] interface { } ) p [ " " ] = r r [ " " ] = s . DeadBandValue rs := v [ " " ] . ( [ ] interface { } ) rs = append ( rs , p ) v [ " " ] = rs } if s . DataChangeTrigger != d . DataChangeTrigger || s . BrowseListChange != d . BrowseListChange || s . MetaDataChange != d . MetaDataChange { p := make ( map [ string ] interface { } ) p [ " " ] = " " r := make ( map [ string ] interface { } ) p [ " " ] = r switch s . DataChangeTrigger { case fbs . DataChangeTriggerStatus : r [ " " ] = " " case fbs . DataChangeTriggerStatusValue : r [ " " ] = " " case fbs . DataChangeTriggerStatusValueTimestamp : r [ " " ] = " " } r [ " " ] = s . BrowseListChange r [ " " ] = s . MetaDataChange rs := v [ " " ] . ( [ ] interface { } ) rs = append ( rs , p ) v [ " " ] = rs } if s . CountingSubscriptions != d . CountingSubscriptions { p := make ( map [ string ] interface { } ) p [ " " ] = " " r := make ( map [ string ] interface { } ) p [ " " ] = r r [ " " ] = s . CountingSubscriptions rs := v [ " " ] . ( [ ] interface { } ) rs = append ( rs , p ) v [ " " ] = rs } return json . Marshal ( v ) }
BuildJson constructs the Json file with default subscription properties.
BuildJson constructs the Json file with default subscription properties .