Module: Backlog::API

Included in:
Client
Defined in:
lib/backlog/api.rb

Defined Under Namespace

Classes: ArgumentError

Instance Method Summary collapse

Instance Method Details

#conv_str_to_int(x) ⇒ Object

String(Integer) -> Integer String(String) -> String Integer -> Integer



124
125
126
127
128
129
130
# File 'lib/backlog/api.rb', line 124

def conv_str_to_int(x)
  if x.instance_of? String
    (x.to_i.zero? && x != "0") ? x : x.to_i
  else
    x
  end
end

#count_issue(condition) ⇒ Object

Hash -> Integer



115
116
117
118
119
# File 'lib/backlog/api.rb', line 115

def count_issue(condition)
  raise Backlog::API::ArgumentError, "must specify 'projectId'" unless condition.has_key? "projectId"
  condition = Backlog::Object::FindCondition.new(condition)
  self.call("backlog.countIssue", condition.to_h)
end

#get_activity_typesObject



77
78
79
80
81
# File 'lib/backlog/api.rb', line 77

def get_activity_types
  self.call("backlog.getActivityTypes").map {|activity_type|
    Backlog::Object::ActivityType.new(activity_type)
  }
end

#get_comments(issue_id) ⇒ Object



65
66
67
68
69
# File 'lib/backlog/api.rb', line 65

def get_comments(issue_id)
  self.call("backlog.getComments", issue_id).map {|comment|
    Backlog::Object::Comment.new(comment)
  }
end

#get_components(project_id) ⇒ Object



20
21
22
23
24
# File 'lib/backlog/api.rb', line 20

def get_components(project_id)
  self.call("backlog.getComponents", project_id).map {|component|
    Backlog::Object::Component.new(component)
  }
end

#get_custom_fields(project_id, issue_type = nil) ⇒ Object

Integer -> (String|Integer) -> Backlog::Object::CustomFields



102
103
104
105
106
107
108
109
110
111
112
# File 'lib/backlog/api.rb', line 102

def get_custom_fields(project_id, issue_type=nil)
  h = {"project_id" => project_id}
  if issue_type.instance_of? String
    h["issue_type"] = issue_type
  elsif issue_type.instance_of? Integer
    h["issue_type_id"] = isuissue_type
  end
  self.call("backlog.getCustomFields", h).map {|custom_field|
    Backlog::Object::CustomField.new(custom_field)
  }
end

#get_issue(issue_key) ⇒ Object

String | Integer -> Backlog::Object::Issue



59
60
61
62
63
# File 'lib/backlog/api.rb', line 59

def get_issue(issue_key)
  Backlog::Object::Issue.new(
    self.call("backlog.getIssue", conv_str_to_int(issue_key))
  )
end

#get_issue_types(project_id) ⇒ Object



52
53
54
55
56
# File 'lib/backlog/api.rb', line 52

def get_issue_types(project_id)
  self.call("backlog.getIssueTypes", project_id).map {|issue_type|
    Backlog::Object::IssueType.new(issue_type)
  }
end

#get_prioritiesObject



95
96
97
98
99
# File 'lib/backlog/api.rb', line 95

def get_priorities
  self.call("backlog.getPriorities").map {|priority|
    Backlog::Object::Priority.new(priority)
  }
end

#get_project(project_key) ⇒ Object

String | Integer -> Backlog::Object::Project



14
15
16
17
18
# File 'lib/backlog/api.rb', line 14

def get_project(project_key)
  Backlog::Object::Project.new(
    self.call("backlog.getProject", conv_str_to_int(project_key))
  )
end

#get_projectsObject



7
8
9
10
11
# File 'lib/backlog/api.rb', line 7

def get_projects
  self.call("backlog.getProjects").map {|project|
    Backlog::Object::Project.new(project)
  }
end

#get_resolutionsObject



89
90
91
92
93
# File 'lib/backlog/api.rb', line 89

def get_resolutions
  self.call("backlog.getResolutions").map {|resolution|
    Backlog::Object::Resolution.new(resolution)
  }
end

#get_statusesObject



83
84
85
86
87
# File 'lib/backlog/api.rb', line 83

def get_statuses
  self.call("backlog.getStatuses").map {|status|
    Backlog::Object::Status.new(status)
  }
end

#get_timelineObject



71
72
73
74
75
# File 'lib/backlog/api.rb', line 71

def get_timeline
  self.call("backlog.getTimeline").map {|timeline|
    Backlog::Object::Timeline.new(timeline)
  }
end

#get_user(user_key) ⇒ Object

String | Integer -> Backlog::Object::DetailUser



39
40
41
42
43
# File 'lib/backlog/api.rb', line 39

def get_user(user_key)
  Backlog::Object::DetailUser.new(
    self.call("backlog.getUser", conv_str_to_int(user_key))
  )
end

#get_user_icon(user_key) ⇒ Object

String | Integer -> Backlog::Object::UserIcon



46
47
48
49
50
# File 'lib/backlog/api.rb', line 46

def get_user_icon(user_key)
  Backlog::Object::UserIcon.new(
    self.call("backlog.getUserIcon", conv_str_to_int(user_key))
  )
end

#get_users(project_id) ⇒ Object



32
33
34
35
36
# File 'lib/backlog/api.rb', line 32

def get_users(project_id)
  self.call("backlog.getUsers", project_id).map {|user|
    Backlog::Object::User.new(user)
  }
end

#get_versions(project_id) ⇒ Object



26
27
28
29
30
# File 'lib/backlog/api.rb', line 26

def get_versions(project_id)
  self.call("backlog.getVersions", project_id).map {|version|
    Backlog::Object::Version.new(version)
  }
end