Sha256: 55e4a53cb0946d62e6d4010ba17041bfdf8219274e3b9222c4141e1f0d9ab36b
Contents?: true
Size: 1.49 KB
Versions: 9
Compression:
Stored size: 1.49 KB
Contents
# # mockapiclient.rb - This file contains the MockApiClient class. # # Copyright (C) 2011 MediaSift Ltd # # == Overview # # The MockApiClient class implements a fake DataSift API interface. module DataSift # MockApiCLient class. # # == Introduction # # The ApiClient class implements a fake DataSift API interface. # class MockApiClient # Set the response to be returned by the call method # === Parameters # # * +code+ - The HTTP response code # * +data+ - The dictionary that would have come from the response body # * +rate_limit+ - The new rate_limit value # * +rate_limit_remaining+ - The new rate_limit_remaining value def setResponse(code, data, rate_limit, rate_limit_remaining) @response = { 'response_code' => code, 'data' => data, 'rate_limit' => rate_limit, 'rate_limit_remaining' => rate_limit_remaining, } end # Clear the response so we throw an exception if we get called again # without a new response being set. # def clearResponse() @response = false end # Fake a call to a DataSift API endpoint. # === Parameters # # * +endpoint+ - The endpoint of the API call. # * +params+ - The parameters to be passed along with the request. # * +username+ - The username for the Auth header # * +api_key+ - The API key for the Auth header def call(username, api_key, endpoint, params = {}, user_agent = 'DataSiftPHP/0.0') if !@response raise StandardError, 'Expected response not set in mock object' end @response end end end
Version data entries
9 entries across 9 versions & 1 rubygems