github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/internal/domain/integrationsystem/converter.go (about)

     1  package integrationsystem
     2  
     3  import (
     4  	"github.com/kyma-incubator/compass/components/director/internal/model"
     5  	"github.com/kyma-incubator/compass/components/director/pkg/graphql"
     6  )
     7  
     8  type converter struct{}
     9  
    10  // NewConverter missing godoc
    11  func NewConverter() *converter {
    12  	return &converter{}
    13  }
    14  
    15  // ToGraphQL missing godoc
    16  func (c *converter) ToGraphQL(in *model.IntegrationSystem) *graphql.IntegrationSystem {
    17  	if in == nil {
    18  		return nil
    19  	}
    20  
    21  	return &graphql.IntegrationSystem{
    22  		ID:          in.ID,
    23  		Name:        in.Name,
    24  		Description: in.Description,
    25  	}
    26  }
    27  
    28  // MultipleToGraphQL missing godoc
    29  func (c *converter) MultipleToGraphQL(in []*model.IntegrationSystem) []*graphql.IntegrationSystem {
    30  	intSys := make([]*graphql.IntegrationSystem, 0, len(in))
    31  	for _, r := range in {
    32  		if r == nil {
    33  			continue
    34  		}
    35  
    36  		intSys = append(intSys, c.ToGraphQL(r))
    37  	}
    38  
    39  	return intSys
    40  }
    41  
    42  // InputFromGraphQL missing godoc
    43  func (c *converter) InputFromGraphQL(in graphql.IntegrationSystemInput) model.IntegrationSystemInput {
    44  	return model.IntegrationSystemInput{
    45  		Name:        in.Name,
    46  		Description: in.Description,
    47  	}
    48  }
    49  
    50  // ToEntity missing godoc
    51  func (c *converter) ToEntity(in *model.IntegrationSystem) *Entity {
    52  	if in == nil {
    53  		return nil
    54  	}
    55  	return &Entity{
    56  		ID:          in.ID,
    57  		Name:        in.Name,
    58  		Description: in.Description,
    59  	}
    60  }
    61  
    62  // FromEntity missing godoc
    63  func (c *converter) FromEntity(in *Entity) *model.IntegrationSystem {
    64  	if in == nil {
    65  		return nil
    66  	}
    67  	return &model.IntegrationSystem{
    68  		ID:          in.ID,
    69  		Name:        in.Name,
    70  		Description: in.Description,
    71  	}
    72  }