Sha256: 206d346b17e7be908b0219533a411876774b41b652429e0bce5ff6823c63bf92

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module TencentCloud
  module Common
    module Http
      class Request
        attr_accessor :klass, :options, :credential

        def initialize(credential, klass, options = {})
          @uri = 'https://' + klass::ENDPOINT
          options[:method] ||= :post
          self.options = options
          self.credential = credential
          self.klass = klass
        end

        def signed_request
          headers = {
            'content-type' => 'application/json; charset=utf-8',
            'host' => klass::ENDPOINT
          }
          if options[:headers].nil?
            options[:headers] = headers
          else
            options[:headers].merge! headers
          end

          request = Typhoeus::Request.new @uri.to_s, options
          authorization = Sign.new(credential, klass, request).sign_tc3
          request.options[:headers]['Authorization'] = authorization
          request
        end

        def run
          signed_request.run
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tencentcloud-sdk-ruby-0.4.8 lib/tencent_cloud/common/http/request.rb
tencentcloud-sdk-ruby-0.3.6 lib/tencent_cloud/common/http/request.rb
tencentcloud-sdk-ruby-0.3.5 lib/tencent_cloud/common/http/request.rb
tencentcloud-sdk-ruby-0.3.4 lib/tencent_cloud/common/http/request.rb
tencentcloud-sdk-ruby-0.3.3 lib/tencent_cloud/common/http/request.rb
tencentcloud-sdk-ruby-0.3.2 lib/tencent_cloud/common/http/request.rb
tencentcloud-sdk-ruby-0.3.1 lib/tencent_cloud/common/http/request.rb
tencentcloud-sdk-ruby-0.2.1 lib/tencent_cloud/common/http/request.rb
tencentcloud-sdk-ruby-0.2.0 lib/tencent_cloud/common/http/request.rb