class Sogou::Search::Api::Core::BaseService
Attributes
client_options[RW]
Public Class Methods
new(service)
click to toggle source
# File lib/sogou/search/api/core/base_service.rb, line 13 def initialize(service) @url = "http://#{service_host}/sem/sms/v1/#{service}?wsdl" @client_options = ClientOptions.default.dup end
Protected Instance Methods
client()
click to toggle source
# File lib/sogou/search/api/core/base_service.rb, line 31 def client @client ||= Savon::Client.new do |savon| savon.wsdl(@url) savon.pretty_print_xml(true) savon.namespaces('xmlns:v1' => 'http://api.sogou.com/sem/common/v1') savon.env_namespace(:soapenv) savon.namespace_identifier(:v11) savon.convert_response_tags_to(lambda { |key| key.snakecase }) soap_header = {} authorization.apply(soap_header) if authorization savon.soap_header(soap_header) savon.proxy(client_options.proxy_url) if client_options.proxy_url savon.open_timeout(client_options.open_timeout_sec) if client_options.open_timeout_sec savon.read_timeout(client_options.read_timeout_sec) if client_options.read_timeout_sec end end
execute_command(command, &block)
click to toggle source
# File lib/sogou/search/api/core/base_service.rb, line 27 def execute_command(command, &block) command.execute(client, &block) end
make_command(operation, params: {}, options: {})
click to toggle source
# File lib/sogou/search/api/core/base_service.rb, line 20 def make_command(operation, params: {}, options: {}) ApiCommand.new(operation).tap do |command| command.params = params unless params.empty? command.options = options end end
Private Instance Methods
service_host()
click to toggle source
# File lib/sogou/search/api/core/base_service.rb, line 52 def service_host "api.agent.sogou.com#{ENV.fetch('ENV', 'development') == 'development' ? ':8080' : ''}" end