package cusanalytic_sc_online

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

// GetEMap invokes the cusanalytic_sc_online.GetEMap API synchronously
// api document: https://help.aliyun.com/api/cusanalytic_sc_online/getemap.html
func (client *Client) GetEMap(request *GetEMapRequest) (response *GetEMapResponse, err error) {
	response = CreateGetEMapResponse()
	err = client.DoAction(request, response)
	return
}

// GetEMapWithChan invokes the cusanalytic_sc_online.GetEMap API asynchronously
// api document: https://help.aliyun.com/api/cusanalytic_sc_online/getemap.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) GetEMapWithChan(request *GetEMapRequest) (<-chan *GetEMapResponse, <-chan error) {
	responseChan := make(chan *GetEMapResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.GetEMap(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

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

// GetEMapRequest is the request struct for api GetEMap
type GetEMapRequest struct {
	*requests.RpcRequest
	StoreId    requests.Integer `position:"Body" name:"StoreId"`
	LocationId requests.Integer `position:"Body" name:"LocationId"`
}

// GetEMapResponse is the response struct for api GetEMap
type GetEMapResponse struct {
	*responses.BaseResponse
	StoreId    int64   `json:"StoreId" xml:"StoreId"`
	Name       string  `json:"Name" xml:"Name"`
	Scale      float64 `json:"Scale" xml:"Scale"`
	LocationId int64   `json:"LocationId" xml:"LocationId"`
	EMapId     int64   `json:"EMapId" xml:"EMapId"`
	ImageUrl   string  `json:"ImageUrl" xml:"ImageUrl"`
}

// CreateGetEMapRequest creates a request to invoke GetEMap API
func CreateGetEMapRequest() (request *GetEMapRequest) {
	request = &GetEMapRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("cusanalytic_sc_online", "2019-05-24", "GetEMap", "", "")
	return
}

// CreateGetEMapResponse creates a response to parse from GetEMap response
func CreateGetEMapResponse() (response *GetEMapResponse) {
	response = &GetEMapResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
