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

package models

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

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

// AccountMembership account membership
//
// swagger:model accountMembership
type AccountMembership struct {

	// billing details
	BillingDetails string `json:"billing_details,omitempty"`

	// billing email
	BillingEmail string `json:"billing_email,omitempty"`

	// billing name
	BillingName string `json:"billing_name,omitempty"`

	// billing period
	BillingPeriod string `json:"billing_period,omitempty"`

	// capabilities
	Capabilities *AccountMembershipCapabilities `json:"capabilities,omitempty"`

	// created at
	CreatedAt string `json:"created_at,omitempty"`

	// id
	ID string `json:"id,omitempty"`

	// name
	Name string `json:"name,omitempty"`

	// owner ids
	OwnerIds []string `json:"owner_ids"`

	// payment method id
	PaymentMethodID string `json:"payment_method_id,omitempty"`

	// roles allowed
	RolesAllowed []string `json:"roles_allowed"`

	// slug
	Slug string `json:"slug,omitempty"`

	// type
	Type string `json:"type,omitempty"`

	// type id
	TypeID string `json:"type_id,omitempty"`

	// type name
	TypeName string `json:"type_name,omitempty"`

	// updated at
	UpdatedAt string `json:"updated_at,omitempty"`
}

// Validate validates this account membership
func (m *AccountMembership) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *AccountMembership) validateCapabilities(formats strfmt.Registry) error {

	if swag.IsZero(m.Capabilities) { // not required
		return nil
	}

	if m.Capabilities != nil {
		if err := m.Capabilities.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("capabilities")
			}
			return err
		}
	}

	return nil
}

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

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