module LanxinOpen

Constants

VERSION

Public Class Methods

config(&block) click to toggle source
# File lib/lanxin_open.rb, line 22
def self.config(&block)
  instance_eval &block
end
dean_hash2xml(p_hash) click to toggle source
# File lib/lanxin_open.rb, line 34
def self.dean_hash2xml(p_hash)
  # return nil if (not p_hash) or p_hash.length <= 0
  no_cdata_key = ["CreateTime","MsgId"]
  line_break = "" #"\n"
  xml_str = "<xml>#{line_break}"
  p_hash.each do |k,v|
    if no_cdata_key.include?(k)
      xml_str += "<#{k}>#{v}</#{k}>#{line_break}"
    else
      xml_str += "<#{k}><![CDATA[#{v}]]></#{k}>#{line_break}"
    end
  end
  xml_str += "</xml>"
end
hash_to_xml(p_hash) click to toggle source
# File lib/lanxin_open.rb, line 49
def self.hash_to_xml(p_hash)
  # return nil if (not p_hash) or p_hash.length <= 0
  return dean_hash2xml(p_hash)
end
new() click to toggle source
# File lib/lanxin_open.rb, line 30
def self.new
  OpenPlatformV1.new({})
end
new_with_params(args) click to toggle source
# File lib/lanxin_open.rb, line 26
def self.new_with_params(args)
  OpenPlatformV1.new(args)
end
parameter(*names) click to toggle source
# File lib/lanxin_open.rb, line 9
def self.parameter(*names)
  names.each do |name|
    attr_accessor name
    # For each given symbol we generate accessor method that sets option's
    # value being called with an argument, or returns option's current value
    # when called without arguments
    define_method name do |*values|
      value = values.first
      value ? self.send("#{name}=", value) : instance_variable_get("@#{name}")
    end
  end
end
parse_callback_xml(msgcontent) click to toggle source
# File lib/lanxin_open.rb, line 54
def self.parse_callback_xml(msgcontent)
  begin
    hash = Hash.from_xml(msgcontent)
    xml_node = hash["xml"]
    return xml_node
  rescue
  end
end