package authz

import "context"

type scopeKey string

const (
	CtxDeptCodesKey   scopeKey = "authz.dept_codes"
	CtxPiyasaCodesKey scopeKey = "authz.piyasa_codes"
)

func WithDeptCodes(ctx context.Context, codes []string) context.Context {
	return context.WithValue(ctx, CtxDeptCodesKey, codes)
}

func WithPiyasaCodes(ctx context.Context, codes []string) context.Context {
	return context.WithValue(ctx, CtxPiyasaCodesKey, codes)
}

func GetDeptCodesFromCtx(ctx context.Context) []string {
	if v := ctx.Value(CtxDeptCodesKey); v != nil {
		if codes, ok := v.([]string); ok {
			return codes
		}
	}
	return nil
}

func GetPiyasaCodesFromCtx(ctx context.Context) []string {
	if v := ctx.Value(CtxPiyasaCodesKey); v != nil {
		if codes, ok := v.([]string); ok {
			return codes
		}
	}
	return nil
}
