samanage 2.1.19 → 2.1.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +224 -0
- data/Gemfile +12 -7
- data/Gemfile.lock +43 -24
- data/Guardfile +5 -3
- data/changelog.md +92 -19
- data/lib/samanage.rb +33 -30
- data/lib/samanage/api.rb +67 -74
- data/lib/samanage/api/attachments.rb +12 -12
- data/lib/samanage/api/category.rb +9 -7
- data/lib/samanage/api/changes.rb +17 -16
- data/lib/samanage/api/comments.rb +6 -7
- data/lib/samanage/api/contracts.rb +17 -17
- data/lib/samanage/api/custom_fields.rb +6 -6
- data/lib/samanage/api/custom_forms.rb +13 -10
- data/lib/samanage/api/departments.rb +9 -9
- data/lib/samanage/api/groups.rb +21 -20
- data/lib/samanage/api/hardwares.rb +14 -14
- data/lib/samanage/api/incidents.rb +7 -8
- data/lib/samanage/api/mobiles.rb +14 -15
- data/lib/samanage/api/other_assets.rb +14 -14
- data/lib/samanage/api/problems.rb +17 -17
- data/lib/samanage/api/purchase_orders.rb +17 -17
- data/lib/samanage/api/releases.rb +14 -14
- data/lib/samanage/api/requester.rb +4 -2
- data/lib/samanage/api/sites.rb +10 -9
- data/lib/samanage/api/solutions.rb +15 -14
- data/lib/samanage/api/tasks.rb +39 -0
- data/lib/samanage/api/time_tracks.rb +8 -6
- data/lib/samanage/api/users.rb +32 -30
- data/lib/samanage/api/utils.rb +11 -9
- data/lib/samanage/api/vendors.rb +14 -13
- data/lib/samanage/error.rb +5 -4
- data/lib/samanage/language.rb +48 -46
- data/lib/samanage/url_builder.rb +27 -25
- data/lib/samanage/utils.rb +10 -8
- data/lib/samanage/version.rb +1 -1
- data/samanage.gemspec +11 -9
- data/spec/api/samanage_attachment_spec.rb +20 -19
- data/spec/api/samanage_category_spec.rb +12 -10
- data/spec/api/samanage_change_spec.rb +47 -44
- data/spec/api/samanage_comments_spec.rb +12 -10
- data/spec/api/samanage_contract_spec.rb +41 -35
- data/spec/api/samanage_custom_field_spec.rb +7 -5
- data/spec/api/samanage_custom_form_spec.rb +11 -9
- data/spec/api/samanage_department_spec.rb +20 -15
- data/spec/api/samanage_group_spec.rb +30 -28
- data/spec/api/samanage_hardware_spec.rb +44 -38
- data/spec/api/samanage_incident_spec.rb +79 -61
- data/spec/api/samanage_mobile_spec.rb +39 -34
- data/spec/api/samanage_other_asset_spec.rb +50 -44
- data/spec/api/samanage_problem_spec.rb +53 -46
- data/spec/api/samanage_purchase_order_spec.rb +43 -40
- data/spec/api/samanage_release_spec.rb +44 -40
- data/spec/api/samanage_site_spec.rb +18 -16
- data/spec/api/samanage_solution_spec.rb +16 -14
- data/spec/api/samanage_task_spec.rb +68 -0
- data/spec/api/samanage_time_tracks_spec.rb +41 -27
- data/spec/api/samanage_user_spec.rb +51 -46
- data/spec/api/samanage_util_spec.rb +13 -11
- data/spec/api/samanage_vendors_spec.rb +18 -16
- data/spec/samanage_api_spec.rb +27 -23
- data/spec/samanage_category_spec.rb +10 -8
- data/spec/samanage_language_spec.rb +12 -10
- data/spec/samanage_url_builder_spec.rb +11 -9
- data/spec/spec_helper.rb +6 -4
- metadata +5 -2
@@ -1,21 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Samanage
|
2
4
|
class Api
|
3
|
-
|
4
|
-
|
5
5
|
# Find comments given incident_id
|
6
|
-
def get_comments(incident_id:
|
6
|
+
def get_comments(incident_id:)
|
7
7
|
path = "incidents/#{incident_id}/comments.json"
|
8
8
|
self.execute(path: path)
|
9
9
|
end
|
10
10
|
|
11
11
|
# Add a new comment
|
12
|
-
def create_comment(incident_id
|
13
|
-
|
12
|
+
def create_comment(incident_id:, comment:, options: {})
|
14
13
|
path = "incidents/#{incident_id}/comments.json?"
|
15
|
-
self.execute(http_method:
|
14
|
+
self.execute(http_method: "post", path: path, payload: comment, options: options)
|
16
15
|
end
|
17
16
|
|
18
17
|
|
19
18
|
alias_method :comments, :get_comments
|
20
19
|
end
|
21
|
-
end
|
20
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Samanage
|
2
4
|
class Api
|
3
|
-
|
4
5
|
# Get contract default path
|
5
6
|
def get_contracts(path: PATHS[:contract], options: {})
|
6
|
-
|
7
|
-
path = 'contracts.json?'
|
7
|
+
path = "contracts.json?"
|
8
8
|
self.execute(path: path, options: options)
|
9
9
|
end
|
10
10
|
|
@@ -14,7 +14,7 @@ module Samanage
|
|
14
14
|
total_pages = self.get_contracts(options: options)[:total_pages]
|
15
15
|
1.upto(total_pages) do |page|
|
16
16
|
options[:page] = page
|
17
|
-
|
17
|
+
|
18
18
|
puts "Collecting Contracts page: #{page}/#{total_pages}" if options[:verbose]
|
19
19
|
path = "contracts.json?"
|
20
20
|
self.execute(path: path, options: options)[:data].each do |contract|
|
@@ -28,16 +28,16 @@ module Samanage
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# Create contract given json payload
|
31
|
-
def create_contract(payload
|
32
|
-
self.execute(path: PATHS[:contract], http_method:
|
31
|
+
def create_contract(payload:, options: {})
|
32
|
+
self.execute(path: PATHS[:contract], http_method: "post", payload: payload)
|
33
33
|
end
|
34
34
|
|
35
35
|
# Find contract given id
|
36
|
-
def find_contract(id
|
36
|
+
def find_contract(id:, options: {})
|
37
37
|
path = "contracts/#{id}.json"
|
38
38
|
self.execute(path: path, options: {})
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
# Check for contract using URL builder
|
42
42
|
def check_contract(options: {})
|
43
43
|
url = Samanage::UrlBuilder.new(path: PATHS[:contract], options: options).url
|
@@ -45,22 +45,22 @@ module Samanage
|
|
45
45
|
end
|
46
46
|
|
47
47
|
# Update contract given id
|
48
|
-
def update_contract(payload
|
48
|
+
def update_contract(payload:, id:, options: {})
|
49
49
|
path = "contracts/#{id}.json"
|
50
|
-
self.execute(path: path, http_method:
|
50
|
+
self.execute(path: path, http_method: "put", payload: payload)
|
51
51
|
end
|
52
52
|
|
53
|
-
def add_item_to_contract(id
|
53
|
+
def add_item_to_contract(id:, payload:)
|
54
54
|
path = "contracts/#{id}/items.json"
|
55
|
-
self.execute(path: path, http_method:
|
55
|
+
self.execute(path: path, http_method: "post", payload: payload)
|
56
56
|
end
|
57
|
-
|
58
|
-
def delete_contract(id:
|
59
|
-
self.execute(path: "contracts/#{id}.json", http_method:
|
57
|
+
|
58
|
+
def delete_contract(id:)
|
59
|
+
self.execute(path: "contracts/#{id}.json", http_method: "delete")
|
60
60
|
end
|
61
61
|
|
62
62
|
|
63
63
|
|
64
|
-
|
64
|
+
alias_method :contracts, :collect_contracts
|
65
65
|
end
|
66
|
-
end
|
66
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Samanage
|
2
4
|
class Api
|
3
|
-
|
4
5
|
# Get custom fields default url
|
5
|
-
def get_custom_fields(path: PATHS[:custom_fields], options:{})
|
6
|
-
|
7
|
-
path = 'custom_fields.json?'
|
6
|
+
def get_custom_fields(path: PATHS[:custom_fields], options: {})
|
7
|
+
path = "custom_fields.json?"
|
8
8
|
self.execute(path: path, options: options)
|
9
9
|
end
|
10
10
|
|
@@ -14,14 +14,14 @@ module Samanage
|
|
14
14
|
total_pages = self.get_custom_fields(options: options)[:total_pages] ||= 2
|
15
15
|
1.upto(total_pages) do |page|
|
16
16
|
options[:page] = page
|
17
|
-
|
17
|
+
|
18
18
|
puts "Collecting Custom Fields page: #{page}/#{total_pages}" if options[:verbose]
|
19
19
|
path = "custom_fields.json?"
|
20
20
|
self.execute(path: path, options: options)[:data].each do |custom_field|
|
21
21
|
if block_given?
|
22
22
|
yield custom_field
|
23
23
|
end
|
24
|
-
custom_fields << custom_field
|
24
|
+
custom_fields << custom_field
|
25
25
|
end
|
26
26
|
end
|
27
27
|
custom_fields
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Samanage
|
2
4
|
class Api
|
3
5
|
# Get custom forms path
|
4
6
|
def get_custom_forms(path: PATHS[:custom_forms], options: {})
|
5
|
-
|
6
7
|
self.execute(path: path)
|
7
8
|
end
|
8
9
|
|
@@ -12,7 +13,7 @@ module Samanage
|
|
12
13
|
total_pages = self.get_custom_forms(options: options)[:total_pages]
|
13
14
|
1.upto(total_pages) do |page|
|
14
15
|
options[:page] = page
|
15
|
-
|
16
|
+
|
16
17
|
puts "Collecting Custom Forms page: #{page}/#{total_pages}" if options[:verbose]
|
17
18
|
path = "custom_forms.json?"
|
18
19
|
self.execute(path: path, options: options)[:data].each do |custom_form|
|
@@ -28,13 +29,15 @@ module Samanage
|
|
28
29
|
# Set forms by type and map fields
|
29
30
|
def organize_forms
|
30
31
|
custom_forms = self.collect_custom_forms
|
31
|
-
custom_forms.map{|form| form.delete_if{|k, v| v.nil?}}
|
32
|
-
custom_forms.map{|form| form[
|
33
|
-
custom_forms.map
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
custom_forms.map { |form| form.delete_if { |k, v| v.nil? } }
|
33
|
+
custom_forms.map { |form| form["custom_form_fields"].map { |fields| fields.delete_if { |k, v| v == false } } }
|
34
|
+
custom_forms.map { |form|
|
35
|
+
form["custom_form_fields"].map { |fields| fields["custom_field"].delete_if { |k, v| !v } }
|
36
|
+
}
|
37
|
+
custom_forms.group_by { |k|
|
38
|
+
k["module"]}.each_pair { |forms_name, forms|
|
39
|
+
forms.each { |form|
|
40
|
+
form["custom_form_fields"].group_by { |f| f["name"] }
|
38
41
|
}
|
39
42
|
}
|
40
43
|
end
|
@@ -47,4 +50,4 @@ module Samanage
|
|
47
50
|
self.custom_forms[object_type]
|
48
51
|
end
|
49
52
|
end
|
50
|
-
end
|
53
|
+
end
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Samanage
|
2
4
|
class Api
|
3
5
|
def get_departments(path: PATHS[:department], options: {})
|
4
|
-
|
5
|
-
path = 'departments.json?'
|
6
|
+
path = "departments.json?"
|
6
7
|
self.execute(path: path, options: options)
|
7
8
|
end
|
8
9
|
|
@@ -11,7 +12,7 @@ module Samanage
|
|
11
12
|
total_pages = self.get_departments(options: options)[:total_pages]
|
12
13
|
1.upto(total_pages) do |page|
|
13
14
|
options[:page] = page
|
14
|
-
|
15
|
+
|
15
16
|
puts "Collecting Departments page: #{page}/#{total_pages}" if options[:verbose]
|
16
17
|
path = "departments.json?"
|
17
18
|
self.execute(path: path, options: options)[:data].each do |department|
|
@@ -24,14 +25,13 @@ module Samanage
|
|
24
25
|
departments
|
25
26
|
end
|
26
27
|
|
27
|
-
def create_department(payload
|
28
|
-
self.execute(path: PATHS[:department], http_method:
|
29
|
-
|
28
|
+
def create_department(payload:, options: {})
|
29
|
+
self.execute(path: PATHS[:department], http_method: "post", payload: payload)
|
30
30
|
end
|
31
|
-
def delete_department(id:
|
32
|
-
self.execute(path: "departments/#{id}.json", http_method:
|
31
|
+
def delete_department(id:)
|
32
|
+
self.execute(path: "departments/#{id}.json", http_method: "delete")
|
33
33
|
end
|
34
34
|
|
35
35
|
alias_method :departments, :collect_departments
|
36
36
|
end
|
37
|
-
end
|
37
|
+
end
|
data/lib/samanage/api/groups.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Samanage
|
2
4
|
class Api
|
3
5
|
def get_groups(path: PATHS[:group], options: {})
|
4
|
-
|
5
|
-
path = 'groups.json?'
|
6
|
+
path = "groups.json?"
|
6
7
|
self.execute(path: path, options: options)
|
7
8
|
end
|
8
9
|
|
@@ -11,9 +12,9 @@ module Samanage
|
|
11
12
|
total_pages = self.get_groups(options: options)[:total_pages]
|
12
13
|
1.upto(total_pages) do |page|
|
13
14
|
options[:page] = page
|
14
|
-
|
15
|
+
|
15
16
|
puts "Collecting Groups page: #{page}/#{total_pages}" if options[:verbose]
|
16
|
-
path =
|
17
|
+
path = "groups.json?"
|
17
18
|
self.execute(path: path, options: options)[:data].each do |group|
|
18
19
|
if block_given?
|
19
20
|
yield group
|
@@ -24,37 +25,37 @@ module Samanage
|
|
24
25
|
groups
|
25
26
|
end
|
26
27
|
|
27
|
-
def create_group(payload
|
28
|
-
self.execute(path: PATHS[:group], http_method:
|
28
|
+
def create_group(payload:, options: {})
|
29
|
+
self.execute(path: PATHS[:group], http_method: "post", payload: payload)
|
29
30
|
end
|
30
31
|
|
31
|
-
def find_group_id_by_name(group:
|
32
|
-
options
|
33
|
-
|
32
|
+
def find_group_id_by_name(group: "", options: {})
|
33
|
+
options[:name] = group if group && !options.keys.include?(:name)
|
34
|
+
|
34
35
|
path = "groups.json?"
|
35
36
|
group_api = self.execute(path: path, options: options)
|
36
37
|
# Group names are case sensitive
|
37
|
-
if !group_api[:data].empty? && group == group_api[:data].first[
|
38
|
-
return group_api[:data].first[
|
38
|
+
if !group_api[:data].empty? && group == group_api[:data].first["name"]
|
39
|
+
return group_api[:data].first["id"]
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
42
|
-
def find_group(id
|
43
|
+
def find_group(id:, options: {})
|
43
44
|
path = "groups/#{id}.json"
|
44
45
|
self.execute(path: path, options: {})
|
45
46
|
end
|
46
47
|
|
47
|
-
def add_member_to_group(email
|
48
|
-
group_id
|
48
|
+
def add_member_to_group(email:, group_id: nil, group_name: nil)
|
49
|
+
group_id ||= self.find_group_id_by_name(group: group_name)
|
49
50
|
user_id = self.find_user_id_by_email(email: email)
|
50
51
|
member_path = "memberships.json?group_id=#{group_id}.json&user_ids=#{user_id}"
|
51
|
-
self.execute(path: member_path, http_method:
|
52
|
+
self.execute(path: member_path, http_method: "post")
|
52
53
|
end
|
53
|
-
|
54
|
-
def delete_group(id:
|
55
|
-
self.execute(path: "groups/#{id}.json", http_method:
|
54
|
+
|
55
|
+
def delete_group(id:)
|
56
|
+
self.execute(path: "groups/#{id}.json", http_method: "delete")
|
56
57
|
end
|
57
|
-
|
58
|
+
|
58
59
|
alias_method :groups, :collect_groups
|
59
60
|
end
|
60
|
-
end
|
61
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Samanage
|
2
4
|
class Api
|
3
|
-
|
4
5
|
# Get hardware default path
|
5
6
|
def get_hardwares(path: PATHS[:hardware], options: {})
|
6
|
-
|
7
|
-
path = 'hardwares.json?'
|
7
|
+
path = "hardwares.json?"
|
8
8
|
self.execute(path: path, options: options)
|
9
9
|
end
|
10
10
|
|
@@ -14,7 +14,7 @@ module Samanage
|
|
14
14
|
total_pages = self.get_hardwares(options: options)[:total_pages]
|
15
15
|
1.upto(total_pages) do |page|
|
16
16
|
options[:page] = page
|
17
|
-
|
17
|
+
|
18
18
|
puts "Collecting Hardwares page: #{page}/#{total_pages}" if options[:verbose]
|
19
19
|
path = "hardwares.json?"
|
20
20
|
self.execute(path: path, options: options)[:data].each do |hardware|
|
@@ -28,18 +28,18 @@ module Samanage
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# Create hardware given json payload
|
31
|
-
def create_hardware(payload
|
32
|
-
self.execute(path: PATHS[:hardware], http_method:
|
31
|
+
def create_hardware(payload:, options: {})
|
32
|
+
self.execute(path: PATHS[:hardware], http_method: "post", payload: payload)
|
33
33
|
end
|
34
34
|
|
35
35
|
# Find hardware given id
|
36
|
-
def find_hardware(id:
|
36
|
+
def find_hardware(id:)
|
37
37
|
path = "hardwares/#{id}.json"
|
38
38
|
self.execute(path: path)
|
39
39
|
end
|
40
40
|
|
41
41
|
# Find hardware given a serial number
|
42
|
-
def find_hardwares_by_serial(serial_number:
|
42
|
+
def find_hardwares_by_serial(serial_number:)
|
43
43
|
path = "hardwares.json?serial_number[]=#{serial_number}"
|
44
44
|
self.execute(path: path)
|
45
45
|
end
|
@@ -52,15 +52,15 @@ module Samanage
|
|
52
52
|
end
|
53
53
|
|
54
54
|
# Update hardware given id
|
55
|
-
def update_hardware(payload
|
55
|
+
def update_hardware(payload:, id:, options: {})
|
56
56
|
path = "hardwares/#{id}.json"
|
57
|
-
self.execute(path: path, http_method:
|
57
|
+
self.execute(path: path, http_method: "put", payload: payload)
|
58
58
|
end
|
59
59
|
|
60
|
-
def delete_hardware(id:
|
61
|
-
self.execute(path: "hardwares/#{id}.json", http_method:
|
60
|
+
def delete_hardware(id:)
|
61
|
+
self.execute(path: "hardwares/#{id}.json", http_method: "delete")
|
62
62
|
end
|
63
63
|
|
64
|
-
|
64
|
+
alias_method :hardwares, :collect_hardwares
|
65
65
|
end
|
66
|
-
end
|
66
|
+
end
|
@@ -14,23 +14,22 @@ module Samanage
|
|
14
14
|
def collect_incidents(options: {})
|
15
15
|
incidents = []
|
16
16
|
total_pages = get_incidents(options: options.except(:audit_archives, :audit_archive, :layout))[:total_pages]
|
17
|
-
|
17
|
+
message = "Requesting Incidents with Audit Archives (this may take a while)"
|
18
|
+
puts message if options[:audit_archives] && options[:verbose]
|
18
19
|
1.upto(total_pages) do |page|
|
19
20
|
puts "Collecting Incidents page: #{page}/#{total_pages}" if options[:verbose]
|
20
21
|
options[:page] = page
|
21
22
|
if options[:audit_archives]
|
22
|
-
|
23
|
-
paginated_path = 'incidents.json?'
|
23
|
+
paginated_path = "incidents.json?"
|
24
24
|
paginated_incidents = execute(path: paginated_path, options: options)[:data]
|
25
25
|
paginated_incidents.map do |incident|
|
26
|
-
params = set_params(options: options.except(:audit_archives, :audit_archive, :layout))
|
27
26
|
archive_uri = "incidents/#{incident['id']}.json?layout=long&audit_archive=true"
|
28
27
|
incident_with_archive = execute(path: archive_uri)[:data]
|
29
28
|
yield incident_with_archive if block_given?
|
30
29
|
incidents.push(incident_with_archive)
|
31
30
|
end
|
32
31
|
else
|
33
|
-
path =
|
32
|
+
path = "incidents.json?"
|
34
33
|
execute(path: path, options: options)[:data].each do |incident|
|
35
34
|
yield incident if block_given?
|
36
35
|
incidents.push(incident)
|
@@ -42,7 +41,7 @@ module Samanage
|
|
42
41
|
|
43
42
|
# Create an incident given json
|
44
43
|
def create_incident(payload: nil, options: {})
|
45
|
-
execute(path: PATHS[:incident], http_method:
|
44
|
+
execute(path: PATHS[:incident], http_method: "post", payload: payload, options: options)
|
46
45
|
end
|
47
46
|
|
48
47
|
# Find incident by ID
|
@@ -54,11 +53,11 @@ module Samanage
|
|
54
53
|
# Update an incident given id and json
|
55
54
|
def update_incident(payload:, id:, options: {})
|
56
55
|
path = "incidents/#{id}.json?"
|
57
|
-
execute(path: path, http_method:
|
56
|
+
execute(path: path, http_method: "put", payload: payload, options: options)
|
58
57
|
end
|
59
58
|
|
60
59
|
def delete_incident(id:, options: {})
|
61
|
-
execute(path: "incidents/#{id}.json", http_method:
|
60
|
+
execute(path: "incidents/#{id}.json", http_method: "delete", options: options)
|
62
61
|
end
|
63
62
|
|
64
63
|
alias incidents collect_incidents
|
data/lib/samanage/api/mobiles.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Samanage
|
2
4
|
class Api
|
3
|
-
|
4
5
|
# Get mobile default path
|
5
6
|
def get_mobiles(path: PATHS[:mobile], options: {})
|
6
|
-
|
7
|
-
path = 'mobiles.json?'
|
7
|
+
path = "mobiles.json?"
|
8
8
|
self.execute(path: path, options: options)
|
9
|
-
|
10
9
|
end
|
11
10
|
|
12
11
|
# Get all mobiles
|
@@ -15,11 +14,11 @@ module Samanage
|
|
15
14
|
total_pages = self.get_mobiles(options: options)[:total_pages]
|
16
15
|
1.upto(total_pages) do |page|
|
17
16
|
options[:page] = page
|
18
|
-
|
17
|
+
|
19
18
|
puts "Collecting Mobiles page: #{page}/#{total_pages}" if options[:verbose]
|
20
19
|
path = "mobiles.json?"
|
21
20
|
self.execute(path: path, options: options)[:data].each do |mobile|
|
22
|
-
if block_given?
|
21
|
+
if block_given?
|
23
22
|
yield mobiles
|
24
23
|
end
|
25
24
|
mobiles << mobile
|
@@ -30,15 +29,15 @@ module Samanage
|
|
30
29
|
|
31
30
|
# Create mobile given json payload
|
32
31
|
def create_mobile(payload: nil, options: {})
|
33
|
-
self.execute(path: PATHS[:mobile], http_method:
|
32
|
+
self.execute(path: PATHS[:mobile], http_method: "post", payload: payload)
|
34
33
|
end
|
35
34
|
|
36
35
|
# Find mobile given id
|
37
|
-
def find_mobile(id
|
36
|
+
def find_mobile(id:, options: {})
|
38
37
|
path = "mobiles/#{id}.json"
|
39
38
|
self.execute(path: path)
|
40
39
|
end
|
41
|
-
|
40
|
+
|
42
41
|
# Check for mobile using URL builder
|
43
42
|
def check_mobile(options: {})
|
44
43
|
url = Samanage::UrlBuilder.new(path: PATHS[:mobile], options: options).url
|
@@ -46,16 +45,16 @@ module Samanage
|
|
46
45
|
end
|
47
46
|
|
48
47
|
# Update mobile given id
|
49
|
-
def update_mobile(payload
|
48
|
+
def update_mobile(payload:, id:, options: {})
|
50
49
|
path = "mobiles/#{id}.json"
|
51
|
-
self.execute(path: path, http_method:
|
50
|
+
self.execute(path: path, http_method: "put", payload: payload)
|
52
51
|
end
|
53
52
|
|
54
|
-
def delete_mobile(id:
|
55
|
-
self.execute(path: "mobiles/#{id}.json", http_method:
|
53
|
+
def delete_mobile(id:)
|
54
|
+
self.execute(path: "mobiles/#{id}.json", http_method: "delete")
|
56
55
|
end
|
57
56
|
|
58
57
|
|
59
|
-
|
58
|
+
alias_method :mobiles, :collect_mobiles
|
60
59
|
end
|
61
|
-
end
|
60
|
+
end
|