Sha256: a32939869cc8c3f7294a3a8907f72c22606f4a0020d03cb9ef42f12f31acabdf

Contents?: true

Size: 1.31 KB

Versions: 14

Compression:

Stored size: 1.31 KB

Contents

# bandwidth
#
# This file was automatically generated by APIMATIC v2.0
# ( https://apimatic.io ).

module Bandwidth
  # BaseController.
  class BaseController
    attr_accessor :config, :http_call_back

    def initialize(config, http_call_back: nil)
      @config = config
      @http_call_back = http_call_back

      @global_headers = {
        'user-agent' => 'APIMATIC 2.0'
      }
    end

    def validate_parameters(args)
      args.each do |_name, value|
        if value.nil?
          raise ArgumentError, "Required parameter #{_name} cannot be nil."
        end
      end
    end

    def execute_request(request, binary: false)
      @http_call_back.on_before_request(request) if @http_call_back

      APIHelper.clean_hash(request.headers)
      request.headers.merge!(@global_headers)

      response = if binary
                   config.http_client.execute_as_binary(request)
                 else
                   config.http_client.execute_as_string(request)
                 end
      @http_call_back.on_after_response(response) if @http_call_back

      response
    end

    def validate_response(response)
      raise APIException.new 'HTTP Response Not OK', response unless
        response.status_code.between?(200, 208) # [200,208] = HTTP OK
    end
  end
end

Version data entries

14 entries across 7 versions & 1 rubygems

Version Path
bandwidth-sdk-2.2.2 lib/bandwidth/voice_lib/voice/controllers/base_controller.rb
bandwidth-sdk-2.2.2 lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb
bandwidth-sdk-2.2.1 lib/bandwidth/voice_lib/voice/controllers/base_controller.rb
bandwidth-sdk-2.2.1 lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb
bandwidth-sdk-2.2.0 lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb
bandwidth-sdk-2.2.0 lib/bandwidth/voice_lib/voice/controllers/base_controller.rb
bandwidth-sdk-2.1.1 lib/bandwidth/voice_lib/voice/controllers/base_controller.rb
bandwidth-sdk-2.1.1 lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb
bandwidth-sdk-2.1.0 lib/bandwidth/voice_lib/voice/controllers/base_controller.rb
bandwidth-sdk-2.1.0 lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb
bandwidth-sdk-2.0.0 lib/bandwidth/voice_lib/voice/controllers/base_controller.rb
bandwidth-sdk-2.0.0 lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb
bandwidth-sdk-1.0.2 lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb
bandwidth-sdk-1.0.2 lib/bandwidth/voice_lib/voice/controllers/base_controller.rb