uberbringer 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/uberbringer/date_helper.rb +24 -0
- data/lib/uberbringer/empty_response.rb +5 -0
- data/lib/uberbringer/query_base.rb +48 -8
- data/lib/uberbringer/remedy_service.rb +8 -0
- data/lib/uberbringer/version.rb +1 -1
- data/lib/uberbringer.rb +4 -14
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef0735d82323058c990a13f7ecd0503c876ce3dd
|
4
|
+
data.tar.gz: c2cf0027214d739b128bbb9b10e3706af397a827
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a281085ec07d91a6168a5e3a0b525877663e8212965038fc33794260e722df0eaabf1a9fa4022cf2b483cbbfaee23b53db64e5f11a98052098e7a3bf37f5b3a4
|
7
|
+
data.tar.gz: 8fc24162d1f9d6b2e929ce805cf0261f7b4889e73231c291520cdad2e23050bd2896e03ea0bfa553417e40c42a343b7a315a8aa4355e5b89cc128ff2f9071dd1
|
data/.gitignore
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Uberbringer
|
2
|
+
module DateHelper
|
3
|
+
|
4
|
+
def this_past_sunday
|
5
|
+
Date.today - Date.today.wday
|
6
|
+
end
|
7
|
+
|
8
|
+
def today
|
9
|
+
Date.today - 1
|
10
|
+
end
|
11
|
+
|
12
|
+
def sunday_before_last
|
13
|
+
this_past_sunday - 7
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def date_format(date)
|
19
|
+
date.strftime('%m/%d/%Y')
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -1,36 +1,76 @@
|
|
1
1
|
module Uberbringer
|
2
2
|
class QueryBase < Array
|
3
|
+
include DateHelper
|
3
4
|
|
4
|
-
|
5
|
+
FIELD_MAPPINGS = {
|
5
6
|
:status => 'Status',
|
6
7
|
:submit_date => 'Submit Date',
|
7
8
|
:group => 'Assigned Group'
|
8
9
|
}
|
9
10
|
|
11
|
+
STATUS_MAPPINGS = {
|
12
|
+
:pending => 'Pending',
|
13
|
+
:assigned => 'Assigned',
|
14
|
+
:new => 'New',
|
15
|
+
:in_progress => 'In Progress',
|
16
|
+
:closed => 'Closed',
|
17
|
+
:resolved => 'Resolved'
|
18
|
+
}
|
19
|
+
|
10
20
|
OPERATORS = {
|
11
|
-
:greater_than => '>'
|
21
|
+
:greater_than => '>',
|
22
|
+
:less_than => '<',
|
23
|
+
:not_equal_to => '!=',
|
24
|
+
:equal_to => '='
|
12
25
|
}
|
13
26
|
|
14
27
|
def all_open_tickets
|
15
|
-
|
28
|
+
filter_by_status([STATUS_MAPPINGS[:pending],STATUS_MAPPINGS[:assigned],STATUS_MAPPINGS[:new],STATUS_MAPPINGS[:in_progress]])
|
29
|
+
end
|
30
|
+
|
31
|
+
def all_closed_tickets
|
32
|
+
filter_by_status([STATUS_MAPPINGS[:closed],STATUS_MAPPINGS[:resolved]])
|
16
33
|
end
|
17
34
|
|
18
35
|
def older_than(number_of_days)
|
19
|
-
self << {:field =>
|
36
|
+
self << {:field => FIELD_MAPPINGS[:submit_date], :value => date_format(Date.today - number_of_days), :operator => OPERATORS[:less_than]}
|
37
|
+
end
|
38
|
+
|
39
|
+
def this_week
|
40
|
+
self << {:field => FIELD_MAPPINGS[:submit_date], :value => date_format(this_past_sunday), :operator => OPERATORS[:greater_than]}
|
41
|
+
end
|
42
|
+
|
43
|
+
def last_week
|
44
|
+
self << {:field => FIELD_MAPPINGS[:submit_date], :value => date_format(sunday_before_last), :operator => OPERATORS[:greater_than]}
|
45
|
+
self << {:field => FIELD_MAPPINGS[:submit_date], :value => date_format(this_past_sunday), :operator => OPERATORS[:less_than]}
|
20
46
|
end
|
21
47
|
|
22
48
|
def submitted_today
|
23
|
-
self << {:field =>
|
49
|
+
self << {:field => FIELD_MAPPINGS[:submit_date], :value => date_format(today), :operator => OPERATORS[:greater_than]}
|
24
50
|
end
|
25
51
|
|
26
52
|
def for_group(group)
|
27
|
-
self << {:field =>
|
53
|
+
self << {:field => FIELD_MAPPINGS[:group], :value => group}
|
54
|
+
end
|
55
|
+
|
56
|
+
def with_status(status)
|
57
|
+
raise ArgumentError unless status.kind_of?(Array)
|
58
|
+
filter_by_status(map_status(status))
|
59
|
+
end
|
60
|
+
|
61
|
+
def without_status(status)
|
62
|
+
raise ArgumentError unless status.kind_of?(Array)
|
63
|
+
filter_by_status(map_status(status),OPERATORS[:not_equal_to])
|
28
64
|
end
|
29
65
|
|
30
66
|
private
|
31
67
|
|
32
|
-
def
|
33
|
-
|
68
|
+
def filter_by_status(values, operator = OPERATORS[:equal_to])
|
69
|
+
self << {:field => FIELD_MAPPINGS[:status], :values => values, :operator => operator}
|
70
|
+
end
|
71
|
+
|
72
|
+
def map_status(status)
|
73
|
+
status.map{|s| STATUS_MAPPINGS[s]}
|
34
74
|
end
|
35
75
|
|
36
76
|
end
|
@@ -8,5 +8,13 @@ module Uberbringer
|
|
8
8
|
ssl_verification(false)
|
9
9
|
ssl_version(:TLSv1)
|
10
10
|
|
11
|
+
def execute_query(query)
|
12
|
+
begin
|
13
|
+
self.help_desk_query_list_service(query)
|
14
|
+
rescue Savon::SOAPFault => e
|
15
|
+
@response = EmptyResponse.new if e.message.include? 'ERROR (302): Entry does not exist in database;'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
11
19
|
end
|
12
20
|
end
|
data/lib/uberbringer/version.rb
CHANGED
data/lib/uberbringer.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
require 'soap-object'
|
2
2
|
require 'fig_newton'
|
3
3
|
|
4
|
+
require 'uberbringer/date_helper'
|
4
5
|
require 'uberbringer/query_base'
|
5
6
|
require 'uberbringer/query_builder'
|
6
7
|
require 'uberbringer/remedy_service'
|
8
|
+
require 'uberbringer/empty_response'
|
9
|
+
|
7
10
|
|
8
11
|
module Uberbringer
|
9
12
|
|
@@ -14,7 +17,7 @@ module Uberbringer
|
|
14
17
|
|
15
18
|
def list_with_filter(criteria, options = {})
|
16
19
|
query = normalize_params(@builder.build(criteria), options)
|
17
|
-
|
20
|
+
@service.execute_query(query)
|
18
21
|
end
|
19
22
|
|
20
23
|
def result
|
@@ -23,14 +26,6 @@ module Uberbringer
|
|
23
26
|
|
24
27
|
private
|
25
28
|
|
26
|
-
def call_and_catch(query)
|
27
|
-
begin
|
28
|
-
@service.help_desk_query_list_service(query)
|
29
|
-
rescue Savon::SOAPFault => e
|
30
|
-
@response = EmptyResponse.new if e.message.include? 'ERROR (302): Entry does not exist in database;'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
29
|
def normalize_params(query, options)
|
35
30
|
params = options.merge({:start_record => 0, :max_limit => 10})
|
36
31
|
{
|
@@ -40,9 +35,4 @@ module Uberbringer
|
|
40
35
|
}
|
41
36
|
end
|
42
37
|
|
43
|
-
class EmptyResponse
|
44
|
-
def body
|
45
|
-
{:help_desk_query_list_service_response => {:get_list_values => []}}
|
46
|
-
end
|
47
|
-
end
|
48
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uberbringer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mosaic
|
@@ -65,6 +65,8 @@ files:
|
|
65
65
|
- README.md
|
66
66
|
- Rakefile
|
67
67
|
- lib/uberbringer.rb
|
68
|
+
- lib/uberbringer/date_helper.rb
|
69
|
+
- lib/uberbringer/empty_response.rb
|
68
70
|
- lib/uberbringer/query_base.rb
|
69
71
|
- lib/uberbringer/query_builder.rb
|
70
72
|
- lib/uberbringer/remedy_service.rb
|