func ConvertUser(request *goa.RequestData, identity *account.Identity, user *account.User) *app.Identity {
	uuid := identity.ID
	id := uuid.String()
	fullName := identity.Username
	userName := identity.Username
	providerType := identity.ProviderType
	var imageURL string
	var bio string
	var userURL string
	var email string
	var contextInformation workitem.Fields

	if user != nil {
		fullName = user.FullName
		imageURL = user.ImageURL
		bio = user.Bio
		userURL = user.URL
		email = user.Email
		contextInformation = user.ContextInformation
	}

	// The following will be used for ContextInformation.
	// The simplest way to represent is to have all fields
	// as a SimpleType. During conversion from 'model' to 'app',
	// the value would be returned 'as is'.

	simpleFieldDefinition := workitem.FieldDefinition{
		Type: workitem.SimpleType{Kind: workitem.KindString},
	}

	converted := app.Identity{
		Data: &app.IdentityData{
			ID:   &id,
			Type: "identities",
			Attributes: &app.IdentityDataAttributes{
				Username:           &userName,
				FullName:           &fullName,
				ImageURL:           &imageURL,
				Bio:                &bio,
				URL:                &userURL,
				ProviderType:       &providerType,
				Email:              &email,
				ContextInformation: workitem.Fields{},
			},
			Links: createUserLinks(request, uuid),
		},
	}
	for name, value := range contextInformation {
		if value == nil {
			// this can be used to unset a key in contextInformation
			continue
		}
		convertedValue, err := simpleFieldDefinition.ConvertFromModel(name, value)
		if err != nil {
			log.Error(nil, map[string]interface{}{
				"err": err,
			}, "Unable to convert user context field %s ", name)
			converted.Data.Attributes.ContextInformation[name] = nil
		}
		converted.Data.Attributes.ContextInformation[name] = convertedValue
	}
	return &converted
}
// ConvertUser converts a complete Identity object into REST representation
ConvertUser converts a complete Identity object into REST representation
// ConvertUser converts a complete Identity object into REST representation
func ConvertUser(request *goa.RequestData, identity *account.Identity, user *account.User) *app.Identity {
	uuid := identity.ID
	id := uuid.String()
	fullName := identity.Username
	userName := identity.Username
	providerType := identity.ProviderType
	var imageURL string
	var bio string
	var userURL string
	var email string
	var contextInformation workitem.Fields
	if user != nil {
		fullName = user.FullName
		imageURL = user.ImageURL
		bio = user.Bio
		userURL = user.URL
		email = user.Email
		contextInformation = user.ContextInformation
	}
	simpleFieldDefinition := workitem.FieldDefinition{
		Type: workitem.SimpleType{Kind: workitem.KindString},
	}
	converted := app.Identity{
		Data: &app.IdentityData{
			ID:   &id,
			Type: "identities",
			Attributes: &app.IdentityDataAttributes{
				Username:           &userName,
				FullName:           &fullName,
				ImageURL:           &imageURL,
				Bio:                &bio,
				URL:                &userURL,
				ProviderType:       &providerType,
				Email:              &email,
				ContextInformation: workitem.Fields{},
			},
			Links: createUserLinks(request, uuid),
		},
	}
	for name, value := range contextInformation {
		if value == nil {
			continue
		}
		convertedValue, err := simpleFieldDefinition.ConvertFromModel(name, value)
		if err != nil {
			log.Error(nil, map[string]interface{}{
				"err": err,
			}, "Unable to convert user context field %s ", name)
			converted.Data.Attributes.ContextInformation[name] = nil
		}
		converted.Data.Attributes.ContextInformation[name] = convertedValue
	}
	return &converted
}
func ConvertUser ( request * goa . RequestData , identity * account . Identity , user * account . User ) * app . Identity { uuid := identity . ID id := uuid . String ( ) fullName := identity . Username userName := identity . Username providerType := identity . ProviderType var imageURL string var bio string var userURL string var email string var contextInformation workitem . Fields if user != nil { fullName = user . FullName imageURL = user . ImageURL bio = user . Bio userURL = user . URL email = user . Email contextInformation = user . ContextInformation } simpleFieldDefinition := workitem . FieldDefinition { Type : workitem . SimpleType { Kind : workitem . KindString } , } converted := app . Identity { Data : & app . IdentityData { ID : & id , Type : " " , Attributes : & app . IdentityDataAttributes { Username : & userName , FullName : & fullName , ImageURL : & imageURL , Bio : & bio , URL : & userURL , ProviderType : & providerType , Email : & email , ContextInformation : workitem . Fields { } , } , Links : createUserLinks ( request , uuid ) , } , } for name , value := range contextInformation { if value == nil { continue } convertedValue , err := simpleFieldDefinition . ConvertFromModel ( name , value ) if err != nil { log . Error ( nil , map [ string ] interface { } { " " : err , } , " " , name ) converted . Data . Attributes . ContextInformation [ name ] = nil } converted . Data . Attributes . ContextInformation [ name ] = convertedValue } return & converted }
ConvertUser converts a complete Identity object into REST representation
ConvertUser converts a complete Identity object into REST representation
// The following will be used for ContextInformation. // The simplest way to represent is to have all fields // as a SimpleType. During conversion from 'model' to 'app', // the value would be returned 'as is'. // this can be used to unset a key in contextInformation