Class: InewsClient::System

Inherits:
Struct
  • Object
show all
Defined in:
lib/inews_client/system.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#auth_cookiesObject

Returns the value of attribute auth_cookies

Returns:

  • (Object)

    the current value of auth_cookies



2
3
4
# File 'lib/inews_client/system.rb', line 2

def auth_cookies
  @auth_cookies
end

Class Method Details

.clientObject



20
21
22
# File 'lib/inews_client/system.rb', line 20

def self.client
  Savon.client(client_options)
end

.client_optionsObject



7
8
9
10
11
12
13
14
# File 'lib/inews_client/system.rb', line 7

def self.client_options
  {
    wsdl: "#{ENV['wsdl']}/inewswebservice/services/inewssystem?wsdl",
    namespaces:{
      "xmlns:types" => "http://avid.com/inewssystem/types",
    },
  }
end

.connect(options) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/inews_client/system.rb', line 24

def self.connect(options)
  message = {
    'types:Username' => "#{options['username']}",
    'types:Password' => "#{options['password']}",
    'types:Servername' => "#{options['servername']}",
  }
  client.call(:connect, message: message)
end

.session(options, &block) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/inews_client/system.rb', line 44

def self.session(options, &block)
  response = connect(options)
  auth_cookies = response.http.cookies
  if auth_cookies
    client = InewsClient::System.new(auth_cookies)
    block.call(client)
  end
rescue Exception => e
  puts e
ensure
  if auth_cookies
    self.client.call(:disconnect, cookies: auth_cookies)
  end
end

Instance Method Details

#ensure_connected!Object



37
38
39
40
41
42
# File 'lib/inews_client/system.rb', line 37

def ensure_connected!
  unless is_connected(auth_cookies).body[:is_connected_response][:is_connected]
    response = connect
    self.auth_cookies = response.http.cookies
  end
end

#get_auth_cookiesObject



16
17
18
# File 'lib/inews_client/system.rb', line 16

def get_auth_cookies
  auth_cookies
end

#is_connected(auth_cookies) ⇒ Object



33
34
35
# File 'lib/inews_client/system.rb', line 33

def is_connected(auth_cookies)
  client.call(:is_connected, cookies: auth_cookies)
end

#queueObject



3
4
5
# File 'lib/inews_client/system.rb', line 3

def queue
  @queue ||= InewsClient::Queue.new(self)
end