samanage 2.1.05 → 2.1.06
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/Gemfile.lock +3 -3
- data/README.md +20 -0
- data/changelog.md +40 -70
- data/lib/samanage.rb +2 -1
- data/lib/samanage/api/time_tracks.rb +15 -0
- data/lib/samanage/version.rb +1 -1
- data/spec/api/samanage_time_tracks_spec.rb +57 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57907ba419f116d71c6213300a479cb66c295fb2
|
4
|
+
data.tar.gz: 5596f9279a0a966be653698370b0a7656d6ff492
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 037f7a2eb6dfcbea53e665458915205574141b560c31fc8808a89c705e2fa9d0daa7621946215b44d3912630fb9d16f2a5824a06f793ad8191b8ac96a912e78b
|
7
|
+
data.tar.gz: 659da3f6311b6810d69a1107ca8ca545da3c82010decf93c727dd702d698cf1671802bad00b83395754720551c2c98cb4db7529f7d279a7c5859d322cb26488c
|
data/Gemfile.lock
CHANGED
@@ -6,7 +6,7 @@ GEM
|
|
6
6
|
diff-lcs (1.3)
|
7
7
|
faker (1.9.1)
|
8
8
|
i18n (>= 0.7)
|
9
|
-
ffi (1.9.
|
9
|
+
ffi (1.9.24)
|
10
10
|
formatador (0.2.5)
|
11
11
|
guard (2.14.2)
|
12
12
|
formatador (>= 0.2.4)
|
@@ -30,7 +30,7 @@ GEM
|
|
30
30
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
31
31
|
rb-inotify (~> 0.9, >= 0.9.7)
|
32
32
|
ruby_dep (~> 1.2)
|
33
|
-
lumberjack (1.0.
|
33
|
+
lumberjack (1.0.13)
|
34
34
|
method_source (0.9.0)
|
35
35
|
multi_xml (0.6.0)
|
36
36
|
nenv (0.3.0)
|
@@ -40,7 +40,7 @@ GEM
|
|
40
40
|
pry (0.11.3)
|
41
41
|
coderay (~> 1.1.0)
|
42
42
|
method_source (~> 0.9.0)
|
43
|
-
rb-fsevent (0.10.
|
43
|
+
rb-fsevent (0.10.3)
|
44
44
|
rb-inotify (0.9.10)
|
45
45
|
ffi (>= 0.5.0, < 2)
|
46
46
|
rspec (3.7.0)
|
data/README.md
CHANGED
@@ -45,6 +45,26 @@ result = api_controller.update_hardware(id: 123, payload: hardware)
|
|
45
45
|
```
|
46
46
|
|
47
47
|
|
48
|
+
### Listing and Searching
|
49
|
+
- Find All Users
|
50
|
+
```ruby
|
51
|
+
users = api_controller.users # returns all users
|
52
|
+
```
|
53
|
+
- Filtering Incidents matching custom field and updated in the last 7 days
|
54
|
+
```ruby
|
55
|
+
incidents = api_controller.incidents(options: {'Custom Field' => 'Some Value', 'updated[]' => 7})
|
56
|
+
```
|
57
|
+
|
58
|
+
- Listing / Searching also responds to blocks
|
59
|
+
```ruby
|
60
|
+
api.controller.users(options: {'Some Filter' => 'Some Value'}) do |user|
|
61
|
+
if user['email'].match(/something/)
|
62
|
+
foo(bar: bar, user: user)
|
63
|
+
else
|
64
|
+
puts "User #{user['email']} did not match"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
```
|
48
68
|
|
49
69
|
|
50
70
|
|
data/changelog.md
CHANGED
@@ -1,119 +1,89 @@
|
|
1
|
-
|
1
|
+
### 2.1.06
|
2
|
+
- Added time track support
|
3
|
+
### 2.1.05
|
2
4
|
- Adding new error checks
|
3
5
|
- Using Faker for tests
|
4
|
-
|
6
|
+
### 2.1.04
|
5
7
|
- params bug fix
|
6
|
-
|
8
|
+
### 2.1.03
|
7
9
|
- Use paths
|
8
|
-
|
9
|
-
# 2.1.02
|
10
|
+
### 2.1.02
|
10
11
|
- Use parmas in all collections
|
11
|
-
|
12
|
-
# 2.1.01
|
12
|
+
### 2.1.01
|
13
13
|
- Added solutions
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
# 2.0.04
|
14
|
+
### 2.1.0
|
15
|
+
- Use `URI###encode_www_form`
|
16
|
+
### 2.0.04
|
19
17
|
- Fix case sensitivity relationships
|
20
18
|
|
21
|
-
|
19
|
+
### 2.0.03
|
22
20
|
- Bugfix for custom fields (fix httparty version)
|
23
|
-
|
24
|
-
# 2.0.0
|
21
|
+
### 2.0.0
|
25
22
|
- Support for responding to blocks in all paginated collection methods
|
26
23
|
- Added Changes (itsm)
|
27
|
-
|
28
|
-
# 1.9.35
|
24
|
+
### 1.9.35
|
29
25
|
- Solve warnings
|
30
|
-
|
31
|
-
# 1.9.34
|
26
|
+
### 1.9.34
|
32
27
|
- Solve warnings
|
33
|
-
|
34
|
-
# 1.9.33
|
28
|
+
### 1.9.33
|
35
29
|
- Using new cert
|
36
|
-
|
37
|
-
# 1.9.32
|
30
|
+
### 1.9.32
|
38
31
|
- Adding layout long for single incident
|
39
32
|
- Adding attachment downloads
|
40
|
-
|
41
|
-
# 1.9.31
|
33
|
+
### 1.9.31
|
42
34
|
- Alias original comment method
|
43
35
|
- Remove (keyword: nil)
|
44
36
|
- Collapse error retry output
|
45
|
-
|
46
|
-
# 1.9.3
|
37
|
+
### 1.9.3
|
47
38
|
- Handle HTTP Read Timeout
|
48
|
-
|
49
|
-
# 1.9.2
|
39
|
+
### 1.9.2
|
50
40
|
- Adding delete functionality for modules Contracts, Departments, Groups, Hardwares, Incidents, Mobiles, Other_assets, Sites, Users
|
51
|
-
|
52
|
-
# 1.9.1
|
41
|
+
### 1.9.1
|
53
42
|
- Adding items to contracts & faster tests
|
54
|
-
|
55
|
-
# 1.9.0
|
43
|
+
### 1.9.0
|
56
44
|
- Adding contracts
|
57
|
-
|
58
|
-
# 1.8.91
|
45
|
+
### 1.8.91
|
59
46
|
- Group case sensitivity fix
|
60
|
-
|
61
|
-
# 1.8.9
|
47
|
+
### 1.8.9
|
62
48
|
- Adding output verbosity for collection methods
|
63
|
-
|
64
|
-
# 1.8.8
|
49
|
+
### 1.8.8
|
65
50
|
- Base level .execute delete functionality
|
66
51
|
- Error message for invalid http methods
|
67
52
|
- Added audit_archive to incident options
|
68
|
-
|
69
|
-
# 1.8.7
|
53
|
+
### 1.8.7
|
70
54
|
- Fixing retry bug
|
71
|
-
|
72
|
-
# 1.8.6
|
55
|
+
### 1.8.6
|
73
56
|
- Removing layout=long verbosity
|
74
|
-
|
75
|
-
# 1.8.5
|
57
|
+
### 1.8.5
|
76
58
|
- Adding option for incidents layout=long
|
77
|
-
|
78
|
-
# 1.8.3
|
59
|
+
### 1.8.3
|
79
60
|
- Additional Request Timeout retry support
|
80
61
|
- Support for non-parsed responseq
|
81
62
|
- Moving non object specific methods to samanage/api/utils
|
82
63
|
- Added activation emails
|
83
|
-
|
84
|
-
# 1.8.2
|
64
|
+
### 1.8.2
|
85
65
|
- Adding Category support
|
86
|
-
|
87
|
-
#1.8.1
|
66
|
+
###1.8.1
|
88
67
|
- More flexible membership adding
|
89
68
|
- Collection method aliasing for simpler api (old methods will be removed in v2.0)
|
90
|
-
|
91
|
-
#1.8.0
|
69
|
+
###1.8.0
|
92
70
|
- Adding coverage for invalid api requests
|
93
|
-
|
94
|
-
#1.7.9
|
71
|
+
###1.7.9
|
95
72
|
- Solving eu datacenter support against base_url
|
96
|
-
|
73
|
+
###1.7.8
|
97
74
|
- Fixing nil condition in user_id methods
|
98
|
-
|
99
|
-
#1.7.6
|
75
|
+
###1.7.6
|
100
76
|
- Adding group_id find methods for group name and user email
|
101
|
-
|
102
|
-
#1.7.5
|
77
|
+
###1.7.5
|
103
78
|
- Adding site, department, group creation
|
104
|
-
|
105
|
-
#1.7.4
|
79
|
+
###1.7.4
|
106
80
|
- Solving admin listing issue
|
107
|
-
|
108
|
-
#1.7.2
|
81
|
+
###1.7.2
|
109
82
|
- Catching refused connections as Samanage::Error
|
110
|
-
|
111
|
-
#1.7.1
|
83
|
+
###1.7.1
|
112
84
|
- Client Side SSL certificate Forced
|
113
|
-
|
114
|
-
#1.7.0
|
85
|
+
###1.7.0
|
115
86
|
- Switched to HTTParty
|
116
87
|
- Payload now responds to `Hash`. `Strings` will be parsed using `JSON.parse(payload)`
|
117
|
-
|
118
|
-
#1.6.9
|
88
|
+
###1.6.9
|
119
89
|
- Added support for Mobile Devices
|
data/lib/samanage.rb
CHANGED
@@ -5,8 +5,8 @@ require 'samanage/api'
|
|
5
5
|
require 'samanage/api/attachments'
|
6
6
|
require 'samanage/api/category'
|
7
7
|
require 'samanage/api/changes'
|
8
|
-
require 'samanage/api/contracts'
|
9
8
|
require 'samanage/api/comments'
|
9
|
+
require 'samanage/api/contracts'
|
10
10
|
require 'samanage/api/custom_fields'
|
11
11
|
require 'samanage/api/custom_forms'
|
12
12
|
require 'samanage/api/departments'
|
@@ -18,6 +18,7 @@ require 'samanage/api/other_assets'
|
|
18
18
|
require 'samanage/api/requester'
|
19
19
|
require 'samanage/api/sites'
|
20
20
|
require 'samanage/api/solutions'
|
21
|
+
require 'samanage/api/time_tracks'
|
21
22
|
require 'samanage/api/users'
|
22
23
|
require 'samanage/api/utils'
|
23
24
|
require 'samanage/error'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Samanage
|
2
|
+
class Api
|
3
|
+
def time_tracks(incident_id: )
|
4
|
+
self.execute(path: "incidents/#{incident_id}/time_tracks.json")[:data]
|
5
|
+
end
|
6
|
+
|
7
|
+
def create_time_track(incident_id: , payload: )
|
8
|
+
self.execute(path: "incidents/#{incident_id}/time_tracks.json", http_method: 'post', payload: payload)
|
9
|
+
end
|
10
|
+
|
11
|
+
def update_time_track(incident_id: ,time_track_id: ,payload: )
|
12
|
+
self.execute(path: "incidents/#{incident_id}/time_tracks.json")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/samanage/version.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'samanage'
|
2
|
+
require 'faker'
|
3
|
+
|
4
|
+
describe Samanage::Api do
|
5
|
+
context 'Site' do
|
6
|
+
before(:all) do
|
7
|
+
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
8
|
+
@samanage = Samanage::Api.new(token: TOKEN)
|
9
|
+
@incidents = @samanage.incidents
|
10
|
+
end
|
11
|
+
it 'creates a time_track' do
|
12
|
+
incident_id = @incidents.sample.dig('id')
|
13
|
+
name = [Faker::NatoPhoneticAlphabet.code_word,Faker::NatoPhoneticAlphabet.code_word,Faker::NatoPhoneticAlphabet.code_word].join(' ')
|
14
|
+
minutes = rand(1000)
|
15
|
+
request = @samanage.create_time_track(incident_id: incident_id, payload: {
|
16
|
+
time_track: {
|
17
|
+
name: name,
|
18
|
+
minutes_parsed: minutes
|
19
|
+
}
|
20
|
+
})
|
21
|
+
expect(request[:code]).to eq(201).or(200)
|
22
|
+
expect(request[:data].dig('minutes')).to eq(minutes)
|
23
|
+
end
|
24
|
+
it 'Finds time tracks' do
|
25
|
+
incidents_with_time_tracks = @incidents.select{|incident| !incident['time_tracks'].to_a.empty?}
|
26
|
+
incident_id = incidents_with_time_tracks.sample.dig('id')
|
27
|
+
time_tracks = @samanage.time_tracks(incident_id: incident_id)
|
28
|
+
expect(time_tracks).to be_an(Array)
|
29
|
+
expect(time_tracks).not_to be_empty
|
30
|
+
end
|
31
|
+
it 'updates a time_track' do
|
32
|
+
incidents_with_time_tracks = @incidents.select{|incident| !incident['time_tracks'].to_a.empty?}
|
33
|
+
incident_id = incidents_with_time_tracks.sample.dig('id')
|
34
|
+
time_tracks = @samanage.time_tracks(incident_id: incident_id)
|
35
|
+
time_track_id = time_tracks.sample.dig('id')
|
36
|
+
name = [Faker::NatoPhoneticAlphabet.code_word,Faker::NatoPhoneticAlphabet.code_word,Faker::NatoPhoneticAlphabet.code_word].join(' ')
|
37
|
+
minutes = rand(1000)
|
38
|
+
request = @samanage.update_time_track(time_track_id: time_track_id, incident_id: incident_id, payload: {
|
39
|
+
time_track: {
|
40
|
+
name: name,
|
41
|
+
minutes_parsed: minutes
|
42
|
+
}
|
43
|
+
})
|
44
|
+
expect(request[:code]).to eq(200).or(201)
|
45
|
+
end
|
46
|
+
it 'Returns empty when no time tracks for valid incident' do
|
47
|
+
incidents_without_time_tracks = @incidents.reject{|incident| !incident['time_tracks'].to_a.empty?}
|
48
|
+
incident_id = incidents_without_time_tracks.sample.dig('id')
|
49
|
+
time_tracks = @samanage.time_tracks(incident_id: incident_id)
|
50
|
+
expect(time_tracks).to be_an(Array)
|
51
|
+
expect(time_tracks).to be_empty
|
52
|
+
end
|
53
|
+
it 'fails when invalid incident' do
|
54
|
+
expect { @samanage.time_tracks(incident_id: rand(100)) }.to raise_error(Samanage::NotFound)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: samanage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.06
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Walls
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- lib/samanage/api/requester.rb
|
70
70
|
- lib/samanage/api/sites.rb
|
71
71
|
- lib/samanage/api/solutions.rb
|
72
|
+
- lib/samanage/api/time_tracks.rb
|
72
73
|
- lib/samanage/api/users.rb
|
73
74
|
- lib/samanage/api/utils.rb
|
74
75
|
- lib/samanage/error.rb
|
@@ -92,6 +93,7 @@ files:
|
|
92
93
|
- spec/api/samanage_other_asset_spec.rb
|
93
94
|
- spec/api/samanage_site_spec.rb
|
94
95
|
- spec/api/samanage_solution_spec.rb
|
96
|
+
- spec/api/samanage_time_tracks_spec.rb
|
95
97
|
- spec/api/samanage_user_spec.rb
|
96
98
|
- spec/api/samanage_util_spec.rb
|
97
99
|
- spec/samanage_api_spec.rb
|