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

package metadata

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

import (
	"context"
	"fmt"
	"io"
	"strconv"

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

// ListMembersReader is a Reader for the ListMembers structure.
type ListMembersReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *ListMembersReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewListMembersOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 404:
		result := NewListMembersNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewListMembersInternalServerError()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[GET /members/{organizationToken}] listMembers", response, response.Code())
	}
}

// NewListMembersOK creates a ListMembersOK with default headers values
func NewListMembersOK() *ListMembersOK {
	return &ListMembersOK{}
}

/*
ListMembersOK describes a response with status code 200, with default header values.

ok
*/
type ListMembersOK struct {
	Payload *ListMembersOKBody
}

// IsSuccess returns true when this list members o k response has a 2xx status code
func (o *ListMembersOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this list members o k response has a 3xx status code
func (o *ListMembersOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this list members o k response has a 4xx status code
func (o *ListMembersOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this list members o k response has a 5xx status code
func (o *ListMembersOK) IsServerError() bool {
	return false
}

// IsCode returns true when this list members o k response a status code equal to that given
func (o *ListMembersOK) IsCode(code int) bool {
	return code == 200
}

// Code gets the status code for the list members o k response
func (o *ListMembersOK) Code() int {
	return 200
}

func (o *ListMembersOK) Error() string {
	return fmt.Sprintf("[GET /members/{organizationToken}][%d] listMembersOK  %+v", 200, o.Payload)
}

func (o *ListMembersOK) String() string {
	return fmt.Sprintf("[GET /members/{organizationToken}][%d] listMembersOK  %+v", 200, o.Payload)
}

func (o *ListMembersOK) GetPayload() *ListMembersOKBody {
	return o.Payload
}

func (o *ListMembersOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	o.Payload = new(ListMembersOKBody)

	// response payload
	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
		return err
	}

	return nil
}

// NewListMembersNotFound creates a ListMembersNotFound with default headers values
func NewListMembersNotFound() *ListMembersNotFound {
	return &ListMembersNotFound{}
}

/*
ListMembersNotFound describes a response with status code 404, with default header values.

not found
*/
type ListMembersNotFound struct {
}

// IsSuccess returns true when this list members not found response has a 2xx status code
func (o *ListMembersNotFound) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this list members not found response has a 3xx status code
func (o *ListMembersNotFound) IsRedirect() bool {
	return false
}

// IsClientError returns true when this list members not found response has a 4xx status code
func (o *ListMembersNotFound) IsClientError() bool {
	return true
}

// IsServerError returns true when this list members not found response has a 5xx status code
func (o *ListMembersNotFound) IsServerError() bool {
	return false
}

// IsCode returns true when this list members not found response a status code equal to that given
func (o *ListMembersNotFound) IsCode(code int) bool {
	return code == 404
}

// Code gets the status code for the list members not found response
func (o *ListMembersNotFound) Code() int {
	return 404
}

func (o *ListMembersNotFound) Error() string {
	return fmt.Sprintf("[GET /members/{organizationToken}][%d] listMembersNotFound ", 404)
}

func (o *ListMembersNotFound) String() string {
	return fmt.Sprintf("[GET /members/{organizationToken}][%d] listMembersNotFound ", 404)
}

func (o *ListMembersNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	return nil
}

// NewListMembersInternalServerError creates a ListMembersInternalServerError with default headers values
func NewListMembersInternalServerError() *ListMembersInternalServerError {
	return &ListMembersInternalServerError{}
}

/*
ListMembersInternalServerError describes a response with status code 500, with default header values.

internal server error
*/
type ListMembersInternalServerError struct {
}

// IsSuccess returns true when this list members internal server error response has a 2xx status code
func (o *ListMembersInternalServerError) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this list members internal server error response has a 3xx status code
func (o *ListMembersInternalServerError) IsRedirect() bool {
	return false
}

// IsClientError returns true when this list members internal server error response has a 4xx status code
func (o *ListMembersInternalServerError) IsClientError() bool {
	return false
}

// IsServerError returns true when this list members internal server error response has a 5xx status code
func (o *ListMembersInternalServerError) IsServerError() bool {
	return true
}

// IsCode returns true when this list members internal server error response a status code equal to that given
func (o *ListMembersInternalServerError) IsCode(code int) bool {
	return code == 500
}

// Code gets the status code for the list members internal server error response
func (o *ListMembersInternalServerError) Code() int {
	return 500
}

func (o *ListMembersInternalServerError) Error() string {
	return fmt.Sprintf("[GET /members/{organizationToken}][%d] listMembersInternalServerError ", 500)
}

func (o *ListMembersInternalServerError) String() string {
	return fmt.Sprintf("[GET /members/{organizationToken}][%d] listMembersInternalServerError ", 500)
}

func (o *ListMembersInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	return nil
}

/*
ListMembersOKBody list members o k body
swagger:model ListMembersOKBody
*/
type ListMembersOKBody struct {

	// members
	Members []*ListMembersOKBodyMembersItems0 `json:"members"`
}

// Validate validates this list members o k body
func (o *ListMembersOKBody) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (o *ListMembersOKBody) validateMembers(formats strfmt.Registry) error {
	if swag.IsZero(o.Members) { // not required
		return nil
	}

	for i := 0; i < len(o.Members); i++ {
		if swag.IsZero(o.Members[i]) { // not required
			continue
		}

		if o.Members[i] != nil {
			if err := o.Members[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("listMembersOK" + "." + "members" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("listMembersOK" + "." + "members" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

// ContextValidate validate this list members o k body based on the context it is used
func (o *ListMembersOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := o.contextValidateMembers(ctx, formats); err != nil {
		res = append(res, err)
	}

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

func (o *ListMembersOKBody) contextValidateMembers(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(o.Members); i++ {

		if o.Members[i] != nil {

			if swag.IsZero(o.Members[i]) { // not required
				return nil
			}

			if err := o.Members[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("listMembersOK" + "." + "members" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("listMembersOK" + "." + "members" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

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

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

/*
ListMembersOKBodyMembersItems0 list members o k body members items0
swagger:model ListMembersOKBodyMembersItems0
*/
type ListMembersOKBodyMembersItems0 struct {

	// admin
	Admin bool `json:"admin,omitempty"`

	// email
	Email string `json:"email,omitempty"`
}

// Validate validates this list members o k body members items0
func (o *ListMembersOKBodyMembersItems0) Validate(formats strfmt.Registry) error {
	return nil
}

// ContextValidate validates this list members o k body members items0 based on context it is used
func (o *ListMembersOKBodyMembersItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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