entities.rb
1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
module API
module Entities
class Image < Grape::Entity
root 'images', 'image'
expose :icon_url do |image, options|
image.public_filename(:icon)
end
expose :minor_url do |image, options|
image.public_filename(:minor)
end
expose :portrait_url do |image, options|
image.public_filename(:portrait)
end
expose :thumb_url do |image, options|
image.public_filename(:thumb)
end
end
class Profile < Grape::Entity
expose :identifier, :name, :created_at, :id
expose :image, :using => Image
end
class Person < Profile;end;
class Enterprise < Profile;end;
class Community < Profile
root 'communities', 'community'
expose :description
end
class Category < Grape::Entity
root 'categories', 'category'
expose :name, :id, :slug
expose :image, :using => Image
end
class Article < Grape::Entity
root 'articles', 'article'
expose :id, :body, :created_at
expose :title, :documentation => {:type => "String", :desc => "Title of the article"}
expose :author, :using => Profile
expose :profile, :using => Profile
expose :categories, :using => Category
end
class Comment < Grape::Entity
root 'comments', 'comment'
expose :body, :title, :created_at, :id
expose :author, :using => Profile
end
class User < Grape::Entity
root 'users', 'user'
expose :login
expose :person, :using => Profile
end
class UserLogin < User
expose :private_token
end
end
end