Class: Innologix::SlaGroup
- Inherits:
-
Object
- Object
- Innologix::SlaGroup
- Defined in:
- lib/innologix/sla_group.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#error ⇒ Object
Returns the value of attribute error.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#supervisor_id ⇒ Object
Returns the value of attribute supervisor_id.
-
#time_frames ⇒ Object
Returns the value of attribute time_frames.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
- #from_hash(attributes) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(h = {}) ⇒ SlaGroup
constructor
A new instance of SlaGroup.
- #list(offset = 0, limit = 10) ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(h = {}) ⇒ SlaGroup
Returns a new instance of SlaGroup.
13 14 15 16 |
# File 'lib/innologix/sla_group.rb', line 13 def initialize(h = {}) h.each { |k, v| public_send("#{k}=", v) } @client = Client.default end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
10 11 12 |
# File 'lib/innologix/sla_group.rb', line 10 def client @client end |
#created_at ⇒ Object
Returns the value of attribute created_at.
7 8 9 |
# File 'lib/innologix/sla_group.rb', line 7 def created_at @created_at end |
#error ⇒ Object
Returns the value of attribute error.
11 12 13 |
# File 'lib/innologix/sla_group.rb', line 11 def error @error end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/innologix/sla_group.rb', line 3 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/innologix/sla_group.rb', line 4 def name @name end |
#supervisor_id ⇒ Object
Returns the value of attribute supervisor_id.
5 6 7 |
# File 'lib/innologix/sla_group.rb', line 5 def supervisor_id @supervisor_id end |
#time_frames ⇒ Object
Returns the value of attribute time_frames.
6 7 8 |
# File 'lib/innologix/sla_group.rb', line 6 def time_frames @time_frames end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
8 9 10 |
# File 'lib/innologix/sla_group.rb', line 8 def updated_at @updated_at end |
Instance Method Details
#create ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/innologix/sla_group.rb', line 53 def create path = '/sla_groups' method = 'post' = { form_params: { sla_group: { name: name, supervisor_id: supervisor_id, time_frames: time_frames } } } result = client.call_api(path, method, ) if result[:error].nil? from_hash(result) else RequestError.new(result) end end |
#delete ⇒ Object
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/innologix/sla_group.rb', line 77 def delete path = '/sla_groups/' + id.to_s method = 'delete' result = client.call_api(path, method) if result[:error].nil? from_hash(result) else RequestError.new(result) end end |
#from_hash(attributes) ⇒ Object
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/innologix/sla_group.rb', line 88 def from_hash(attributes) sla_group = Innologix::SlaGroup.new sla_group.id = attributes[:id] sla_group.name = attributes[:name] sla_group.supervisor_id = attributes[:supervisor_id] sla_group.time_frames = attributes[:time_frames] sla_group.created_at = attributes[:created_at] sla_group.updated_at = attributes[:updated_at] sla_group end |
#get(id) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/innologix/sla_group.rb', line 42 def get(id) path = '/sla_groups/' + id.to_s method = 'get' result = client.call_api(path, method) if result[:error].nil? from_hash(result) else RequestError.new(result) end end |
#list(offset = 0, limit = 10) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/innologix/sla_group.rb', line 18 def list(offset = 0, limit = 10) path = '/sla_groups' method = 'get' = { query_params: { offset: offset, limit: limit } } result = client.call_api(path, method, ) if result[:error].nil? list = [] result[:sla_groups].each do |sla_group| list.push(from_hash(sla_group)) end = OpenStruct.new .offset = result[:meta][:offset] .limit = result[:meta][:limit] .total = result[:meta][:total] result = OpenStruct.new result.sla_groups = list result. = result else RequestError.new(result) end end |
#update ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/innologix/sla_group.rb', line 65 def update path = '/sla_groups/' + id.to_s method = 'put' = { form_params: { sla_group: { name: name, supervisor_id: supervisor_id, time_frames: time_frames } } } result = client.call_api(path, method, ) if result[:error].nil? from_hash(result) else RequestError.new(result) end end |