Class: Smplkit::ManagementClient::ContextTypesNamespace

Inherits:
Object
  • Object
show all
Defined in:
lib/smplkit/management/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_client) ⇒ ContextTypesNamespace

Returns a new instance of ContextTypesNamespace.



236
237
238
# File 'lib/smplkit/management/client.rb', line 236

def initialize(api_client)
  @api = SmplkitGeneratedClient::App::ContextTypesApi.new(api_client)
end

Instance Method Details

#_create_context_type(ct) ⇒ Object



259
260
261
262
# File 'lib/smplkit/management/client.rb', line 259

def _create_context_type(ct)
  response = ErrorMapping.call { @api.create_context_type(body_for(ct)) }
  from_resource(ResourceShim.from_model(response.data))
end

#_update_context_type(ct) ⇒ Object



264
265
266
267
# File 'lib/smplkit/management/client.rb', line 264

def _update_context_type(ct)
  response = ErrorMapping.call { @api.update_context_type(ct.key, body_for(ct)) }
  from_resource(ResourceShim.from_model(response.data))
end

#delete(key) ⇒ Object



250
251
252
253
# File 'lib/smplkit/management/client.rb', line 250

def delete(key)
  ErrorMapping.call { @api.delete_context_type(key) }
  true
end

#get(key) ⇒ Object



245
246
247
248
# File 'lib/smplkit/management/client.rb', line 245

def get(key)
  response = ErrorMapping.call { @api.get_context_type(key) }
  from_resource(ResourceShim.from_model(response.data))
end

#listObject



240
241
242
243
# File 'lib/smplkit/management/client.rb', line 240

def list
  response = ErrorMapping.call { @api.list_context_types }
  (response.data || []).map { |r| from_resource(ResourceShim.from_model(r)) }
end

#new_context_type(key, name: nil, description: nil) ⇒ Object



255
256
257
# File 'lib/smplkit/management/client.rb', line 255

def new_context_type(key, name: nil, description: nil)
  Management::ContextType.new(self, key: key, name: name, description: description)
end