Commit 15a50cf4928960f8c3b70ea49bbbcc0bb98cef6b

Authored by Victor Costa
1 parent cf2b8ce4

Fix api date format

Showing 2 changed files with 11 additions and 5 deletions   Show diff stats
lib/api/entities.rb
1 1 module API
2 2 module Entities
3 3  
  4 + Grape::Entity.format_with :timestamp do |date|
  5 + date.strftime('%Y/%m/%d %H:%M:%S') if date
  6 + end
  7 +
4 8 class Image < Grape::Entity
5 9 root 'images', 'image'
6 10  
... ... @@ -22,7 +26,8 @@ module API
22 26 end
23 27  
24 28 class Profile < Grape::Entity
25   - expose :identifier, :name, :created_at, :id
  29 + expose :identifier, :name, :id
  30 + expose :created_at, :format_with => :timestamp
26 31 expose :image, :using => Image
27 32 end
28 33  
... ... @@ -42,7 +47,8 @@ module API
42 47  
43 48 class Article < Grape::Entity
44 49 root 'articles', 'article'
45   - expose :id, :body, :created_at
  50 + expose :id, :body
  51 + expose :created_at, :format_with => :timestamp
46 52 expose :title, :documentation => {:type => "String", :desc => "Title of the article"}
47 53 expose :author, :using => Profile
48 54 expose :profile, :using => Profile
... ... @@ -51,8 +57,8 @@ module API
51 57  
52 58 class Comment < Grape::Entity
53 59 root 'comments', 'comment'
54   - expose :body, :title, :created_at, :id
55   -
  60 + expose :body, :title, :id
  61 + expose :created_at, :format_with => :timestamp
56 62 expose :author, :using => Profile
57 63 end
58 64  
... ...
lib/api/helpers.rb
... ... @@ -167,7 +167,7 @@ module API
167 167 protected
168 168  
169 169 def start_log
170   - logger.info "Started #{request.path}"
  170 + logger.info "Started #{request.path} #{request.params.except('password')}"
171 171 end
172 172 def end_log
173 173 logger.info "Completed #{request.path}"
... ...