Class: Smplkit::Platform::ContextTypesClient
- Inherits:
-
Object
- Object
- Smplkit::Platform::ContextTypesClient
- Defined in:
- lib/smplkit/platform/client.rb
Overview
Sync context-type CRUD (client.platform.context_types).
Instance Method Summary collapse
- #_create(ct) ⇒ Object
- #_update(ct) ⇒ Object
- #delete(id) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(app_http) ⇒ ContextTypesClient
constructor
A new instance of ContextTypesClient.
- #list(page_number: nil, page_size: nil) ⇒ Object
- #new(id, name: nil, attributes: nil) ⇒ Object
Constructor Details
#initialize(app_http) ⇒ ContextTypesClient
Returns a new instance of ContextTypesClient.
219 220 221 |
# File 'lib/smplkit/platform/client.rb', line 219 def initialize(app_http) @api = SmplkitGeneratedClient::App::ContextTypesApi.new(app_http) end |
Instance Method Details
#_create(ct) ⇒ Object
245 246 247 248 |
# File 'lib/smplkit/platform/client.rb', line 245 def _create(ct) response = ApiSupport::ErrorMapping.call { @api.create_context_type(body_for(ct)) } from_resource(ApiSupport::ResourceShim.from_model(response.data)) end |
#_update(ct) ⇒ Object
250 251 252 253 254 255 |
# File 'lib/smplkit/platform/client.rb', line 250 def _update(ct) raise "cannot update a ContextType with no id" if ct.id.nil? response = ApiSupport::ErrorMapping.call { @api.update_context_type(ct.id, body_for(ct)) } from_resource(ApiSupport::ResourceShim.from_model(response.data)) end |
#delete(id) ⇒ Object
240 241 242 243 |
# File 'lib/smplkit/platform/client.rb', line 240 def delete(id) ApiSupport::ErrorMapping.call { @api.delete_context_type(id) } nil end |
#get(id) ⇒ Object
235 236 237 238 |
# File 'lib/smplkit/platform/client.rb', line 235 def get(id) response = ApiSupport::ErrorMapping.call { @api.get_context_type(id) } from_resource(ApiSupport::ResourceShim.from_model(response.data)) end |
#list(page_number: nil, page_size: nil) ⇒ Object
227 228 229 230 231 232 233 |
# File 'lib/smplkit/platform/client.rb', line 227 def list(page_number: nil, page_size: nil) opts = {} opts[:page_number] = page_number unless page_number.nil? opts[:page_size] = page_size unless page_size.nil? response = ApiSupport::ErrorMapping.call { @api.list_context_types(opts) } (response.data || []).map { |r| from_resource(ApiSupport::ResourceShim.from_model(r)) } end |
#new(id, name: nil, attributes: nil) ⇒ Object
223 224 225 |
# File 'lib/smplkit/platform/client.rb', line 223 def new(id, name: nil, attributes: nil) ContextType.new(self, id: id, name: name || id, attributes: attributes || {}) end |