package host

import (
	"context"
	"encoding/json"
)

func (c Core) FindChannels(ctx context.Context, in *FindChannelsInput) (*FindChannelsOutput, error) {
	marshal, err := json.Marshal(in)
	if err != nil {
		return nil, err
	}
	result, err := c.Plugin.CallHost("findChannels", marshal)

	if err != nil {
		return nil, err
	}

	out := FindChannelsOutput{}
	if err = json.Unmarshal(result, &out); err != nil {
		return nil, err
	}
	return &out, nil
}
