Sha256: 639ce43bb8feffc1004140945835e0434b0997e03a3c6c3873075ea717639d82

Contents?: true

Size: 1.89 KB

Versions: 15

Compression:

Stored size: 1.89 KB

Contents

require 'mongo'

require 'json'
require 'rubygems'
require 'nokogiri'
require 'rails'

require 'imperituroard/add_functions/logger/any_functions'

class MongoVpn

  attr_accessor :mongo_vpn_ip, :mongo_vpn_port, :client_vpn, :mongo_vpn_database, :internal_vpn_func, :logger_any

  def initialize(mongo_vpn_ip, mongo_vpn_port, mongo_vpn_database)
    @mongo_vpn_database = mongo_vpn_database
    @mongo_vpn_ip = mongo_vpn_ip
    @mongo_vpn_port = mongo_vpn_port
    client_vpn_host = [mongo_vpn_ip + ":" + mongo_vpn_port]
    @client_vpn = Mongo::Client.new(client_vpn_host, :database => mongo_vpn_database)
    @logger_any = LogAddFunctions_2.new
  end

  #get data by msisdn. Validate data from collection msisdn_list
  def get_mongo_msisdn(msisdn)
    out_resp = {}
    begin
      msisdn_data = []
      collection = client_vpn[:msisdn_list]
      collection.find({:msisdn => msisdn.to_s}).each {|row|
        msisdn_data = row
      }
      if msisdn_data != [] && msisdn_data["msisdn"] != nil && msisdn_data["msisdn"] != ""
        if msisdn_data["group_id"] != [] && msisdn_data["group_id"] != nil && msisdn_data["group_id"] != ""
          if msisdn_data["profile_id"] != [] && msisdn_data["profile_id"] != nil && msisdn_data["profile_id"] != ""
            out_resp = {:code => 200, :result => "get_mongo_msisdn: Request completed successfully", :body => msisdn_data}
          else
            out_resp = {:code => 406, :result => "get_mongo_msisdn: invalid data. profile_id not found"}
          end
        else
          out_resp = {:code => 405, :result => "get_mongo_msisdn: invalid data. organization_id not found"}
        end
      else
        out_resp = {:code => 404, :result => "get_mongo_msisdn: login not found in database"}
      end
    rescue
      out_resp = {:code => 507, :result => "get_mongo_msisdn: Unknown SDK error"}
    end
    logger_any.printer_texter(out_resp, "debug")
    out_resp
  end



end


Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
imperituroard-1.1.23 lib/imperituroard/projects/autovpn/mongo_vpn.rb
imperituroard-1.1.22 lib/imperituroard/projects/autovpn/mongo_vpn.rb
imperituroard-1.1.21 lib/imperituroard/projects/autovpn/mongo_vpn.rb
imperituroard-1.1.20 lib/imperituroard/projects/autovpn/mongo_vpn.rb
imperituroard-1.1.19 lib/imperituroard/projects/autovpn/mongo_vpn.rb
imperituroard-1.1.18 lib/imperituroard/projects/autovpn/mongo_vpn.rb
imperituroard-1.1.17 lib/imperituroard/projects/autovpn/mongo_vpn.rb
imperituroard-1.1.15 lib/imperituroard/projects/autovpn/mongo_vpn.rb
imperituroard-1.1.14 lib/imperituroard/projects/autovpn/mongo_vpn.rb
imperituroard-1.1.13 lib/imperituroard/projects/autovpn/mongo_vpn.rb
imperituroard-1.1.12 lib/imperituroard/projects/autovpn/mongo_vpn.rb
imperituroard-1.1.11 lib/imperituroard/projects/autovpn/mongo_vpn.rb
imperituroard-1.1.10 lib/imperituroard/projects/autovpn/mongo_vpn.rb
imperituroard-1.1.9 lib/imperituroard/projects/autovpn/mongo_vpn.rb
imperituroard-1.1.8 lib/imperituroard/projects/autovpn/mongo_vpn.rb