servicenow 1.1.2 → 1.1.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/lib/servicenow.rb +6 -9
- data/lib/servicenow/change.rb +8 -7
- data/lib/servicenow/client.rb +8 -7
- data/lib/servicenow/version.rb +1 -1
- data/servicenow.gemspec +4 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18c4645dd46a4043144d7f0f95a6283be65ad32f
|
4
|
+
data.tar.gz: cecb08079b14e3c1679d5cdf59c2ccbc944fd12c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ad4abf79e426b25f34aad75c3fa39be3148ba1a8d98951c292690013d497a419820685af52eeca1fab190475d5b8a559d371d0cbecc2bb1728de6c84895401f
|
7
|
+
data.tar.gz: 57bd61e2b229770c7f354c38c767d362f9d5ec4cf807c08bc5cf4491a408e4c8f168d7ae19ec1836693130dc31e8d7e86021f9b14dba136b3ec5f6130ea7ff40
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# servicenow [](https://travis-ci.org/rubyisbeautiful/servicenow)[](https://travis-ci.org/rubyisbeautiful/servicenow)[](https://codeclimate.com/github/rubyisbeautiful/servicenow)
|
2
2
|
This is a very simple, WIP REST API Client for ServiceNow.
|
3
3
|
|
4
4
|
|
data/Rakefile
CHANGED
data/lib/servicenow.rb
CHANGED
@@ -2,6 +2,9 @@ require 'servicenow/version'
|
|
2
2
|
require 'servicenow/client'
|
3
3
|
require 'servicenow/change'
|
4
4
|
|
5
|
+
# This module is the base for the ServiceNow gem. It's primary
|
6
|
+
# interface consists of the 'configure', 'configuration'
|
7
|
+
# and 'logger' methods
|
5
8
|
module Servicenow
|
6
9
|
|
7
10
|
@logger = nil
|
@@ -20,18 +23,14 @@ module Servicenow
|
|
20
23
|
#
|
21
24
|
# @yieldparam config [Servicenow::Configuration]
|
22
25
|
def self.configure(&block)
|
23
|
-
if @configuration.nil?
|
24
|
-
@configuration = OpenStruct.new({})
|
25
|
-
end
|
26
|
+
@configuration = OpenStruct.new({}) if @configuration.nil?
|
26
27
|
yield @configuration
|
27
28
|
end
|
28
29
|
|
29
30
|
|
30
31
|
# @return [Servicenow::Configuration]
|
31
32
|
def self.configuration
|
32
|
-
if @configuration.nil?
|
33
|
-
@configuration = OpenStruct.new({})
|
34
|
-
end
|
33
|
+
@configuration = OpenStruct.new({}) if @configuration.nil?
|
35
34
|
@configuration
|
36
35
|
end
|
37
36
|
|
@@ -48,9 +47,7 @@ module Servicenow
|
|
48
47
|
#
|
49
48
|
# @return [Logger] the module logger
|
50
49
|
def self.logger
|
51
|
-
if @logger.nil?
|
52
|
-
@logger = Logger.new(STDOUT)
|
53
|
-
end
|
50
|
+
@logger = Logger.new(STDOUT) if @logger.nil?
|
54
51
|
@logger
|
55
52
|
end
|
56
53
|
|
data/lib/servicenow/change.rb
CHANGED
@@ -2,6 +2,9 @@ require 'ostruct'
|
|
2
2
|
|
3
3
|
module Servicenow
|
4
4
|
|
5
|
+
# This class represents a ServiceNow Change. A Change is a local
|
6
|
+
# representation of the state of the remote. For writing operations, the
|
7
|
+
# local is updated, and then a request to update the remote is sent
|
5
8
|
class Change < OpenStruct
|
6
9
|
|
7
10
|
@_client = nil
|
@@ -16,7 +19,7 @@ module Servicenow
|
|
16
19
|
work_notes: notes
|
17
20
|
}
|
18
21
|
|
19
|
-
|
22
|
+
client.send_request(url, query, :patch)
|
20
23
|
change
|
21
24
|
end
|
22
25
|
|
@@ -33,7 +36,7 @@ module Servicenow
|
|
33
36
|
work_start: Time.now.utc
|
34
37
|
}.merge(extra)
|
35
38
|
|
36
|
-
|
39
|
+
client.send_request(url, query, :patch)
|
37
40
|
change
|
38
41
|
end
|
39
42
|
|
@@ -50,7 +53,7 @@ module Servicenow
|
|
50
53
|
work_end: Time.now.utc
|
51
54
|
}.merge(extra)
|
52
55
|
|
53
|
-
|
56
|
+
client.send_request(url, query, :patch)
|
54
57
|
change
|
55
58
|
end
|
56
59
|
|
@@ -70,9 +73,7 @@ module Servicenow
|
|
70
73
|
|
71
74
|
|
72
75
|
def client
|
73
|
-
if @_client.nil?
|
74
|
-
@_client = Servicenow::Client.new
|
75
|
-
end
|
76
|
+
@_client = Servicenow::Client.new if @_client.nil?
|
76
77
|
@_client
|
77
78
|
end
|
78
79
|
|
@@ -83,7 +84,7 @@ module Servicenow
|
|
83
84
|
'work in progress' => 2,
|
84
85
|
'work complete' => 11,
|
85
86
|
'work incomplete' => 4,
|
86
|
-
'waiting on user' => -5
|
87
|
+
'waiting on user' => -5
|
87
88
|
}
|
88
89
|
end
|
89
90
|
|
data/lib/servicenow/client.rb
CHANGED
@@ -4,6 +4,7 @@ require 'json'
|
|
4
4
|
|
5
5
|
module Servicenow
|
6
6
|
|
7
|
+
# Client is the client to interact with the ServiceNow REST API
|
7
8
|
class Client
|
8
9
|
|
9
10
|
attr_reader :snow_api_base_url, :snow_table_url
|
@@ -42,8 +43,8 @@ module Servicenow
|
|
42
43
|
def get_changes_by_user(user_id)
|
43
44
|
url = format('%s/change_request', @snow_table_url)
|
44
45
|
query = {
|
45
|
-
|
46
|
-
|
46
|
+
sysparm_limit: 10,
|
47
|
+
sysparm_query: "active=true^GOTOu_cr_requester.u_name_idLIKE#{user_id}"
|
47
48
|
}
|
48
49
|
|
49
50
|
response = send_request(url, query)
|
@@ -61,9 +62,9 @@ module Servicenow
|
|
61
62
|
def get_changes_by_query(encodedquery, limit=10, page=1)
|
62
63
|
url = format('%s/change_request', @snow_table_url)
|
63
64
|
query = {
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
sysparm_limit: limit,
|
66
|
+
sysparm_page: page,
|
67
|
+
sysparm_query: encodedquery
|
67
68
|
}
|
68
69
|
|
69
70
|
response = send_request(url, query)
|
@@ -80,8 +81,8 @@ module Servicenow
|
|
80
81
|
def get_change(number)
|
81
82
|
url = format('%s/change_request', @snow_table_url)
|
82
83
|
query = {
|
83
|
-
|
84
|
-
|
84
|
+
sysparm_limit: 1,
|
85
|
+
number: number
|
85
86
|
}
|
86
87
|
|
87
88
|
response = send_request(url, query)
|
data/lib/servicenow/version.rb
CHANGED
data/servicenow.gemspec
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
|
5
4
|
require 'base64'
|
@@ -11,8 +10,8 @@ Gem::Specification.new do |spec|
|
|
11
10
|
spec.authors = ['rubyisbeautiful']
|
12
11
|
spec.email = ['YmNwdGF5bG9yQGdtYWlsLmNvbQ==\n'].collect{ |foo| Base64.decode64(foo) }
|
13
12
|
|
14
|
-
spec.summary =
|
15
|
-
spec.description =
|
13
|
+
spec.summary = 'Simple WIP REST API client for ServiceNow'
|
14
|
+
spec.description = 'This REST API client for ServiceNow is a work in progress'
|
16
15
|
spec.homepage = 'https://github.com/rubyisbeautiful/servicenow'
|
17
16
|
spec.license = 'MIT'
|
18
17
|
|
@@ -25,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
25
24
|
'public gem pushes.'
|
26
25
|
end
|
27
26
|
|
28
|
-
spec.files
|
27
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
29
28
|
f.match(%r{^(test|spec|features)/})
|
30
29
|
end
|
31
30
|
spec.bindir = 'exe'
|