postmaster_filters_controller.rb 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. class PostmasterFiltersController < ApplicationController
  3. before_action { authentication_check(permission: 'admin.channel_email') }
  4. =begin
  5. Format:
  6. JSON
  7. Example:
  8. {
  9. "id":1,
  10. "name":"some name",
  11. "type":"email",
  12. "match":{
  13. "From":"some@example.com"
  14. },
  15. "perform":{
  16. "x-zammad-ticket-priority":"3 high"
  17. },
  18. "note":"",
  19. "active":true,
  20. "updated_at":"2012-09-14T17:51:53Z",
  21. "created_at":"2012-09-14T17:51:53Z",
  22. "updated_by_id":2,
  23. "created_by_id":2,
  24. }
  25. =end
  26. =begin
  27. Resource:
  28. GET /api/v1/postmaster_filters.json
  29. Response:
  30. [
  31. {
  32. "id": 1,
  33. "name":"some name",
  34. ...
  35. },
  36. {
  37. "id": 2,
  38. "name":"some name",
  39. ...
  40. }
  41. ]
  42. Test:
  43. curl http://localhost/api/v1/postmaster_filters.json -v -u #{login}:#{password}
  44. =end
  45. def index
  46. model_index_render(PostmasterFilter, params)
  47. end
  48. =begin
  49. Resource:
  50. GET /api/v1/postmaster_filters/#{id}.json
  51. Response:
  52. {
  53. "id": 1,
  54. "name": "name_1",
  55. ...
  56. }
  57. Test:
  58. curl http://localhost/api/v1/postmaster_filters/#{id}.json -v -u #{login}:#{password}
  59. =end
  60. def show
  61. model_show_render(PostmasterFilter, params)
  62. end
  63. =begin
  64. Resource:
  65. POST /api/v1/postmaster_filters.json
  66. Payload:
  67. {
  68. "name":"some name",
  69. "type":"email",
  70. "match":{
  71. "From":"some@example.com"
  72. },
  73. "perform":{
  74. "x-zammad-ticket-priority":"3 high"
  75. },
  76. "note":"",
  77. "active":true,
  78. }
  79. Response:
  80. {
  81. "id": 1,
  82. "name":"some name",
  83. "type":"email",
  84. "match":{
  85. "From":"some@example.com"
  86. },
  87. "perform":{
  88. "x-zammad-ticket-priority":"3 high"
  89. },
  90. "note": "",
  91. "active":true,
  92. ...
  93. }
  94. Test:
  95. curl http://localhost/api/v1/postmaster_filters.json -v -u #{login}:#{password} -H "Content-Type: application/json" -X POST -d '{"name": "some_name","active": true, "note": "some note"}'
  96. =end
  97. def create
  98. model_create_render(PostmasterFilter, params)
  99. end
  100. =begin
  101. Resource:
  102. PUT /api/v1/postmaster_filters/{id}.json
  103. Payload:
  104. {
  105. "name":"some name",
  106. "match":{
  107. "From":"some@example.com"
  108. },
  109. "perform":{
  110. "x-zammad-ticket-priority":"3 high"
  111. },
  112. "note":"",
  113. "active":true,
  114. }
  115. Response:
  116. {
  117. "id": 1,
  118. "name":"some name",
  119. "match":{
  120. "From":"some@example.com"
  121. },
  122. "perform":{
  123. "x-zammad-ticket-priority":"3 high"
  124. },
  125. "note":"",
  126. "active":true,
  127. ...
  128. }
  129. Test:
  130. curl http://localhost/api/v1/postmaster_filters.json -v -u #{login}:#{password} -H "Content-Type: application/json" -X PUT -d '{"name": "some_name","active": true, "note": "some note"}'
  131. =end
  132. def update
  133. model_update_render(PostmasterFilter, params)
  134. end
  135. =begin
  136. Resource:
  137. Response:
  138. Test:
  139. =end
  140. def destroy
  141. model_destory_render(PostmasterFilter, params)
  142. end
  143. end