// Code generated by go-swagger; DO NOT EDIT.

package types

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"
	"encoding/json"
	"strconv"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
	"github.com/go-openapi/validate"
)

// GetUserInfoResponse get user info response
//
// swagger:model getUserInfoResponse
type GetUserInfoResponse struct {

	// Email address of user, if available
	// Example: user@example.com
	// Max Length: 255
	// Format: email
	Email strfmt.Email `json:"email,omitempty"`

	// Auth-Scopes of the user, if available
	// Example: ["app"]
	Scopes []string `json:"scopes"`

	// ID of user
	// Example: 82ebdfad-c586-4407-a873-4cc1c33d56fc
	// Required: true
	Sub *string `json:"sub"`

	// Unix timestamp the user's info was last updated at
	// Example: 1591960808
	// Required: true
	UpdatedAt *int64 `json:"updated_at"`
}

// Validate validates this get user info response
func (m *GetUserInfoResponse) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateEmail(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateScopes(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateSub(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateUpdatedAt(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *GetUserInfoResponse) validateEmail(formats strfmt.Registry) error {
	if swag.IsZero(m.Email) { // not required
		return nil
	}

	if err := validate.MaxLength("email", "body", m.Email.String(), 255); err != nil {
		return err
	}

	if err := validate.FormatOf("email", "body", "email", m.Email.String(), formats); err != nil {
		return err
	}

	return nil
}

var getUserInfoResponseScopesItemsEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["app","cms"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		getUserInfoResponseScopesItemsEnum = append(getUserInfoResponseScopesItemsEnum, v)
	}
}

func (m *GetUserInfoResponse) validateScopesItemsEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, getUserInfoResponseScopesItemsEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *GetUserInfoResponse) validateScopes(formats strfmt.Registry) error {
	if swag.IsZero(m.Scopes) { // not required
		return nil
	}

	for i := 0; i < len(m.Scopes); i++ {

		// value enum
		if err := m.validateScopesItemsEnum("scopes"+"."+strconv.Itoa(i), "body", m.Scopes[i]); err != nil {
			return err
		}

	}

	return nil
}

func (m *GetUserInfoResponse) validateSub(formats strfmt.Registry) error {

	if err := validate.Required("sub", "body", m.Sub); err != nil {
		return err
	}

	return nil
}

func (m *GetUserInfoResponse) validateUpdatedAt(formats strfmt.Registry) error {

	if err := validate.Required("updated_at", "body", m.UpdatedAt); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this get user info response based on context it is used
func (m *GetUserInfoResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

// MarshalBinary interface implementation
func (m *GetUserInfoResponse) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *GetUserInfoResponse) UnmarshalBinary(b []byte) error {
	var res GetUserInfoResponse
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
