class Gms_2

Attributes

gms_login[RW]
gms_password[RW]
internal_func[RW]
telegram_connector[RW]

Public Class Methods

new(gms_login, gms_password, telegram_api_url, telegram_chat_id) click to toggle source
# File lib/imperituroard/projects/mhub/subs/evrotorg/gms_connector.rb, line 18
def initialize(gms_login, gms_password, telegram_api_url, telegram_chat_id)
  @gms_login = gms_login
  @gms_password = gms_password
  @internal_func = InternalFunc.new
  @telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
end

Public Instance Methods

get_advanced_by_external(external_id) click to toggle source
# File lib/imperituroard/projects/mhub/subs/evrotorg/gms_connector.rb, line 25
def get_advanced_by_external(external_id)

  input_params = {:external_id => external_id}
  output_params = {}
  thr1_get_advanced_by_external = Thread.new do
    begin
      uri = URI("https://dr-v2.hyber.im/2160/api/dr/external/" + external_id + "/advanced")
      https = Net::HTTP.new(uri.host, uri.port)
      https.use_ssl = true
      https.verify_mode = OpenSSL::SSL::VERIFY_NONE
      req = Net::HTTP::Get.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
      req.basic_auth gms_login, gms_password
      req["Content-Type"] = "application/json"
      res = https.request(req)

      p res.code
      p res.body
      if res.code == "200"
        output_params = {:code => 200,
                         :result => "Gms_2.get_advanced_by_external: Request processed",
                         :body => {:request_message => input_params,
                                   :res_code => res.code,
                                   :res_body => JSON.parse(res.body.to_s)}}
      else
        output_params = {:code => res.code.to_i,
                         :result => "Gms_2.get_advanced_by_external: Request processed",
                         :body => {:request_message => input_params,
                                   :res_code => res.code,
                                   :res_body => res.body.to_s}}
      end
    rescue
      output_params = {:code => 500, :result => "Gms_2.get_advanced_by_external: Something wrong", :body => {:request_message => input_params}}
    end
  end
  thr1_get_advanced_by_external.join

  internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Gms_2.get_advanced_by_external"}, "debug")
  output_params

end