client/api/multiplay_api.go (331 lines of code) (raw):

// Package client /* * YuanJing OpenAPI SDK for Go * * */ package api import ( "github.com/aliyun/alibabacloud-yjopenapi-go-client/client/model" "io/ioutil" "net/http" "net/url" "strings" ) type MultiplayApiService service // Close /* * 关闭联机 * @param varForms model.MultiplayCloseForms */ func (s *MultiplayApiService) Close( varForms *model.MultiplayCloseForms, ) (model.MultiplayCloseResult, *http.Response, error) { var ( varHttpMethod = strings.ToUpper("Post") varReturnValue model.MultiplayCloseResult ) // create path and map variables varPath := s.client.cfg.Scheme + "://" + s.client.cfg.Host + "/multiplay/close" varHeaderParams := make(map[string]string) varQueryParams := url.Values{} varFormParams := url.Values{} // to determine the Content-Type header varHttpContentTypes := []string{"application/x-www-form-urlencoded"} // set Content-Type header varHttpContentType := selectHeaderContentType(varHttpContentTypes) if varHttpContentType != "" { varHeaderParams["Content-Type"] = varHttpContentType } // to determine the Accept header varHttpHeaderAccepts := []string{"application/json"} // set Accept header varHttpHeaderAccept := selectHeaderAccept(varHttpHeaderAccepts) if varHttpHeaderAccept != "" { varHeaderParams["Accept"] = varHttpHeaderAccept } varFormParams.Add("mpId", parameterToString(varForms.MpId, "")) if varForms != nil && varForms.Reason != nil { varFormParams.Add("reason", parameterToString(*varForms.Reason, "")) } r, err := s.client.prepareRequest(varPath, varHttpMethod, varHeaderParams, varQueryParams, varFormParams) if err != nil { return varReturnValue, nil, err } varHttpResponse, err := s.client.callAPI(r) if err != nil || varHttpResponse == nil { return varReturnValue, varHttpResponse, err } defer varHttpResponse.Body.Close() varBody, err := ioutil.ReadAll(varHttpResponse.Body) if err != nil { return varReturnValue, varHttpResponse, err } if varHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = s.client.decode(&varReturnValue, varBody, varHttpResponse.Header.Get("Content-Type")) if err == nil { return varReturnValue, varHttpResponse, err } } if varHttpResponse.StatusCode >= 300 { newErr := GenericError{ body: varBody, error: varHttpResponse.Status, } return varReturnValue, varHttpResponse, newErr } return varReturnValue, varHttpResponse, nil } // Init /* * 初始化联机 * @param varForms model.MultiplayInitForms */ func (s *MultiplayApiService) Init( varForms *model.MultiplayInitForms, ) (model.MultiplayInitResult, *http.Response, error) { var ( varHttpMethod = strings.ToUpper("Post") varReturnValue model.MultiplayInitResult ) // create path and map variables varPath := s.client.cfg.Scheme + "://" + s.client.cfg.Host + "/multiplay/init" varHeaderParams := make(map[string]string) varQueryParams := url.Values{} varFormParams := url.Values{} // to determine the Content-Type header varHttpContentTypes := []string{"application/x-www-form-urlencoded"} // set Content-Type header varHttpContentType := selectHeaderContentType(varHttpContentTypes) if varHttpContentType != "" { varHeaderParams["Content-Type"] = varHttpContentType } // to determine the Accept header varHttpHeaderAccepts := []string{"application/json"} // set Accept header varHttpHeaderAccept := selectHeaderAccept(varHttpHeaderAccepts) if varHttpHeaderAccept != "" { varHeaderParams["Accept"] = varHttpHeaderAccept } varFormParams.Add("gameSession", parameterToString(varForms.GameSession, "")) varFormParams.Add("appKey", parameterToString(varForms.AppKey, "")) if varForms != nil && varForms.Config != nil { varFormParams.Add("config", parameterToString(*varForms.Config, "")) } if varForms != nil && varForms.Tokens != nil { varFormParams.Add("tokens", parameterToString(*varForms.Tokens, "multi")) } r, err := s.client.prepareRequest(varPath, varHttpMethod, varHeaderParams, varQueryParams, varFormParams) if err != nil { return varReturnValue, nil, err } varHttpResponse, err := s.client.callAPI(r) if err != nil || varHttpResponse == nil { return varReturnValue, varHttpResponse, err } defer varHttpResponse.Body.Close() varBody, err := ioutil.ReadAll(varHttpResponse.Body) if err != nil { return varReturnValue, varHttpResponse, err } if varHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = s.client.decode(&varReturnValue, varBody, varHttpResponse.Header.Get("Content-Type")) if err == nil { return varReturnValue, varHttpResponse, err } } if varHttpResponse.StatusCode >= 300 { newErr := GenericError{ body: varBody, error: varHttpResponse.Status, } return varReturnValue, varHttpResponse, newErr } return varReturnValue, varHttpResponse, nil } // Join /* * 加入联机 * @param varForms model.MultiplayJoinForms */ func (s *MultiplayApiService) Join( varForms *model.MultiplayJoinForms, ) (model.MultiplayJoinResult, *http.Response, error) { var ( varHttpMethod = strings.ToUpper("Post") varReturnValue model.MultiplayJoinResult ) // create path and map variables varPath := s.client.cfg.Scheme + "://" + s.client.cfg.Host + "/multiplay/join" varHeaderParams := make(map[string]string) varQueryParams := url.Values{} varFormParams := url.Values{} // to determine the Content-Type header varHttpContentTypes := []string{"application/x-www-form-urlencoded"} // set Content-Type header varHttpContentType := selectHeaderContentType(varHttpContentTypes) if varHttpContentType != "" { varHeaderParams["Content-Type"] = varHttpContentType } // to determine the Accept header varHttpHeaderAccepts := []string{"application/json"} // set Accept header varHttpHeaderAccept := selectHeaderAccept(varHttpHeaderAccepts) if varHttpHeaderAccept != "" { varHeaderParams["Accept"] = varHttpHeaderAccept } varFormParams.Add("mpId", parameterToString(varForms.MpId, "")) varFormParams.Add("accountId", parameterToString(varForms.AccountId, "")) if varForms != nil && varForms.ControlId != nil { varFormParams.Add("controlId", parameterToString(*varForms.ControlId, "")) } r, err := s.client.prepareRequest(varPath, varHttpMethod, varHeaderParams, varQueryParams, varFormParams) if err != nil { return varReturnValue, nil, err } varHttpResponse, err := s.client.callAPI(r) if err != nil || varHttpResponse == nil { return varReturnValue, varHttpResponse, err } defer varHttpResponse.Body.Close() varBody, err := ioutil.ReadAll(varHttpResponse.Body) if err != nil { return varReturnValue, varHttpResponse, err } if varHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = s.client.decode(&varReturnValue, varBody, varHttpResponse.Header.Get("Content-Type")) if err == nil { return varReturnValue, varHttpResponse, err } } if varHttpResponse.StatusCode >= 300 { newErr := GenericError{ body: varBody, error: varHttpResponse.Status, } return varReturnValue, varHttpResponse, newErr } return varReturnValue, varHttpResponse, nil } // Leave /* * 离开联机 * @param varForms model.MultiplayLeaveForms */ func (s *MultiplayApiService) Leave( varForms *model.MultiplayLeaveForms, ) (model.MultiplayLeaveResult, *http.Response, error) { var ( varHttpMethod = strings.ToUpper("Post") varReturnValue model.MultiplayLeaveResult ) // create path and map variables varPath := s.client.cfg.Scheme + "://" + s.client.cfg.Host + "/multiplay/leave" varHeaderParams := make(map[string]string) varQueryParams := url.Values{} varFormParams := url.Values{} // to determine the Content-Type header varHttpContentTypes := []string{"application/x-www-form-urlencoded"} // set Content-Type header varHttpContentType := selectHeaderContentType(varHttpContentTypes) if varHttpContentType != "" { varHeaderParams["Content-Type"] = varHttpContentType } // to determine the Accept header varHttpHeaderAccepts := []string{"application/json"} // set Accept header varHttpHeaderAccept := selectHeaderAccept(varHttpHeaderAccepts) if varHttpHeaderAccept != "" { varHeaderParams["Accept"] = varHttpHeaderAccept } varFormParams.Add("mpId", parameterToString(varForms.MpId, "")) varFormParams.Add("kickOut", parameterToString(varForms.KickOut, "")) if varForms != nil && varForms.Reason != nil { varFormParams.Add("reason", parameterToString(*varForms.Reason, "")) } varFormParams.Add("tokenIds", parameterToString(varForms.TokenIds, "multi")) r, err := s.client.prepareRequest(varPath, varHttpMethod, varHeaderParams, varQueryParams, varFormParams) if err != nil { return varReturnValue, nil, err } varHttpResponse, err := s.client.callAPI(r) if err != nil || varHttpResponse == nil { return varReturnValue, varHttpResponse, err } defer varHttpResponse.Body.Close() varBody, err := ioutil.ReadAll(varHttpResponse.Body) if err != nil { return varReturnValue, varHttpResponse, err } if varHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = s.client.decode(&varReturnValue, varBody, varHttpResponse.Header.Get("Content-Type")) if err == nil { return varReturnValue, varHttpResponse, err } } if varHttpResponse.StatusCode >= 300 { newErr := GenericError{ body: varBody, error: varHttpResponse.Status, } return varReturnValue, varHttpResponse, newErr } return varReturnValue, varHttpResponse, nil } // Modify /* * 修改联机 * @param varForms model.MultiplayModifyForms */ func (s *MultiplayApiService) Modify( varForms *model.MultiplayModifyForms, ) (model.MultiplayModifyResult, *http.Response, error) { var ( varHttpMethod = strings.ToUpper("Post") varReturnValue model.MultiplayModifyResult ) // create path and map variables varPath := s.client.cfg.Scheme + "://" + s.client.cfg.Host + "/multiplay/modify" varHeaderParams := make(map[string]string) varQueryParams := url.Values{} varFormParams := url.Values{} // to determine the Content-Type header varHttpContentTypes := []string{"application/x-www-form-urlencoded"} // set Content-Type header varHttpContentType := selectHeaderContentType(varHttpContentTypes) if varHttpContentType != "" { varHeaderParams["Content-Type"] = varHttpContentType } // to determine the Accept header varHttpHeaderAccepts := []string{"application/json"} // set Accept header varHttpHeaderAccept := selectHeaderAccept(varHttpHeaderAccepts) if varHttpHeaderAccept != "" { varHeaderParams["Accept"] = varHttpHeaderAccept } varFormParams.Add("mpId", parameterToString(varForms.MpId, "")) if varForms != nil && varForms.Tokens != nil { varFormParams.Add("tokens", parameterToString(*varForms.Tokens, "multi")) } r, err := s.client.prepareRequest(varPath, varHttpMethod, varHeaderParams, varQueryParams, varFormParams) if err != nil { return varReturnValue, nil, err } varHttpResponse, err := s.client.callAPI(r) if err != nil || varHttpResponse == nil { return varReturnValue, varHttpResponse, err } defer varHttpResponse.Body.Close() varBody, err := ioutil.ReadAll(varHttpResponse.Body) if err != nil { return varReturnValue, varHttpResponse, err } if varHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = s.client.decode(&varReturnValue, varBody, varHttpResponse.Header.Get("Content-Type")) if err == nil { return varReturnValue, varHttpResponse, err } } if varHttpResponse.StatusCode >= 300 { newErr := GenericError{ body: varBody, error: varHttpResponse.Status, } return varReturnValue, varHttpResponse, newErr } return varReturnValue, varHttpResponse, nil } // Query /* * 离开联机 * @param varForms model.MultiplayQueryForms */ func (s *MultiplayApiService) Query( varForms *model.MultiplayQueryForms, ) (model.MultiplayQueryResult, *http.Response, error) { var ( varHttpMethod = strings.ToUpper("Post") varReturnValue model.MultiplayQueryResult ) // create path and map variables varPath := s.client.cfg.Scheme + "://" + s.client.cfg.Host + "/multiplay/query" varHeaderParams := make(map[string]string) varQueryParams := url.Values{} varFormParams := url.Values{} // to determine the Content-Type header varHttpContentTypes := []string{"application/x-www-form-urlencoded"} // set Content-Type header varHttpContentType := selectHeaderContentType(varHttpContentTypes) if varHttpContentType != "" { varHeaderParams["Content-Type"] = varHttpContentType } // to determine the Accept header varHttpHeaderAccepts := []string{"application/json"} // set Accept header varHttpHeaderAccept := selectHeaderAccept(varHttpHeaderAccepts) if varHttpHeaderAccept != "" { varHeaderParams["Accept"] = varHttpHeaderAccept } varFormParams.Add("mpId", parameterToString(varForms.MpId, "")) r, err := s.client.prepareRequest(varPath, varHttpMethod, varHeaderParams, varQueryParams, varFormParams) if err != nil { return varReturnValue, nil, err } varHttpResponse, err := s.client.callAPI(r) if err != nil || varHttpResponse == nil { return varReturnValue, varHttpResponse, err } defer varHttpResponse.Body.Close() varBody, err := ioutil.ReadAll(varHttpResponse.Body) if err != nil { return varReturnValue, varHttpResponse, err } if varHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = s.client.decode(&varReturnValue, varBody, varHttpResponse.Header.Get("Content-Type")) if err == nil { return varReturnValue, varHttpResponse, err } } if varHttpResponse.StatusCode >= 300 { newErr := GenericError{ body: varBody, error: varHttpResponse.Status, } return varReturnValue, varHttpResponse, newErr } return varReturnValue, varHttpResponse, nil }