Sha256: 09a887d66b42beb028f9e74abdb5043c92e3e2b6a5de6feb11d4e0d02133fd95

Contents?: true

Size: 1.88 KB

Versions: 8

Compression:

Stored size: 1.88 KB

Contents

require 'net/http'
require 'uri'
require 'rexml/document'


class StateWTTX

  def update_statuswttx(imsi, imei)

    doc = REXML::Document.new
    #doc.context[:attribute_quote] = :quote  # <-- Set double-quote as the attribute value delimiter
    root = doc.add_element('row')

    attr1 = root.add_element('key')
    attr1.add_attribute('code', 'imsi')
    attr1.add_attribute('value', imsi)

    attr2 = root.add_element('field')
    attr2.add_attribute('code', 'imei')
    attr2.add_attribute('value', imei)

    attr3 = root.add_element('field')
    attr3.add_attribute('code', 'status')
    attr3.add_attribute('value', 'TRUE')

    xmlout = ""
    doc.write xmlout
    p xmlout

    url_string = "http://172.24.220.77:8080/custrefdata/wttx/_update"
    xml_string = xmlout
    uri = URI.parse url_string
    request = Net::HTTP::Post.new uri.path
    p request.body = xml_string
    request.content_type = 'application/xml'
    p  response = Net::HTTP.new(uri.host, uri.port).start { |http| http.request request }
    p response.body
  end


  def getrest_cps(imsi)

    url = "http://172.24.220.77:8080/custrefdata/wttx/_query?imsi=#{imsi}"
    uri = URI.parse(url)
    http = Net::HTTP.new(uri.host, uri.port)
    response = http.request(Net::HTTP::Get.new(uri.request_uri))
    p content = response.body
    p result_code = response.to_s.include?("OK")
    #Rails.logger = Logger.new(STDOUT)
    #logger.info "WTTX service getrestCPS result code: #{response.to_s}"
    #logger.info "WTTX service getrestCPS soap body: #{content.to_s}"



    if !result_code
      "false"
    else
      reg_imsi = /<field code="imsi" value="([0-9]{10,15})"/
      reg_imei = /<field code="imei" value="([0-9]{10,17})"/

      m1 = reg_imsi.match(content)
      m2 = reg_imei.match(content)
      imsi = m1[1]
      imei = m2[1]

      res = result_code.to_s + " " + imsi + " " + imei
      p res
      res
    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
imperituroard-1.1.25 lib/imperituroard/projects/wttx/updatepostcps.rb
imperituroard-1.1.24 lib/imperituroard/projects/wttx/updatepostcps.rb
imperituroard-1.1.23 lib/imperituroard/projects/wttx/updatepostcps.rb
imperituroard-1.1.22 lib/imperituroard/projects/wttx/updatepostcps.rb
imperituroard-1.1.21 lib/imperituroard/projects/wttx/updatepostcps.rb
imperituroard-1.1.20 lib/imperituroard/projects/wttx/updatepostcps.rb
imperituroard-1.1.19 lib/imperituroard/projects/wttx/updatepostcps.rb
imperituroard-1.1.18 lib/imperituroard/projects/wttx/updatepostcps.rb