lib/gateway/client.rb in gateway-sdk-1.1.3 vs lib/gateway/client.rb in gateway-sdk-1.2.3
- old
+ new
@@ -15,24 +15,24 @@
METHOD_GET = 'get' # http method GET
METHOD_POST = 'post' # http method POST
attr_accessor :request
- attr_reader :config_data, :test
+ attr_reader :config_data, :url
#
# Initialize
#
# @param [Gateway::Requests::CommonRequest] request
# @param [String] token access token
- # @param [TrueClass|FalseClass] test test or production modes
+ # @param [String] url
#
- def initialize(request, token, test = false)
+ def initialize(request, token, url = Gateway.config.urls.production)
Gateway.config = JSON.parse(YAML.load_file("#{Gateway.root}/gateway/config.yml").to_json, object_class: OpenStruct)
@request = request
@token = token
- @test = test
+ @url = url
request_name = request.class.name.split('::').last
@config_data = Gateway.config.api_methods[request_name]
raise Gateway::StandardError.new("fill data in config.yml for method: #{request_name}") unless @config_data
end
@@ -70,11 +70,11 @@
# @param [Hash] query_params
#
# @return [String] url with query params
#
def url(query_params)
- url = test ? Gateway.config.urls.test : Gateway.config.urls.production
- url += '?' + URI.encode_www_form(query_params) unless query_params.empty?
+ url = @url
+ url += "?#{URI.encode_www_form(query_params)}" unless query_params.empty?
url
end
end
end
\ No newline at end of file