package unimkt

//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
//http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
//
// Code generated by Alibaba Cloud SDK Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

import (
	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
)

// QueryContentList invokes the unimkt.QueryContentList API synchronously
func (client *Client) QueryContentList(request *QueryContentListRequest) (response *QueryContentListResponse, err error) {
	response = CreateQueryContentListResponse()
	err = client.DoAction(request, response)
	return
}

// QueryContentListWithChan invokes the unimkt.QueryContentList API asynchronously
func (client *Client) QueryContentListWithChan(request *QueryContentListRequest) (<-chan *QueryContentListResponse, <-chan error) {
	responseChan := make(chan *QueryContentListResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.QueryContentList(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// QueryContentListWithCallback invokes the unimkt.QueryContentList API asynchronously
func (client *Client) QueryContentListWithCallback(request *QueryContentListRequest, callback func(response *QueryContentListResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *QueryContentListResponse
		var err error
		defer close(result)
		response, err = client.QueryContentList(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// QueryContentListRequest is the request struct for api QueryContentList
type QueryContentListRequest struct {
	*requests.RpcRequest
	TaskType    string           `position:"Query" name:"TaskType"`
	TaskBizType string           `position:"Query" name:"TaskBizType"`
	BrandUserId requests.Integer `position:"Query" name:"BrandUserId"`
	ProxyUserId requests.Integer `position:"Query" name:"ProxyUserId"`
	ChannelId   string           `position:"Query" name:"ChannelId"`
}

// QueryContentListResponse is the response struct for api QueryContentList
type QueryContentListResponse struct {
	*responses.BaseResponse
	Code      int                      `json:"Code" xml:"Code"`
	Success   bool                     `json:"Success" xml:"Success"`
	ErrorMsg  string                   `json:"ErrorMsg" xml:"ErrorMsg"`
	RequestId string                   `json:"RequestId" xml:"RequestId"`
	Data      []map[string]interface{} `json:"Data" xml:"Data"`
}

// CreateQueryContentListRequest creates a request to invoke QueryContentList API
func CreateQueryContentListRequest() (request *QueryContentListRequest) {
	request = &QueryContentListRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("UniMkt", "2018-12-12", "QueryContentList", "uniMkt", "openAPI")
	request.Method = requests.POST
	return
}

// CreateQueryContentListResponse creates a response to parse from QueryContentList response
func CreateQueryContentListResponse() (response *QueryContentListResponse) {
	response = &QueryContentListResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
