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.



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

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

Instance Method Details

#_create_context_type(ct) ⇒ Object



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

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



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

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



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

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

#get(key) ⇒ Object



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

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

#listObject



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

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



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

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