Class: BitBucket::Issues::Milestones

Inherits:
API
  • Object
show all
Defined in:
lib/bitbucket_rest_api/issues/milestones.rb

Constant Summary collapse

VALID_MILESTONE_INPUTS =
%w[
  name
].freeze

Constants included from Validations

Validations::VALID_API_KEYS

Constants included from Validations::Token

Validations::Token::TOKEN_REQUIRED, Validations::Token::TOKEN_REQUIRED_REGEXP

Constants included from Request

Request::METHODS, Request::METHODS_WITH_BODIES

Constants included from Connection

Connection::ALLOWED_OPTIONS

Instance Method Summary collapse

Methods inherited from API

#_merge_mime_type, #_merge_user_into_params!, #_merge_user_repo_into_params!, #_update_user_repo_params, #api_methods_in, inherited, #method_missing, #process_basic_auth, #set_api_client, #setup, #update_and_validate_user_repo_params

Methods included from Normalizer

#normalize!

Methods included from ParameterFilter

#filter!

Methods included from AutoloadHelper

#autoload_all, #lookup_constant, #register_constant

Methods included from Validations::Required

#assert_required_keys, #assert_required_values_present, #parse_values

Methods included from Validations::Token

#validates_token_for

Methods included from Validations::Format

#assert_valid_values

Methods included from Validations::Presence

#_validate_presence_of, #_validate_user_repo_params

Methods included from Request

#delete_request, #get_request, #patch_request, #post_request, #put_request, #request

Methods included from Connection

caching?, clear_cache, connection, default_middleware, default_options, stack

Methods included from Authorization

#authenticated?, #authentication, #basic_authed?

Constructor Details

#initialize(options = {}) ⇒ Milestones

Creates new Issues::Milestones API



9
10
11
# File 'lib/bitbucket_rest_api/issues/milestones.rb', line 9

def initialize(options = {})
  super(options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class BitBucket::API

Instance Method Details

#create(user_name, repo_name, params = {}) ⇒ Object

Create a milestone

Inputs

<tt>:name</tt> - Required string

Examples

bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
bitbucket.issues.milestones.create :name => 'hello-world'


57
58
59
60
61
62
63
64
65
66
# File 'lib/bitbucket_rest_api/issues/milestones.rb', line 57

def create(user_name, repo_name, params = {})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?

  normalize! params
  filter! VALID_MILESTONE_INPUTS, params
  assert_required_keys(%w[name], params)

  post_request("/1.0/repositories/#{user}/#{repo.downcase}/issues/milestones", params)
end

#delete(user_name, repo_name, milestone_id, params = {}) ⇒ Object

Delete a milestone

Examples

bitbucket = BitBucket.new
bitbucket.issues.milestones.delete 'user-name', 'repo-name', 'milestone-id'


96
97
98
99
100
101
102
103
# File 'lib/bitbucket_rest_api/issues/milestones.rb', line 96

def delete(user_name, repo_name, milestone_id, params = {})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of milestone_id
  normalize! params

  delete_request("/1.0/repositories/#{user}/#{repo.downcase}/issues/milestones/#{milestone_id}", params)
end

#get(user_name, repo_name, milestone_id, params = {}) ⇒ Object Also known as: find

Get a single milestone

Examples

bitbucket = BitBucket.new
bitbucket.issues.milestones.get 'user-name', 'repo-name', 'milestone-id'


38
39
40
41
42
43
44
45
# File 'lib/bitbucket_rest_api/issues/milestones.rb', line 38

def get(user_name, repo_name, milestone_id, params = {})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of milestone_id
  normalize! params

  get_request("/1.0/repositories/#{user}/#{repo.downcase}/issues/milestones/#{milestone_id}", params)
end

#list(user_name, repo_name, params = {}) ⇒ Object Also known as: all

List milestones for a repository

Examples

bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
bitbucket.issues.milestones.list


19
20
21
22
23
24
25
26
27
28
29
# File 'lib/bitbucket_rest_api/issues/milestones.rb', line 19

def list(user_name, repo_name, params = {})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?

  normalize! params

  response = get_request("/1.0/repositories/#{user}/#{repo.downcase}/issues/milestones", params)
  return response unless block_given?

  response.each { |el| yield el }
end

#update(user_name, repo_name, milestone_id, params = {}) ⇒ Object

Update a milestone

Inputs

<tt>:name</tt> - Required string

Examples

bitbucket = BitBucket.new
bitbucket.issues.milestones.update 'user-name', 'repo-name', 'milestone-id',
  :name => 'hello-world'


78
79
80
81
82
83
84
85
86
87
88
# File 'lib/bitbucket_rest_api/issues/milestones.rb', line 78

def update(user_name, repo_name, milestone_id, params = {})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of milestone_id

  normalize! params
  filter! VALID_MILESTONE_INPUTS, params
  assert_required_keys(%w[name], params)

  put_request("/1.0/repositories/#{user}/#{repo.downcase}/issues/milestones/#{milestone_id}", params)
end