Class: Zendesk2::CreateCategory
- Inherits:
-
Object
- Object
- Zendesk2::CreateCategory
show all
- Includes:
- Request
- Defined in:
- lib/zendesk2/create_category.rb
Instance Attribute Summary
Attributes included from Request
#params
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Request
#call, cistern_included, #data, #delete!, #error!, #find!, #html_url_for, included, #mock_response, #page, #page_params!, #page_params?, #pluralize, #real, #real_request, #request_body, #request_params, #request_path, #resources, #response, #timestamp, #url_for
Class Method Details
.accepted_attributes ⇒ Object
9
10
11
|
# File 'lib/zendesk2/create_category.rb', line 9
def self.accepted_attributes
%w(id name description position)
end
|
Instance Method Details
#mock ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/zendesk2/create_category.rb', line 13
def mock
identity = cistern.serial_id
record = {
'id' => identity,
'url' => url_for("/categories/#{identity}.json"),
'created_at' => timestamp,
'updated_at' => timestamp,
}.merge(Cistern::Hash.slice(params.fetch('category'), *self.class.accepted_attributes))
cistern.data[:categories][identity] = record
mock_response({ 'category' => record }, { status: 201 })
end
|