email_addresses_controller.rb 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. class EmailAddressesController < ApplicationController
  3. before_filter :authentication_check
  4. =begin
  5. Format:
  6. JSON
  7. Example:
  8. {
  9. "id":1,
  10. "realname":"some realname",
  11. "email":"system@example.com",
  12. "updated_at":"2012-09-14T17:51:53Z",
  13. "created_at":"2012-09-14T17:51:53Z",
  14. "updated_by_id":2,
  15. "created_by_id":2,
  16. }
  17. =end
  18. =begin
  19. Resource:
  20. GET /api/v1/email_addresses.json
  21. Response:
  22. [
  23. {
  24. "id": 1,
  25. "realname":"some realname1",
  26. ...
  27. },
  28. {
  29. "id": 2,
  30. "realname":"some realname2",
  31. ...
  32. }
  33. ]
  34. Test:
  35. curl http://localhost/api/v1/email_addresses.json -v -u #{login}:#{password}
  36. =end
  37. def index
  38. model_index_render(EmailAddress, params)
  39. end
  40. =begin
  41. Resource:
  42. GET /api/v1/email_addresses/#{id}.json
  43. Response:
  44. {
  45. "id": 1,
  46. "name": "name_1",
  47. ...
  48. }
  49. Test:
  50. curl http://localhost/api/v1/email_addresses/#{id}.json -v -u #{login}:#{password}
  51. =end
  52. def show
  53. model_show_render(EmailAddress, params)
  54. end
  55. =begin
  56. Resource:
  57. POST /api/v1/email_addresses.json
  58. Payload:
  59. {
  60. "realname":"some realname",
  61. "email":"system@example.com",
  62. "note": "",
  63. "active":true,
  64. }
  65. Response:
  66. {
  67. "id": 1,
  68. "realname":"some realname",
  69. "email":"system@example.com",
  70. ...
  71. }
  72. Test:
  73. curl http://localhost/api/v1/email_addresses.json -v -u #{login}:#{password} -H "Content-Type: application/json" -X POST -d '{"name": "some_name","active": true, "note": "some note"}'
  74. =end
  75. def create
  76. return if deny_if_not_role('Admin')
  77. model_create_render(EmailAddress, params)
  78. end
  79. =begin
  80. Resource:
  81. PUT /api/v1/email_addresses/{id}.json
  82. Payload:
  83. {
  84. "realname":"some realname",
  85. "email":"system@example.com",
  86. "note": "",
  87. "active":true,
  88. }
  89. Response:
  90. {
  91. "id": 1,
  92. "realname":"some realname",
  93. "email":"system@example.com",
  94. ...
  95. }
  96. Test:
  97. curl http://localhost/api/v1/email_addresses.json -v -u #{login}:#{password} -H "Content-Type: application/json" -X PUT -d '{"name": "some_name","active": true, "note": "some note"}'
  98. =end
  99. def update
  100. return if deny_if_not_role('Admin')
  101. model_update_render(EmailAddress, params)
  102. end
  103. =begin
  104. Resource:
  105. Response:
  106. Test:
  107. =end
  108. def destroy
  109. return if deny_if_not_role('Admin')
  110. model_destory_render(EmailAddress, params)
  111. end
  112. end