entities.rb 2.2 KB
Newer Older
Nihad Abbasov's avatar
Nihad Abbasov committed
1 2 3 4 5 6
module Gitlab
  module Entities
    class User < Grape::Entity
      expose :id, :email, :name, :bio, :skype, :linkedin, :twitter,
             :dark_scheme, :theme_id, :blocked, :created_at
    end
Nihad Abbasov's avatar
Nihad Abbasov committed
7

8 9 10 11
    class UserBasic < Grape::Entity
      expose :id, :email, :name, :blocked, :created_at
    end

12 13
    class UserLogin < UserBasic
      expose :private_token
14 15
    end

miks's avatar
miks committed
16 17 18 19
    class Hook < Grape::Entity
      expose :id, :url
    end

Nihad Abbasov's avatar
Nihad Abbasov committed
20 21
    class Project < Grape::Entity
      expose :id, :code, :name, :description, :path, :default_branch
22 23
      expose :owner, using: Entities::UserBasic
      expose :private_flag, as: :private
Nihad Abbasov's avatar
Nihad Abbasov committed
24 25 26
      expose :issues_enabled, :merge_requests_enabled, :wall_enabled, :wiki_enabled, :created_at
    end

27 28 29 30
    class ProjectMember < UserBasic
      expose :project_access, :as => :access_level do |user, options|
        options[:project].users_projects.find_by_user_id(user.id).project_access
      end
miks's avatar
miks committed
31 32
    end

Nihad Abbasov's avatar
Nihad Abbasov committed
33
    class RepoObject < Grape::Entity
Nihad Abbasov's avatar
Nihad Abbasov committed
34 35
      expose :name, :commit
    end
Nihad Abbasov's avatar
Nihad Abbasov committed
36

37 38 39 40
    class RepoCommit < Grape::Entity
      expose :id, :short_id, :title, :author_name, :author_email, :created_at
    end

Nihad Abbasov's avatar
Nihad Abbasov committed
41 42
    class ProjectSnippet < Grape::Entity
      expose :id, :title, :file_name
43
      expose :author, using: Entities::UserBasic
Nihad Abbasov's avatar
Nihad Abbasov committed
44 45
      expose :expires_at, :updated_at, :created_at
    end
Nihad Abbasov's avatar
Nihad Abbasov committed
46 47

    class Milestone < Grape::Entity
48 49 50
      expose :id
      expose (:project_id) {|milestone| milestone.project.id}
      expose :title, :description, :due_date, :closed, :updated_at, :created_at
Nihad Abbasov's avatar
Nihad Abbasov committed
51 52 53
    end

    class Issue < Grape::Entity
54 55 56
      expose :id
      expose (:project_id) {|issue| issue.project.id}
      expose :title, :description
57 58 59
      expose :label_list, as: :labels
      expose :milestone, using: Entities::Milestone
      expose :assignee, :author, using: Entities::UserBasic
Nihad Abbasov's avatar
Nihad Abbasov committed
60 61
      expose :closed, :updated_at, :created_at
    end
Alex Denisov's avatar
Alex Denisov committed
62

63 64
    class SSHKey < Grape::Entity
      expose :id, :title, :key
Alex Denisov's avatar
Alex Denisov committed
65
    end
66 67

    class MergeRequest < Grape::Entity
Valeriy Sizov's avatar
Valeriy Sizov committed
68
      expose :id, :target_branch, :source_branch, :project_id, :title, :closed, :merged
69 70
      expose :author, :assignee, using: Entities::UserBasic
    end
71 72 73 74 75

    class Note < Grape::Entity
      expose :author, using: Entities::UserBasic
      expose :note
    end
Nihad Abbasov's avatar
Nihad Abbasov committed
76 77
  end
end