Beispiel #1
0
// NewUserResponse creates new UserResponse instance
func NewUserResponse(o *User) (*UserResponse, error) {
	response := &UserResponse{
		ID:        o.ID,
		Email:     o.OauthUser.Username,
		FirstName: o.FirstName.String,
		LastName:  o.LastName.String,
		Role:      o.OauthUser.RoleID.String,
		Confirmed: o.Confirmed,
		CreatedAt: util.FormatTime(&o.CreatedAt),
		UpdatedAt: util.FormatTime(&o.UpdatedAt),
	}

	// Set the self link
	response.SetLink(
		"self", // name
		fmt.Sprintf("/v1/users/%d", o.ID), // href
		"", // title
	)

	return response, nil
}
Beispiel #2
0
// NewConfirmationResponse creates new ConfirmationResponse instance
func NewConfirmationResponse(o *Confirmation) (*ConfirmationResponse, error) {
	response := &ConfirmationResponse{
		EmailTokenResponse: EmailTokenResponse{
			ID:          o.ID,
			Reference:   o.Reference,
			EmailSent:   o.EmailSent,
			EmailSentAt: util.FormatTime(o.EmailSentAt),
			ExpiresAt:   util.FormatTime(&o.ExpiresAt),
			CreatedAt:   util.FormatTime(&o.CreatedAt),
			UpdatedAt:   util.FormatTime(&o.UpdatedAt),
		},
		UserID: o.User.ID,
	}

	// Set the self link
	response.SetLink(
		"self", // name
		fmt.Sprintf("/v1/confirmations/%d", o.ID), // href
		"", // title
	)

	return response, nil
}