1 /*
2  * Copyright 1999-2019 Alibaba Cloud All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <alibabacloud/core/CommonRequest.h>
18 
19 namespace AlibabaCloud {
20 
CommonRequest(RequestPattern pattern)21 CommonRequest::CommonRequest(RequestPattern pattern)
22     : ServiceRequest("", ""), domain_(), queryParams_(),
23       httpMethod_(HttpRequest::Get), requestPattern_(pattern) {}
24 
~CommonRequest()25 CommonRequest::~CommonRequest() {}
26 
domain() const27 std::string CommonRequest::domain() const { return domain_; }
28 
setDomain(const std::string & domain)29 void CommonRequest::setDomain(const std::string &domain) { domain_ = domain; }
30 
requestPattern() const31 CommonRequest::RequestPattern CommonRequest::requestPattern() const {
32   return requestPattern_;
33 }
34 
setRequestPattern(RequestPattern pattern)35 void CommonRequest::setRequestPattern(RequestPattern pattern) {
36   requestPattern_ = pattern;
37 }
38 
setHttpMethod(HttpRequest::Method method)39 void CommonRequest::setHttpMethod(HttpRequest::Method method) {
40   httpMethod_ = method;
41 }
42 
httpMethod() const43 HttpRequest::Method CommonRequest::httpMethod() const { return httpMethod_; }
44 
45 CommonRequest::ParameterValueType
queryParameter(const ParameterNameType & name) const46 CommonRequest::queryParameter(const ParameterNameType &name) const {
47   ParameterCollection::const_iterator it = queryParams_.find(name);
48   if (it == queryParams_.end()) {
49     return ParameterValueType("");
50   }
51   return it->second;
52 }
53 
queryParameters() const54 CommonRequest::ParameterCollection CommonRequest::queryParameters() const {
55   return queryParams_;
56 }
57 
setQueryParameter(const ParameterNameType & name,const ParameterValueType & value)58 void CommonRequest::setQueryParameter(const ParameterNameType &name,
59                                       const ParameterValueType &value) {
60   queryParams_[name] = value;
61 }
62 
63 CommonRequest::ParameterValueType
headerParameter(const ParameterNameType & name) const64 CommonRequest::headerParameter(const ParameterNameType &name) const {
65   const ParameterCollection::const_iterator it = headerParams_.find(name);
66   if (it == headerParams_.end()) {
67     return ParameterValueType("");
68   }
69   return it->second;
70 }
71 
headerParameters() const72 CommonRequest::ParameterCollection CommonRequest::headerParameters() const {
73   return headerParams_;
74 }
75 
setHeaderParameter(const ParameterNameType & name,const ParameterValueType & value)76 void CommonRequest::setHeaderParameter(const ParameterNameType &name,
77                                        const ParameterValueType &value) {
78   headerParams_[name] = value;
79 }
80 
81 } // namespace AlibabaCloud
82