icws 0.0.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Glinski
@@ -14,28 +14,28 @@ dependencies:
14
14
  name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: Ruby wrapper around ICWS
@@ -46,13 +46,6 @@ extra_rdoc_files: []
46
46
  files:
47
47
  - LICENSE
48
48
  - RAKEFILE
49
- - lib/configuration/configurationitem.rb
50
- - lib/configuration/users.rb
51
- - lib/configuration/workgroups.rb
52
- - lib/connection.rb
53
- - lib/feature.rb
54
- - lib/icws/INTERNAL/challangemessagehandler.rb
55
- - lib/icws/INTERNAL/internalconnection.rb
56
49
  - lib/icws/configuration/configurationitem.rb
57
50
  - lib/icws/configuration/roles.rb
58
51
  - lib/icws/configuration/stations.rb
@@ -69,17 +62,9 @@ files:
69
62
  - lib/icws/status/status.rb
70
63
  - lib/icws/status/statusmessage.rb
71
64
  - lib/icws/status/userstatus.rb
72
- - lib/icwsclient.rb
73
- - lib/messages/messagequeue.rb
74
- - lib/messages/messagesubscriber.rb
75
- - lib/statistics/statisticcategory.rb
76
- - lib/statistics/statisticdefinition.rb
77
- - lib/statistics/statistics.rb
78
- - lib/status/status.rb
79
- - lib/status/statusmessage.rb
80
- - lib/status/userstatus.rb
81
65
  homepage: https://github.com/InteractiveIntelligence/ICWSRubyGem
82
- licenses: []
66
+ licenses:
67
+ - MPLv2
83
68
  metadata: {}
84
69
  post_install_message:
85
70
  rdoc_options: []
@@ -102,3 +87,4 @@ signing_key:
102
87
  specification_version: 3
103
88
  summary: open source Ruby wrapper around ICWS
104
89
  test_files: []
