Class: YouTrack::Client::CreateProject

Inherits:
Request
  • Object
show all
Defined in:
lib/you_track/client/requests/create_project.rb

Overview

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Request

#find, #ms_time, #require_parameters

Class Method Details

.accepted_attributesObject



3
4
5
6
7
8
9
10
11
# File 'lib/you_track/client/requests/create_project.rb', line 3

def self.accepted_attributes
  # "projectId",        # string  required   Unique identifier of a project to be created. This short name will be used as prefix in issue IDs for this project.
  @_accepted_attributes ||= [
    "projectName",      # string  required   Full name of a new project. Must be unique.
    "startingNumber",   # integer required   Number to assign to the next manually created issue.
    "projectLeadLogin", # string  required   Login name of a user to be assigned as a project leader.
    "description",      # string  Optional   description of the new project.
  ]
end

Instance Method Details

#mock(params) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/you_track/client/requests/create_project.rb', line 21

def mock(params)
  identity = params.fetch("projectId")

  service.data[:projects][identity] = {
    "isImporting"    => "false",
    "lead"           => params.fetch("projectLeadLogin"), # @todo check user login
    "shortName"      => identity,
    "name"           => params.fetch("projectName"),
    "startingNumber" => params.fetch("startingNumber"),
    "sub"            => { "value" => "No subsystem" },
    "versions"       => [],
  }.merge(Cistern::Hash.slice(params, "description"))

  service.data[:project_custom_fields][identity] = service.data[:custom_fields].values.select { |v| v["autoAttached"] }

  service.response(status: 201)
end

#real(params) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/you_track/client/requests/create_project.rb', line 13

def real(params)
  service.request(
    :path   => "/admin/project/#{params.fetch("projectId")}",
    :method => :put,
    :params => Cistern::Hash.slice(params, *self.class.accepted_attributes),
  )
end