package ltl

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

// RegisterDeviceGroup invokes the ltl.RegisterDeviceGroup API synchronously
func (client *Client) RegisterDeviceGroup(request *RegisterDeviceGroupRequest) (response *RegisterDeviceGroupResponse, err error) {
	response = CreateRegisterDeviceGroupResponse()
	err = client.DoAction(request, response)
	return
}

// RegisterDeviceGroupWithChan invokes the ltl.RegisterDeviceGroup API asynchronously
func (client *Client) RegisterDeviceGroupWithChan(request *RegisterDeviceGroupRequest) (<-chan *RegisterDeviceGroupResponse, <-chan error) {
	responseChan := make(chan *RegisterDeviceGroupResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.RegisterDeviceGroup(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// RegisterDeviceGroupWithCallback invokes the ltl.RegisterDeviceGroup API asynchronously
func (client *Client) RegisterDeviceGroupWithCallback(request *RegisterDeviceGroupRequest, callback func(response *RegisterDeviceGroupResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *RegisterDeviceGroupResponse
		var err error
		defer close(result)
		response, err = client.RegisterDeviceGroup(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// RegisterDeviceGroupRequest is the request struct for api RegisterDeviceGroup
type RegisterDeviceGroupRequest struct {
	*requests.RpcRequest
	AuthorizeType   string `position:"Query" name:"AuthorizeType"`
	ApiVersion      string `position:"Query" name:"ApiVersion"`
	Remark          string `position:"Query" name:"Remark"`
	ProductKey      string `position:"Query" name:"ProductKey"`
	DeviceGroupName string `position:"Query" name:"DeviceGroupName"`
	BizChainId      string `position:"Query" name:"BizChainId"`
}

// RegisterDeviceGroupResponse is the response struct for api RegisterDeviceGroup
type RegisterDeviceGroupResponse struct {
	*responses.BaseResponse
	Code      int    `json:"Code" xml:"Code"`
	Message   string `json:"Message" xml:"Message"`
	Data      string `json:"Data" xml:"Data"`
	RequestId string `json:"RequestId" xml:"RequestId"`
	Success   bool   `json:"Success" xml:"Success"`
}

// CreateRegisterDeviceGroupRequest creates a request to invoke RegisterDeviceGroup API
func CreateRegisterDeviceGroupRequest() (request *RegisterDeviceGroupRequest) {
	request = &RegisterDeviceGroupRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("ltl", "2019-05-10", "RegisterDeviceGroup", "", "")
	request.Method = requests.POST
	return
}

// CreateRegisterDeviceGroupResponse creates a response to parse from RegisterDeviceGroup response
func CreateRegisterDeviceGroupResponse() (response *RegisterDeviceGroupResponse) {
	response = &RegisterDeviceGroupResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
