Class: TencentCloud::Common::BaseClient
- Inherits:
-
Object
- Object
- TencentCloud::Common::BaseClient
show all
- Defined in:
- lib/tencent_cloud/common/base_client.rb
Instance Method Summary
collapse
Constructor Details
#initialize(credential, region = nil) ⇒ BaseClient
Returns a new instance of BaseClient.
10
11
12
13
|
# File 'lib/tencent_cloud/common/base_client.rb', line 10
def initialize(credential, region = nil)
@credential = credential
@region = region
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, body) ⇒ Object
Instance Method Details
#camel_case(str) ⇒ Object
15
16
17
18
19
|
# File 'lib/tencent_cloud/common/base_client.rb', line 15
def camel_case(str)
return str if str !~ /_/ && str =~ /[A-Z]+.*/
str.split('_').map(&:capitalize).join
end
|
#get_response(action, body) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/tencent_cloud/common/base_client.rb', line 21
def get_response(action, body)
= {
'X-TC-Action' => action,
'X-TC-Version' => self.class::API_VERSION,
'X-TC-Timestamp' => Time.now.to_i
}
['X-TC-Region'] = @region if @region
request = TencentCloud::Common::Http::Request.new @credential,
self.class,
headers: ,
body: JSON.generate(body, space: ' ')
request.run
end
|