Class: Gms_2

Inherits:
Object
  • Object
show all
Defined in:
lib/imperituroard/projects/mhub/subs/evrotorg/gms_connector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gms_login, gms_password, telegram_api_url, telegram_chat_id) ⇒ Gms_2

Returns a new instance of Gms_2.



18
19
20
21
22
23
# File 'lib/imperituroard/projects/mhub/subs/evrotorg/gms_connector.rb', line 18

def initialize(, gms_password, telegram_api_url, telegram_chat_id)
  @gms_login = 
  @gms_password = gms_password
  @internal_func = InternalFunc.new
  @telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
end

Instance Attribute Details

#gms_loginObject

Returns the value of attribute gms_login.



16
17
18
# File 'lib/imperituroard/projects/mhub/subs/evrotorg/gms_connector.rb', line 16

def 
  @gms_login
end

#gms_passwordObject

Returns the value of attribute gms_password.



16
17
18
# File 'lib/imperituroard/projects/mhub/subs/evrotorg/gms_connector.rb', line 16

def gms_password
  @gms_password
end

#internal_funcObject

Returns the value of attribute internal_func.



16
17
18
# File 'lib/imperituroard/projects/mhub/subs/evrotorg/gms_connector.rb', line 16

def internal_func
  @internal_func
end

#telegram_connectorObject

Returns the value of attribute telegram_connector.



16
17
18
# File 'lib/imperituroard/projects/mhub/subs/evrotorg/gms_connector.rb', line 16

def telegram_connector
  @telegram_connector
end

Instance Method Details

#get_advanced_by_external(external_id) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# 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_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