package vod

//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"
)

// DescribeUserVvByVideoid invokes the vod.DescribeUserVvByVideoid API synchronously
// api document: https://help.aliyun.com/api/vod/describeuservvbyvideoid.html
func (client *Client) DescribeUserVvByVideoid(request *DescribeUserVvByVideoidRequest) (response *DescribeUserVvByVideoidResponse, err error) {
	response = CreateDescribeUserVvByVideoidResponse()
	err = client.DoAction(request, response)
	return
}

// DescribeUserVvByVideoidWithChan invokes the vod.DescribeUserVvByVideoid API asynchronously
// api document: https://help.aliyun.com/api/vod/describeuservvbyvideoid.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) DescribeUserVvByVideoidWithChan(request *DescribeUserVvByVideoidRequest) (<-chan *DescribeUserVvByVideoidResponse, <-chan error) {
	responseChan := make(chan *DescribeUserVvByVideoidResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.DescribeUserVvByVideoid(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// DescribeUserVvByVideoidWithCallback invokes the vod.DescribeUserVvByVideoid API asynchronously
// api document: https://help.aliyun.com/api/vod/describeuservvbyvideoid.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) DescribeUserVvByVideoidWithCallback(request *DescribeUserVvByVideoidRequest, callback func(response *DescribeUserVvByVideoidResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *DescribeUserVvByVideoidResponse
		var err error
		defer close(result)
		response, err = client.DescribeUserVvByVideoid(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// DescribeUserVvByVideoidRequest is the request struct for api DescribeUserVvByVideoid
type DescribeUserVvByVideoidRequest struct {
	*requests.RpcRequest
	SecurityToken string           `position:"Query" name:"SecurityToken"`
	EndTime       string           `position:"Query" name:"EndTime"`
	Videoid       string           `position:"Query" name:"Videoid"`
	StartTime     string           `position:"Query" name:"StartTime"`
	OwnerId       requests.Integer `position:"Query" name:"OwnerId"`
}

// DescribeUserVvByVideoidResponse is the response struct for api DescribeUserVvByVideoid
type DescribeUserVvByVideoidResponse struct {
	*responses.BaseResponse
	RequestId               string                                           `json:"RequestId" xml:"RequestId"`
	UserPlayStatisticsInfos UserPlayStatisticsInfosInDescribeUserVvByVideoid `json:"UserPlayStatisticsInfos" xml:"UserPlayStatisticsInfos"`
}

// CreateDescribeUserVvByVideoidRequest creates a request to invoke DescribeUserVvByVideoid API
func CreateDescribeUserVvByVideoidRequest() (request *DescribeUserVvByVideoidRequest) {
	request = &DescribeUserVvByVideoidRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("vod", "2017-03-21", "DescribeUserVvByVideoid", "vod", "openAPI")
	return
}

// CreateDescribeUserVvByVideoidResponse creates a response to parse from DescribeUserVvByVideoid response
func CreateDescribeUserVvByVideoidResponse() (response *DescribeUserVvByVideoidResponse) {
	response = &DescribeUserVvByVideoidResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
