module Rexpense::Resources::Comment
Public Instance Methods
Get resource comments
- API
-
Method:
GET /api/v1/reimbursements/:id/comments
Method:GET /api/v1/expenses/:id/comments
Method:GET /api/v1/advancements/:id/comments
Documentation: developers.rexpense.com/api/comments#index
# File lib/rexpense/resources/nested_endpoints/comment.rb, line 12 def comments(resource_id) http.get(comment_endpoint(resource_id)) do |response| Rexpense::Entities::CommentCollection.build response end end
Create resource comment
- API
-
Method:
POST /api/v1/reimbursements/:id/comments
Method:POST /api/v1/expenses/:id/comments
Method:POST /api/v1/advancements/:id/comments
Documentation: developers.rexpense.com/api/comments#create
# File lib/rexpense/resources/nested_endpoints/comment.rb, line 42 def create_comment(resource_id, params) http.post(comment_endpoint(resource_id), body: params) do |response| Rexpense::Entities::Comment.new response.parsed_body end end
Destroy resource comment
- API
-
Method:
DELETE /api/v1/reimbursements/:id/comments/:comment_id
Method:DELETE /api/v1/expenses/:id/comments/:comment_id
Method:DELETE /api/v1/advancements/:id/comments/:comment_id
Documentation: developers.rexpense.com/api/comments#destroy
# File lib/rexpense/resources/nested_endpoints/comment.rb, line 72 def destroy_comment(resource_id, comment_id) http.delete("#{comment_endpoint(resource_id)}/#{comment_id}") do |response| true end end
Get resource comment
- API
-
Method:
GET /api/v1/reimbursements/:id/comments/:comment_id
Method:GET /api/v1/expenses/:id/comments/:comment_id
Method:GET /api/v1/advancements/:id/comments/:comment_id
Documentation: developers.rexpense.com/api/comments#show
# File lib/rexpense/resources/nested_endpoints/comment.rb, line 27 def find_comment(resource_id, comment_id) http.get("#{comment_endpoint(resource_id)}/#{comment_id}") do |response| Rexpense::Entities::Comment.new response.parsed_body end end
Update resource comment
- API
-
Method:
PUT /api/v1/reimbursements/:id/comments/:comment_id
Method:PUT /api/v1/expenses/:id/comments/:comment_id
Method:PUT /api/v1/advancements/:id/comments/:comment_id
Documentation: developers.rexpense.com/api/comments#update
# File lib/rexpense/resources/nested_endpoints/comment.rb, line 57 def update_comment(resource_id, comment_id, params) http.put("#{comment_endpoint(resource_id)}/#{comment_id}", body: params) do |response| Rexpense::Entities::Comment.new response.parsed_body end end
Private Instance Methods
# File lib/rexpense/resources/nested_endpoints/comment.rb, line 80 def comment_endpoint(resource_id) "#{endpoint_base}/#{resource_id}/comments" end