lib/api/voip/voip_models/callflow.go

250 lines
5.8 KiB
Go

// Code generated by go-swagger; DO NOT EDIT.
// (c) 2012-2020 by Telnexus LLC
// All rights reserved worldwide.
// Proprietary product; unlicensed use is not allowed
package voip_models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"strconv"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// Callflow Call flows describe steps to take in order to process a phone call. They are trees of information related to a phone call such as "answer, play file, record file" etc. that are logically grouped together and ordered.
//
// swagger:model Callflow
type Callflow struct {
// feature code
FeatureCode *CallflowFeatureCode `json:"FeatureCode,omitempty"`
// Flags set by external applications
Flags []string `json:"Flags"`
// A callflow node defines a module to execute, data to provide to that module, and zero or more children to branch to
Flow *CallFlowAction `json:"Flow,omitempty"`
// Telnexus Record Identifier
ID string `json:"ID,omitempty"`
// A list of static numbers that the callflow should execute for
// Unique: true
Numbers []string `json:"Numbers"`
// A list of regular expressions that the callflow should execute for, with optional capture groups
Patterns []string `json:"Patterns"`
}
// Validate validates this callflow
func (m *Callflow) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateFeatureCode(formats); err != nil {
res = append(res, err)
}
if err := m.validateFlow(formats); err != nil {
res = append(res, err)
}
if err := m.validateNumbers(formats); err != nil {
res = append(res, err)
}
if err := m.validatePatterns(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Callflow) validateFeatureCode(formats strfmt.Registry) error {
if swag.IsZero(m.FeatureCode) { // not required
return nil
}
if m.FeatureCode != nil {
if err := m.FeatureCode.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("FeatureCode")
}
return err
}
}
return nil
}
func (m *Callflow) validateFlow(formats strfmt.Registry) error {
if swag.IsZero(m.Flow) { // not required
return nil
}
if m.Flow != nil {
if err := m.Flow.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("Flow")
}
return err
}
}
return nil
}
func (m *Callflow) validateNumbers(formats strfmt.Registry) error {
if swag.IsZero(m.Numbers) { // not required
return nil
}
if err := validate.UniqueItems("Numbers", "body", m.Numbers); err != nil {
return err
}
for i := 0; i < len(m.Numbers); i++ {
if err := validate.MinLength("Numbers"+"."+strconv.Itoa(i), "body", m.Numbers[i], 1); err != nil {
return err
}
if err := validate.MaxLength("Numbers"+"."+strconv.Itoa(i), "body", m.Numbers[i], 36); err != nil {
return err
}
}
return nil
}
func (m *Callflow) validatePatterns(formats strfmt.Registry) error {
if swag.IsZero(m.Patterns) { // not required
return nil
}
for i := 0; i < len(m.Patterns); i++ {
if err := validate.MinLength("Patterns"+"."+strconv.Itoa(i), "body", m.Patterns[i], 1); err != nil {
return err
}
}
return nil
}
// ContextValidate validate this callflow based on the context it is used
func (m *Callflow) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateFeatureCode(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateFlow(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Callflow) contextValidateFeatureCode(ctx context.Context, formats strfmt.Registry) error {
if m.FeatureCode != nil {
if err := m.FeatureCode.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("FeatureCode")
}
return err
}
}
return nil
}
func (m *Callflow) contextValidateFlow(ctx context.Context, formats strfmt.Registry) error {
if m.Flow != nil {
if err := m.Flow.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("Flow")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *Callflow) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *Callflow) UnmarshalBinary(b []byte) error {
var res Callflow
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}
// CallflowFeatureCode When the callflow is used as a featurecode this object tracks the intended match of the pattern and name of the feature
//
// swagger:model CallflowFeatureCode
type CallflowFeatureCode struct {
// name
Name string `json:"name,omitempty"`
// number
Number string `json:"number,omitempty"`
}
// Validate validates this callflow feature code
func (m *CallflowFeatureCode) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this callflow feature code based on context it is used
func (m *CallflowFeatureCode) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *CallflowFeatureCode) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *CallflowFeatureCode) UnmarshalBinary(b []byte) error {
var res CallflowFeatureCode
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}