uberbringer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 923d8c579ec94756faec4a714124935887164b4c
4
+ data.tar.gz: 0fbe29ed8ea0acd2ed62cbbbd5b6f24cfc5fa942
5
+ SHA512:
6
+ metadata.gz: 2efafc1510f6866c39bbe7179a54cd0844caaf79307bd64f71d7f90c4b684054e904c7d771fb9f11d3a448d4141495f8f6042920b1636064980fe0c31c03f26c
7
+ data.tar.gz: c77eb23b31dbccbc88ff28bc6305150395ee6beecbeaf62902d1dd876cf3981d50b08a4b72e95fd73d86feeb763fe9704bc4c9b1e1189993f7ea9bab7e90472a
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ .idea/
2
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kendo-page-object-widgets.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,59 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ uberbringer (0.0.1)
5
+ fig_newton
6
+ soap-object
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ akami (1.3.1)
12
+ gyoku (>= 0.4.0)
13
+ nokogiri
14
+ builder (3.2.2)
15
+ diff-lcs (1.2.5)
16
+ fig_newton (0.11)
17
+ yml_reader (>= 0.3)
18
+ gyoku (1.3.1)
19
+ builder (>= 2.1.2)
20
+ httpi (2.4.1)
21
+ rack
22
+ mini_portile (0.6.2)
23
+ nokogiri (1.6.6.2-x86-mingw32)
24
+ mini_portile (~> 0.6.0)
25
+ nori (2.6.0)
26
+ rack (1.6.1)
27
+ rspec (3.1.0)
28
+ rspec-core (~> 3.1.0)
29
+ rspec-expectations (~> 3.1.0)
30
+ rspec-mocks (~> 3.1.0)
31
+ rspec-core (3.1.7)
32
+ rspec-support (~> 3.1.0)
33
+ rspec-expectations (3.1.2)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.1.0)
36
+ rspec-mocks (3.1.3)
37
+ rspec-support (~> 3.1.0)
38
+ rspec-support (3.1.2)
39
+ savon (2.11.1)
40
+ akami (~> 1.2)
41
+ builder (>= 2.1.2)
42
+ gyoku (~> 1.2)
43
+ httpi (~> 2.3)
44
+ nokogiri (>= 1.4.0)
45
+ nori (~> 2.4)
46
+ wasabi (~> 3.4)
47
+ soap-object (0.6.5)
48
+ savon (>= 2.2.0)
49
+ wasabi (3.5.0)
50
+ httpi (~> 2.0)
51
+ nokogiri (>= 1.4.2)
52
+ yml_reader (0.5)
53
+
54
+ PLATFORMS
55
+ x86-mingw32
56
+
57
+ DEPENDENCIES
58
+ rspec (>= 2.12.0)
59
+ uberbringer!
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ Der Uberbringer
2
+
3
+ This gem allows easy access to query the sherwin remedy api.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,37 @@
1
+ module Uberbringer
2
+ class QueryBase < Array
3
+
4
+ REMEDY_FIELDS = {
5
+ :status => 'Status',
6
+ :submit_date => 'Submit Date',
7
+ :group => 'Assigned Group'
8
+ }
9
+
10
+ OPERATORS = {
11
+ :greater_than => '>'
12
+ }
13
+
14
+ def all_open_tickets
15
+ self << {:field => REMEDY_FIELDS[:status], :values => ['Pending', 'Assigned', 'New', 'In Progress']}
16
+ end
17
+
18
+ def older_than(number_of_days)
19
+ self << {:field => REMEDY_FIELDS[:submit_date], :value => date_format(Date.today - number_of_days), :operator => OPERATORS[:greater_than]}
20
+ end
21
+
22
+ def submitted_today
23
+ self << {:field => REMEDY_FIELDS[:submit_date], :value => date_format(Date.today - 1), :operator => OPERATORS[:greater_than]}
24
+ end
25
+
26
+ def for_group(group)
27
+ self << {:field => REMEDY_FIELDS[:group], :value => group}
28
+ end
29
+
30
+ private
31
+
32
+ def date_format(date)
33
+ date.strftime('%m/%d/%Y')
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,41 @@
1
+ module Uberbringer
2
+ class QueryBuilder
3
+
4
+ AND = "\s&&\s"
5
+ OR = "\s||\s"
6
+
7
+ def build(params = [])
8
+ result = params.map do |obj|
9
+ query(with_defaults(obj))
10
+ end
11
+ result.join(AND)
12
+ end
13
+
14
+ private
15
+
16
+ def query(obj)
17
+ return multiple_values(obj) unless obj[:values].nil?
18
+ return single_value(obj) unless obj[:value].nil?
19
+ raise ArgumentError
20
+ end
21
+
22
+ def single_value(obj)
23
+ format_argument(obj[:field], obj[:operator], obj[:value])
24
+ end
25
+
26
+ def multiple_values(obj)
27
+ result = obj[:values].map do |value|
28
+ format_argument(obj[:field], obj[:operator], value)
29
+ end
30
+ "(#{result.join(OR)})"
31
+ end
32
+
33
+ def format_argument(field, operator, value)
34
+ "'#{field}' #{operator} \"#{value}\""
35
+ end
36
+
37
+ def with_defaults(obj)
38
+ {:operator => '='}.merge(obj)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,12 @@
1
+ module Uberbringer
2
+
3
+ class RemedyService
4
+ include SoapObject
5
+
6
+ wsdl FigNewton.remedy_wsdl
7
+ soap_header({'AuthenticationInfo' => {:userName => FigNewton.remedy_username, :password => FigNewton.remedy_password}})
8
+ ssl_verification(false)
9
+ ssl_version(:TLSv1)
10
+
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module Uberbringer
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,48 @@
1
+ require 'soap-object'
2
+ require 'fig_newton'
3
+
4
+ require 'uberbringer/query_base'
5
+ require 'uberbringer/query_builder'
6
+ require 'uberbringer/remedy_service'
7
+
8
+ module Uberbringer
9
+
10
+ def initialize
11
+ @service = RemedyService.new
12
+ @builder = QueryBuilder.new
13
+ end
14
+
15
+ def list_with_filter(criteria, options = {})
16
+ query = normalize_params(@builder.build(criteria), options)
17
+ call_and_catch(query)
18
+ end
19
+
20
+ def result
21
+ @service.body[:help_desk_query_list_service_response][:get_list_values]
22
+ end
23
+
24
+ private
25
+
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
+ def normalize_params(query, options)
35
+ params = options.merge({:start_record => 0, :max_limit => 10})
36
+ {
37
+ 'Qualification' => query,
38
+ 'startRecord' => params[:start_record],
39
+ 'maxLimit' => params[:max_limit]
40
+ }
41
+ end
42
+
43
+ class EmptyResponse
44
+ def body
45
+ {:help_desk_query_list_service_response => {:get_list_values => []}}
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'uberbringer/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "uberbringer"
8
+ gem.version = Uberbringer::VERSION
9
+ gem.authors = ['mosaic']
10
+ gem.email = ["mosaic.development@sherwin.com"]
11
+ gem.description = %q{Wrapper around remedy web service for easy querying}
12
+ gem.summary = %q{Wrapper around remedy web service for easy querying}
13
+ gem.files = `git ls-files`.split($/)
14
+ gem.require_paths = ["lib"]
15
+
16
+ gem.add_dependency 'soap-object'
17
+ gem.add_dependency 'fig_newton'
18
+
19
+ gem.add_development_dependency 'rspec', '>= 2.12.0'
20
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: uberbringer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - mosaic
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: soap-object
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fig_newton
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 2.12.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.12.0
55
+ description: Wrapper around remedy web service for easy querying
56
+ email:
57
+ - mosaic.development@sherwin.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - README.md
66
+ - Rakefile
67
+ - lib/uberbringer.rb
68
+ - lib/uberbringer/query_base.rb
69
+ - lib/uberbringer/query_builder.rb
70
+ - lib/uberbringer/remedy_service.rb
71
+ - lib/uberbringer/version.rb
72
+ - uberbringer.gemspec
73
+ homepage:
74
+ licenses: []
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.0.14
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Wrapper around remedy web service for easy querying
96
+ test_files: []