class Cccode::Soap
Constants
- WSDL
Attributes
client[RW]
command[RW]
countries[RW]
country[RW]
country_code[RW]
currencies[RW]
currency[RW]
currency_code[RW]
message[RW]
response[RW]
result[RW]
result_keys[RW]
xml[RW]
Public Class Methods
new()
click to toggle source
# File lib/soap.rb, line 14 def initialize end
table_empty?()
click to toggle source
# File lib/soap.rb, line 22 def self.table_empty? !Cccode::CountryCode.exists? end
Public Instance Methods
get_all()
click to toggle source
# File lib/soap.rb, line 30 def get_all get_xml(:get_currency_code) Cccode::CountryCode.insert_all(@xml) end
table_empty?()
click to toggle source
todo: needed here? only model direct?
# File lib/soap.rb, line 18 def table_empty? Cccode::Soap.table_empty? end
Private Instance Methods
call()
click to toggle source
# File lib/soap.rb, line 104 def call begin @response = self.client.call(@command, :message => @message) rescue Savon::HTTPError => e raise "savon call error, call failed: #{e.http.code}" end end
get_content(css)
click to toggle source
# File lib/soap.rb, line 60 def get_content(css) @xml.css(css).first.present? ? @xml.css(css).first.content : nil end
get_xml(mode)
click to toggle source
# File lib/soap.rb, line 98 def get_xml(mode) set_mode(mode) call result end
set_mode(mode)
click to toggle source
# File lib/soap.rb, line 64 def set_mode(mode) @command = mode @message = nil case mode when :get_countries @result_keys = [ :envelope, :body, :get_countries_response, :get_countries_result ] when :get_iso_country_code_by_county_name @result_keys = [ :envelope, :body, :get_iso_country_code_by_county_name_response, :get_iso_country_code_by_county_name_result ] @message = {"CountryName" => @country} when :get_currency_by_country @result_keys = [ :envelope, :body, :get_currency_by_country_response, :get_currency_by_country_result ] @message = {"CountryName" => @country} when :get_currency_code_by_currency_name @result_keys = [ :envelope, :body, :get_currency_code_by_currency_name_response, :get_currency_code_by_currency_name_result ] @message = {"CurrencyName" => @currency} when :get_currency_code @result_keys = [ :envelope, :body, :get_currency_code_response, :get_currency_code_result ] end end