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.



234
235
236
# File 'lib/smplkit/management/client.rb', line 234

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

Instance Method Details

#_create_context_type(ct) ⇒ Object



257
258
259
260
# File 'lib/smplkit/management/client.rb', line 257

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



262
263
264
265
# File 'lib/smplkit/management/client.rb', line 262

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



248
249
250
251
# File 'lib/smplkit/management/client.rb', line 248

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

#get(key) ⇒ Object



243
244
245
246
# File 'lib/smplkit/management/client.rb', line 243

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

#listObject



238
239
240
241
# File 'lib/smplkit/management/client.rb', line 238

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



253
254
255
# File 'lib/smplkit/management/client.rb', line 253

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