90
+ has_rdoc:
@@ -1,35 +0,0 @@
1
- require '..\lib\connection.rb'
2
- require '..\lib\icwsclient.rb'
3
-
4
- class ICWS
5
- class Configuration
6
- class ConfigurationItem
7
- protected
8
- def initialize(connection, class_name)
9
- @uri = '/configuration/'+ class_name
10
- @client = ICWS::Client.new connection
11
- end
12
-
13
- public
14
- def get(id, fields="configurationId")
15
- @client.get(@uri + '/' + id + '?select='+ fields)
16
- end
17
-
18
- def delete(id)
19
- @client.delete @uri + '/' + id
20
- end
21
-
22
- def get_all(fields="configurationId")
23
- @client.get @uri + '?select='+ fields
24
- end
25
-
26
- def create_new(new_item)
27
- @client.post @uri, new_item
28
- end
29
-
30
- def update(id, configuration_item)
31
- @client.put @uri + '/' + id, configuration_item
32
- end
33
- end
34
- end
35
- end
@@ -1,11 +0,0 @@
1
- require '..\lib\configuration\configurationitem.rb'
2
-
3
- class ICWS
4
- class Configuration
5
- class Users < ICWS::Configuration::ConfigurationItem
6
- def initialize(connection)
7
- super(connection,'users')
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- require '..\lib\configuration\configurationitem.rb'
2
-
3
- class ICWS
4
- class Configuration
5
- class Workgroups < ICWS::Configuration::ConfigurationItem
6
- def initialize(connection)
7
- super(connection,'workgroups')
8
- end
9
- end
10
- end
11
- end
data/lib/connection.rb DELETED
@@ -1,75 +0,0 @@
1
- require 'rest_client'
2
- require 'rubygems'
3
- require 'json'
4
- require '..\lib\feature.rb'
5
-
6
- class ICWS
7
- class Connection
8
- # Creates a new connection
9
- # @param applicationName [String] the name of the application
10
- # @param server [String] the server to connect to
11
- def initialize(application_name, server)
12
- @application_name = application_name
13
- @server = server
14
- end
15
-
16
- # Connects to the server
17
- # @param user [String] the name of the user to connect with
18
- # @param password [String] the password for the user
19
- def connect(user, password)
20
- connectResponse = RestClient.post @server +'/icws/connection',
21
- { '__type' => "urn:inin.com:connection:icAuthConnectionRequestSettings",
22
- :applicationName => @application_name,
23
- :userID => user,
24
- :password => password}.to_json,
25
- :content_type => :json,
26
- :accept => :json,
27
- 'Accept-Language' => 'en-us'
28
-
29
- response = JSON.parse(connectResponse);
30
- @cookie = connectResponse.headers[:set_cookie][0]
31
- @csrf_token = response['csrfToken']
32
- @session_id = response['sessionId']
33
-
34
- end
35
-
36
- def application_name
37
- @application_name
38
- end
39
-
40
- def token
41
- @csrf_token
42
- end
43
-
44
- def cookie
45
- @cookie
46
- end
47
-
48
- # Gets the url of the server
49
- # @return [String] the url of the server
50
- def server
51
- @server
52
- end
53
-
54
- # Gets the version of the server
55
- # @return [String] the version of the server
56
- def version
57
- JSON.parse RestClient.get @server+'/icws/connection/version'
58
- end
59
-
60
- # Gets the features of the server
61
- # @return [Array[ICWS::Connection::Features]] the features of the server
62
- def features
63
- data = JSON.parse RestClient.get @server+'/icws/connection/features'
64
- features = data["featureInfoList"].map { |rd| ICWS::Connection::Feature.new(rd["featureId"], rd["version"]) }
65
- end
66
-
67
- def generate_uri(path)
68
- @server+'/icws/' + @session_id +'/' + path
69
- end
70
-
71
- def base_uri
72
- @server+'/icws/' + @session_id +'/'
73
- end
74
- end
75
- end
data/lib/feature.rb DELETED
@@ -1,12 +0,0 @@
1
- class ICWS
2
- class Connection
3
- class Feature
4
- attr_accessor :feature, :version
5
-
6
- def initialize(feature, version)
7
- @feature = feature
8
- @version = version
9
- end
10
- end
11
- end
12
- end
@@ -1,25 +0,0 @@
1
- require '.icws/messages/messagesubscriber.rb'
2
-
3
- class ICWS
4
- class ChallangeMessageHandler < MessageSubscriber
5
- def initialize(connection, message_queue)
6
- super(connection, message_queue,'urn:inin.com:messaging:message6')
7
- end
8
- def event_received(message)
9
- nonce = message['value']
10
-
11
- response_arr = Array.new(nonce.length)
12
-
13
- for i in 0..nonce.length do
14
- response_arr[2*i] = nonce[i]
15
- response_arr[2*i+1] = @application_name[i % @application_name.length]
16
- end
17
-
18
- response = {}
19
- response['_'] = response_arr.join
20
-
21
- @client.post '/messaging/m', response
22
-
23
- end
24
- end
25
- end
@@ -1 +0,0 @@
1
- #:ininInternalUseOnly => 'aaIZoS5tNSy81oNrtp3r+N2cZVal5Gbk+3vYO5k9nho=',
data/lib/icwsclient.rb DELETED
@@ -1,40 +0,0 @@
1
- require 'rest_client'
2
- require 'rubygems'
3
- require 'json'
4
-
5
- class ICWS
6
- class Client
7
- def initialize(connection)
8
- @connection = connection
9
- headers = {:Cookie => @connection.cookie,"ININ-ICWS-CSRF-Token" => @connection.token}
10
- @http_resource = RestClient::Resource.new(@connection.base_uri, :headers => headers)
11
- end
12
-
13
- def post(url, body, headers={})
14
- begin
15
- JSON.parse @http_resource[url].post body.to_json, headers
16
- rescue => e
17
- puts e.inspect
18
- throw e
19
- end
20
- end
21
-
22
- def get(url, headers={})
23
- JSON.parse @http_resource[url].get headers
24
- end
25
-
26
- def delete(url, headers={})
27
- @http_resource[url].delete headers
28
- end
29
-
30
- def put(url, body, headers={})
31
- begin
32
- @http_resource[url].put body.to_json, headers
33
- rescue => e
34
- puts e.inspect
35
- throw e
36
- end
37
-
38
- end
39
- end
40
- end
@@ -1,65 +0,0 @@
1
- class ICWS
2
- class MessageQueue
3
- #http://stackoverflow.com/questions/605169/how-to-do-events-in-ruby
4
- class EventHandlerArray < Array
5
- def add_handler(&block)
6
- push(block)
7
- end
8
- def add
9
- raise "error"
10
- end
11
- def remove_handler(code)
12
- delete(code)
13
- end
14
- def fire(e)
15
- reverse_each { |handler|
16
- begin
17
- handler.call(e)
18
- rescue => e
19
- puts e.inspect
20
- end
21
- }
22
- end
23
- end
24
-
25
- def initialize(connection)
26
- @message_handlers = {}
27
- @client = ICWS::Client.new connection
28
-
29
- @pollingThread = Thread.new() {
30
- poll_loop
31
- }
32
- end
33
-
34
- def register(messageType, &block)
35
- if(@message_handlers[messageType] == nil)
36
- @message_handlers[messageType] = EventHandlerArray.new
37
- end
38
- callback = block
39
- @message_handlers[messageType].add_handler {|e| callback.call(e)}
40
- end
41
-
42
- def deregister(messageType, code)
43
- if(@message_handlers[messageType] == nil)
44
- return
45
- end
46
-
47
- @message_handlers[messageType].remove_handler(code)
48
- end
49
-
50
- private
51
- def poll_loop
52
- while true
53
- messages = @client.get '/messaging/messages'
54
- for message in messages
55
- #puts message
56
- type = message['__type']
57
- if @message_handlers[type]
58
- @message_handlers[type].fire(message)
59
- end
60
- end
61
- sleep 1
62
- end
63
- end
64
- end
65
- end
@@ -1,14 +0,0 @@
1
- class ICWS
2
- class MessageSubscriber
3
- def initialize(connection, message_queue, messageId)
4
- message_queue.register(messageId) {|e| event_received(e)}
5
- @application_name = connection.application_name
6
- @client = ICWS::Client.new connection
7
-
8
- end
9
-
10
- def event_received(message)
11
-
12
- end
13
- end
14
- end
@@ -1,22 +0,0 @@
1
- require '..\lib\statistics\statisticdefinition.rb'
2
-
3
- class ICWS
4
- class StatisticCategory
5
- attr_reader :statistic_category_id
6
- attr_reader :display_string
7
- attr_reader :description
8
- attr_reader :statistic_definitions
9
-
10
- def initialize(propertyMap)
11
- @statistic_category_id = propertyMap['statisticCategoryId']
12
- @display_string = propertyMap['displayString']
13
- @description = propertyMap['description']
14
- @statistic_definitions = []
15
- propertyMap['statisticDefinitions'].each {|s| @statistic_definitions.push ICWS::StatisticDefinition.new(s)}
16
- end
17
-
18
- def to_s
19
- @display_string + '(' + @statistic_category_id + ')'
20
- end
21
- end
22
- end
@@ -1,20 +0,0 @@
1
-
2
- class ICWS
3
- class StatisticDefinition
4
- attr_reader :statistic_identifier
5
- attr_reader :display_string
6
- attr_reader :description
7
- attr_reader :units_display
8
-
9
- def initialize(propertyMap)
10
- @statistic_identifier = propertyMap['statisticIdentifier']
11
- @display_string = propertyMap['displayString']
12
- @description = propertyMap['description']
13
- @units_display = propertyMap['unitsDisplay']
14
- end
15
-
16
- def to_s
17
- ' ' + @display_string + '(' + @statistic_identifier + ')'
18
- end
19
- end
20
- end
@@ -1,24 +0,0 @@
1
- require '..\lib\messages\messagesubscriber.rb'
2
- require '..\lib\statistics\statisticcategory.rb'
3
-
4
- class ICWS
5
- class Statistics < MessageSubscriber
6
- attr_reader :statistic_catalog
7
-
8
- def initialize(connection, message_queue)
9
- super(connection, message_queue,'urn:inin.com:statistics:statisticCatalogMessage')
10
- @client = ICWS::Client.new connection
11
- @client.put '/messaging/subscriptions/statistics/statistic-catalog', {}
12
-
13
- end
14
-
15
- def event_received(message)
16
- if message['__type'] == 'urn:inin.com:statistics:statisticCatalogMessage'
17
- @statistic_catalog = []
18
- message['statisticCategoryList'].each {|s| @statistic_catalog.push ICWS::StatisticCategory.new(s)}
19
-
20
- end
21
- end
22
-
23
- end
24
- end