reenhanced_bitbucket_api 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +43 -0
- data/README.md +169 -0
- data/Rakefile +3 -0
- data/lib/bitbucket_rest_api/api/actions.rb +50 -0
- data/lib/bitbucket_rest_api/api.rb +120 -0
- data/lib/bitbucket_rest_api/api_factory.rb +30 -0
- data/lib/bitbucket_rest_api/authorization.rb +34 -0
- data/lib/bitbucket_rest_api/client.rb +58 -0
- data/lib/bitbucket_rest_api/compatibility.rb +23 -0
- data/lib/bitbucket_rest_api/configuration.rb +101 -0
- data/lib/bitbucket_rest_api/connection.rb +96 -0
- data/lib/bitbucket_rest_api/constants.rb +58 -0
- data/lib/bitbucket_rest_api/core_ext/array.rb +17 -0
- data/lib/bitbucket_rest_api/core_ext/hash.rb +56 -0
- data/lib/bitbucket_rest_api/core_ext/ordered_hash.rb +107 -0
- data/lib/bitbucket_rest_api/deprecation.rb +39 -0
- data/lib/bitbucket_rest_api/error/bad_request.rb +12 -0
- data/lib/bitbucket_rest_api/error/client_error.rb +20 -0
- data/lib/bitbucket_rest_api/error/forbidden.rb +12 -0
- data/lib/bitbucket_rest_api/error/internal_server_error.rb +12 -0
- data/lib/bitbucket_rest_api/error/invalid_options.rb +18 -0
- data/lib/bitbucket_rest_api/error/not_found.rb +12 -0
- data/lib/bitbucket_rest_api/error/required_params.rb +18 -0
- data/lib/bitbucket_rest_api/error/service_error.rb +19 -0
- data/lib/bitbucket_rest_api/error/service_unavailable.rb +12 -0
- data/lib/bitbucket_rest_api/error/unauthorized.rb +12 -0
- data/lib/bitbucket_rest_api/error/unknown_value.rb +18 -0
- data/lib/bitbucket_rest_api/error/unprocessable_entity.rb +12 -0
- data/lib/bitbucket_rest_api/error/validations.rb +18 -0
- data/lib/bitbucket_rest_api/error.rb +35 -0
- data/lib/bitbucket_rest_api/invitations.rb +15 -0
- data/lib/bitbucket_rest_api/issues/comments.rb +118 -0
- data/lib/bitbucket_rest_api/issues/components.rb +106 -0
- data/lib/bitbucket_rest_api/issues/milestones.rb +107 -0
- data/lib/bitbucket_rest_api/issues.rb +230 -0
- data/lib/bitbucket_rest_api/normalizer.rb +27 -0
- data/lib/bitbucket_rest_api/parameter_filter.rb +32 -0
- data/lib/bitbucket_rest_api/repos/changesets.rb +54 -0
- data/lib/bitbucket_rest_api/repos/following.rb +39 -0
- data/lib/bitbucket_rest_api/repos/keys.rb +87 -0
- data/lib/bitbucket_rest_api/repos/services.rb +103 -0
- data/lib/bitbucket_rest_api/repos/sources.rb +31 -0
- data/lib/bitbucket_rest_api/repos.rb +238 -0
- data/lib/bitbucket_rest_api/request/basic_auth.rb +31 -0
- data/lib/bitbucket_rest_api/request/jsonize.rb +46 -0
- data/lib/bitbucket_rest_api/request/oauth.rb +51 -0
- data/lib/bitbucket_rest_api/request.rb +67 -0
- data/lib/bitbucket_rest_api/response/helpers.rb +21 -0
- data/lib/bitbucket_rest_api/response/jsonize.rb +30 -0
- data/lib/bitbucket_rest_api/response/mashify.rb +24 -0
- data/lib/bitbucket_rest_api/response/raise_error.rb +31 -0
- data/lib/bitbucket_rest_api/response/xmlize.rb +26 -0
- data/lib/bitbucket_rest_api/response.rb +28 -0
- data/lib/bitbucket_rest_api/result.rb +140 -0
- data/lib/bitbucket_rest_api/user.rb +101 -0
- data/lib/bitbucket_rest_api/users/account.rb +53 -0
- data/lib/bitbucket_rest_api/users.rb +24 -0
- data/lib/bitbucket_rest_api/utils/url.rb +56 -0
- data/lib/bitbucket_rest_api/validations/format.rb +24 -0
- data/lib/bitbucket_rest_api/validations/presence.rb +25 -0
- data/lib/bitbucket_rest_api/validations/required.rb +24 -0
- data/lib/bitbucket_rest_api/validations/token.rb +43 -0
- data/lib/bitbucket_rest_api/validations.rb +25 -0
- data/lib/bitbucket_rest_api/version.rb +11 -0
- data/lib/bitbucket_rest_api.rb +91 -0
- metadata +338 -0
@@ -0,0 +1,96 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
require 'faraday_middleware'
|
5
|
+
require 'bitbucket_rest_api/response'
|
6
|
+
require 'bitbucket_rest_api/response/mashify'
|
7
|
+
require 'bitbucket_rest_api/response/jsonize'
|
8
|
+
require 'bitbucket_rest_api/response/helpers'
|
9
|
+
require 'bitbucket_rest_api/response/raise_error'
|
10
|
+
require 'bitbucket_rest_api/request/oauth'
|
11
|
+
require 'bitbucket_rest_api/request/basic_auth'
|
12
|
+
require 'bitbucket_rest_api/request/jsonize'
|
13
|
+
|
14
|
+
module BitBucket
|
15
|
+
module Connection
|
16
|
+
extend self
|
17
|
+
include BitBucket::Constants
|
18
|
+
|
19
|
+
ALLOWED_OPTIONS = [
|
20
|
+
:headers,
|
21
|
+
:url,
|
22
|
+
:params,
|
23
|
+
:request,
|
24
|
+
:ssl
|
25
|
+
].freeze
|
26
|
+
|
27
|
+
def default_options(options={})
|
28
|
+
{
|
29
|
+
:headers => {
|
30
|
+
USER_AGENT => user_agent
|
31
|
+
},
|
32
|
+
:ssl => { :verify => false },
|
33
|
+
:url => options.fetch(:endpoint) { BitBucket.endpoint }
|
34
|
+
}.merge(options)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Default middleware stack that uses default adapter as specified at
|
38
|
+
# configuration stage.
|
39
|
+
#
|
40
|
+
def default_middleware(options={})
|
41
|
+
Proc.new do |builder|
|
42
|
+
#builder.use BitBucket::Request::Jsonize
|
43
|
+
builder.use Faraday::Request::Multipart
|
44
|
+
builder.use Faraday::Request::UrlEncoded
|
45
|
+
builder.use FaradayMiddleware::OAuth, {:consumer_key => client_id, :consumer_secret => client_secret, :token => oauth_token, :token_secret => oauth_secret} if client_id? and client_secret?
|
46
|
+
builder.use BitBucket::Request::BasicAuth, authentication if basic_authed?
|
47
|
+
builder.use FaradayMiddleware::EncodeJson
|
48
|
+
|
49
|
+
builder.use Faraday::Response::Logger if ENV['DEBUG']
|
50
|
+
builder.use BitBucket::Response::Helpers
|
51
|
+
unless options[:raw]
|
52
|
+
builder.use BitBucket::Response::Mashify
|
53
|
+
builder.use BitBucket::Response::Jsonize
|
54
|
+
end
|
55
|
+
builder.use BitBucket::Response::RaiseError
|
56
|
+
builder.adapter adapter
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
@connection = nil
|
61
|
+
|
62
|
+
@stack = nil
|
63
|
+
|
64
|
+
def clear_cache
|
65
|
+
@connection = nil
|
66
|
+
end
|
67
|
+
|
68
|
+
def caching?
|
69
|
+
!@connection.nil?
|
70
|
+
end
|
71
|
+
|
72
|
+
# Exposes middleware builder to facilitate custom stacks and easy
|
73
|
+
# addition of new extensions such as cache adapter.
|
74
|
+
#
|
75
|
+
def stack(options={}, &block)
|
76
|
+
@stack ||= begin
|
77
|
+
if block_given?
|
78
|
+
Faraday::RackBuilder.new(&block)
|
79
|
+
else
|
80
|
+
Faraday::RackBuilder.new(&default_middleware(options))
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Returns a Fraday::Connection object
|
86
|
+
#
|
87
|
+
def connection(options = {})
|
88
|
+
conn_options = default_options(options)
|
89
|
+
clear_cache unless options.empty?
|
90
|
+
puts "OPTIONS:#{conn_options.inspect}" if ENV['DEBUG']
|
91
|
+
|
92
|
+
@connection ||= Faraday.new(conn_options.merge(:builder => stack(options)))
|
93
|
+
end
|
94
|
+
|
95
|
+
end # Connection
|
96
|
+
end # BitBucket
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module BitBucket
|
2
|
+
module Constants
|
3
|
+
extend self
|
4
|
+
|
5
|
+
# Response headers
|
6
|
+
RATELIMIT_REMAINING = 'X-RateLimit-Remaining'.freeze
|
7
|
+
|
8
|
+
RATELIMIT_LIMIT = 'X-RateLimit-Limit'.freeze
|
9
|
+
|
10
|
+
CONTENT_TYPE = 'Content-Type'.freeze
|
11
|
+
|
12
|
+
CONTENT_LENGTH = 'content-length'.freeze
|
13
|
+
|
14
|
+
CACHE_CONTROL = 'cache-control'.freeze
|
15
|
+
|
16
|
+
ETAG = 'ETag'.freeze
|
17
|
+
|
18
|
+
SERVER = 'Server'.freeze
|
19
|
+
|
20
|
+
DATE = 'Date'.freeze
|
21
|
+
|
22
|
+
LOCATION = 'Location'.freeze
|
23
|
+
|
24
|
+
USER_AGENT = 'User-Agent'.freeze
|
25
|
+
|
26
|
+
ACCEPT = 'Accept'.freeze
|
27
|
+
|
28
|
+
ACCEPT_CHARSET = 'Accept-Charset'.freeze
|
29
|
+
|
30
|
+
# Link headers
|
31
|
+
HEADER_LINK = "Link".freeze
|
32
|
+
|
33
|
+
HEADER_NEXT = "X-Next".freeze
|
34
|
+
|
35
|
+
HEADER_LAST = "X-Last".freeze
|
36
|
+
|
37
|
+
META_REL = "rel".freeze
|
38
|
+
|
39
|
+
META_LAST = "last".freeze
|
40
|
+
|
41
|
+
META_NEXT = "next".freeze
|
42
|
+
|
43
|
+
META_FIRST = "first".freeze
|
44
|
+
|
45
|
+
META_PREV = "prev".freeze
|
46
|
+
|
47
|
+
PARAM_PAGE = "page".freeze
|
48
|
+
|
49
|
+
PARAM_PER_PAGE = "per_page".freeze
|
50
|
+
|
51
|
+
PARAM_START_PAGE = "start_page".freeze
|
52
|
+
|
53
|
+
# URI parsing
|
54
|
+
QUERY_STR_SEP = '?'.freeze
|
55
|
+
|
56
|
+
|
57
|
+
end # Constants
|
58
|
+
end # BitBucket
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Array # :nodoc:
|
2
|
+
|
3
|
+
def except(*keys) # :nodoc:
|
4
|
+
self.dup.except!(*keys)
|
5
|
+
end unless method_defined?(:except)
|
6
|
+
|
7
|
+
def except!(*items) # :nodoc:
|
8
|
+
copy = self.dup
|
9
|
+
copy.reject! { |item| items.include? item }
|
10
|
+
copy
|
11
|
+
end unless method_defined?(:except!)
|
12
|
+
|
13
|
+
def extract_options!
|
14
|
+
last.is_a?(::Hash) ? pop : {}
|
15
|
+
end
|
16
|
+
|
17
|
+
end # Array
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class Hash # :nodoc:
|
2
|
+
|
3
|
+
def except(*items) # :nodoc:
|
4
|
+
self.dup.except!(*items)
|
5
|
+
end unless method_defined?(:except)
|
6
|
+
|
7
|
+
def except!(*keys) # :nodoc:
|
8
|
+
copy = self.dup
|
9
|
+
keys.each { |key| copy.delete!(key) }
|
10
|
+
copy
|
11
|
+
end unless method_defined?(:except!)
|
12
|
+
|
13
|
+
def symbolize_keys # :nodoc:
|
14
|
+
inject({}) do |hash, (key, value)|
|
15
|
+
hash[(key.to_sym rescue key) || key] = value
|
16
|
+
hash
|
17
|
+
end
|
18
|
+
end unless method_defined?(:symbolize_keys)
|
19
|
+
|
20
|
+
def symbolize_keys! # :nodoc:
|
21
|
+
hash = symbolize_keys
|
22
|
+
hash.each do |key, val|
|
23
|
+
hash[key] = case val
|
24
|
+
when Hash
|
25
|
+
val.symbolize_keys!
|
26
|
+
when Array
|
27
|
+
val.map do |item|
|
28
|
+
item.is_a?(Hash) ? item.symbolize_keys! : item
|
29
|
+
end
|
30
|
+
else
|
31
|
+
val
|
32
|
+
end
|
33
|
+
end
|
34
|
+
return hash
|
35
|
+
end unless method_defined?(:symbolize_keys!)
|
36
|
+
|
37
|
+
def serialize # :nodoc:
|
38
|
+
self.map { |key, val| [key, val].join("=") }.join("&")
|
39
|
+
end unless method_defined?(:serialize)
|
40
|
+
|
41
|
+
def all_keys # :nodoc:
|
42
|
+
keys = self.keys
|
43
|
+
keys.each do |key|
|
44
|
+
if self[key].is_a?(Hash)
|
45
|
+
keys << self[key].all_keys.compact.flatten
|
46
|
+
next
|
47
|
+
end
|
48
|
+
end
|
49
|
+
keys.flatten
|
50
|
+
end unless method_defined?(:all_keys)
|
51
|
+
|
52
|
+
def has_deep_key?(key)
|
53
|
+
self.all_keys.include? key
|
54
|
+
end unless method_defined?(:has_deep_key?)
|
55
|
+
|
56
|
+
end # Hash
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket
|
4
|
+
module CoreExt #:nodoc:
|
5
|
+
|
6
|
+
if RUBY_VERSION >= '1.9'
|
7
|
+
class OrderedHash < ::Hash; end
|
8
|
+
else
|
9
|
+
class OrderedHash < ::Hash
|
10
|
+
attr_accessor :order
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def [](*args)
|
14
|
+
hsh = OrderedHash.new
|
15
|
+
if Hash == args[0]
|
16
|
+
hsh.replace args[0]
|
17
|
+
elsif (args.size % 2) != 0
|
18
|
+
pp args
|
19
|
+
raise ArgumentError, "odd number of elements for Hash"
|
20
|
+
else
|
21
|
+
0.step(args.size - 1, 2) do |a|
|
22
|
+
b = a + 1
|
23
|
+
hsh[args[a]] = args[b]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
hsh
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(*args, &block)
|
31
|
+
super
|
32
|
+
@order = []
|
33
|
+
end
|
34
|
+
|
35
|
+
def []=(key, value)
|
36
|
+
@order.push key unless member?(key)
|
37
|
+
super key, value
|
38
|
+
end
|
39
|
+
|
40
|
+
def ==(hsh2)
|
41
|
+
return false if @order != hsh2.order
|
42
|
+
super hsh2
|
43
|
+
end
|
44
|
+
|
45
|
+
def clear
|
46
|
+
@order = []
|
47
|
+
super
|
48
|
+
end
|
49
|
+
|
50
|
+
def delete(key)
|
51
|
+
@order.delete key
|
52
|
+
super
|
53
|
+
end
|
54
|
+
|
55
|
+
def each_key
|
56
|
+
@order.each { |k| yield k }
|
57
|
+
self
|
58
|
+
end
|
59
|
+
|
60
|
+
def each_value
|
61
|
+
@order.each { |k| yield self[k] }
|
62
|
+
self
|
63
|
+
end
|
64
|
+
|
65
|
+
def each
|
66
|
+
@order.each { |k| yield k, self[k] }
|
67
|
+
self
|
68
|
+
end
|
69
|
+
alias :each_pair :each
|
70
|
+
|
71
|
+
def delete_if
|
72
|
+
@order.clone.each { |k| delete k if yield }
|
73
|
+
self
|
74
|
+
end
|
75
|
+
|
76
|
+
def values
|
77
|
+
ary = []
|
78
|
+
@order.each { |k| ary.push self[k] }
|
79
|
+
ary
|
80
|
+
end
|
81
|
+
|
82
|
+
def keys
|
83
|
+
@order
|
84
|
+
end
|
85
|
+
|
86
|
+
def replace(hsh2)
|
87
|
+
@order = hsh2.keys
|
88
|
+
super hsh2
|
89
|
+
end
|
90
|
+
|
91
|
+
def shift
|
92
|
+
key = @order.first
|
93
|
+
key ? [key, delete(key)] : super
|
94
|
+
end
|
95
|
+
|
96
|
+
def class
|
97
|
+
Hash
|
98
|
+
end
|
99
|
+
|
100
|
+
def __class__
|
101
|
+
OrderedHash
|
102
|
+
end
|
103
|
+
end # OrderedHash
|
104
|
+
end
|
105
|
+
|
106
|
+
end # CoreExt
|
107
|
+
end # BitBucket
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket
|
4
|
+
|
5
|
+
DEPRECATION_PREFIX = "[BitBucketAPI] Deprecation warning:"
|
6
|
+
|
7
|
+
class << self
|
8
|
+
|
9
|
+
attr_writer :deprecation_tracker
|
10
|
+
|
11
|
+
def deprecation_tracker
|
12
|
+
@deprecation_tracker ||= []
|
13
|
+
end
|
14
|
+
|
15
|
+
# Displays deprecation message to the user.
|
16
|
+
# Each message is printed once.
|
17
|
+
def deprecate(method, alternate_method=nil)
|
18
|
+
return if deprecation_tracker.include? method
|
19
|
+
deprecation_tracker << method
|
20
|
+
|
21
|
+
message = <<-NOTICE
|
22
|
+
#{DEPRECATION_PREFIX}
|
23
|
+
|
24
|
+
* #{method} is deprecated.
|
25
|
+
NOTICE
|
26
|
+
if alternate_method
|
27
|
+
message << <<-ADDITIONAL
|
28
|
+
* please use #{alternate_method} instead.
|
29
|
+
ADDITIONAL
|
30
|
+
end
|
31
|
+
warn_deprecation(message)
|
32
|
+
end
|
33
|
+
|
34
|
+
def warn_deprecation(message)
|
35
|
+
send :warn, message
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end # BitBucket
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket #:nodoc
|
4
|
+
# Raised when BitBucket returns the HTTP status code 404
|
5
|
+
module Error
|
6
|
+
class ClientError < BitBucketError
|
7
|
+
attr_reader :problem, :summary, :resolution
|
8
|
+
|
9
|
+
def initialize(message)
|
10
|
+
super(message)
|
11
|
+
end
|
12
|
+
|
13
|
+
def generate_message(attributes)
|
14
|
+
"\nProblem:\n #{attributes[:problem]}"+
|
15
|
+
"\nSummary:\n #{attributes[:summary]}"+
|
16
|
+
"\nResolution:\n #{attributes[:resolution]}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end # Error
|
20
|
+
end # BitBucket
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket #:nodoc
|
4
|
+
# Raised when invalid options are passed to a request body
|
5
|
+
module Error
|
6
|
+
class InvalidOptions < ClientError
|
7
|
+
def initialize(invalid, valid)
|
8
|
+
super(
|
9
|
+
generate_message(
|
10
|
+
:problem => "Invalid option #{invalid.keys.join(', ')} provided for this request.",
|
11
|
+
:summary => "BitBucket gem checks the request parameters passed to ensure that github api is not hit unnecessairly and to fail fast.",
|
12
|
+
:resolution => "Valid options are: #{valid.join(', ')}, make sure these are the ones you are using"
|
13
|
+
)
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end # Error
|
18
|
+
end # BitBucket
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket #:nodoc
|
4
|
+
# Raised when invalid options are passed to a request body
|
5
|
+
module Error
|
6
|
+
class RequiredParams < ClientError
|
7
|
+
def initialize(provided, required)
|
8
|
+
super(
|
9
|
+
generate_message(
|
10
|
+
:problem => "Missing required parameters: #{provided.keys.join(', ')} provided for this request.",
|
11
|
+
:summary => "BitBucket gem checks the request parameters passed to ensure that github api is not hit unnecessairly and to fail fast.",
|
12
|
+
:resolution => "Required parameters are: #{required.join(', ')}, make sure these are the ones you are using"
|
13
|
+
)
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end # Error
|
18
|
+
end # BitBucket
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket #:nodoc
|
4
|
+
# Raised when BitBucket returns any of the HTTP status codes
|
5
|
+
module Error
|
6
|
+
class ServiceError < BitBucketError
|
7
|
+
attr_accessor :http_headers
|
8
|
+
|
9
|
+
def initialize(env)
|
10
|
+
super(generate_message(env))
|
11
|
+
@http_headers = env[:response_headers]
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate_message(env)
|
15
|
+
"#{env[:method].to_s.upcase} #{env[:url].to_s}: #{env[:status]} #{env[:body]}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end # Error
|
19
|
+
end # BitBucket
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket #:nodoc
|
4
|
+
# Raised when invalid options are passed to a request body
|
5
|
+
module Error
|
6
|
+
class UnknownValue < ClientError
|
7
|
+
def initialize(key, value, permitted)
|
8
|
+
super(
|
9
|
+
generate_message(
|
10
|
+
:problem => "Wrong value of '#{value}' for the parameter: #{key} provided for this request.",
|
11
|
+
:summary => "BitBucket gem checks the request parameters passed to ensure that github api is not hit unnecessairly and fails fast.",
|
12
|
+
:resolution => "Permitted values are: #{permitted}, make sure these are the ones you are using"
|
13
|
+
)
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end # Error
|
18
|
+
end # BitBucket
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket #:nodoc
|
4
|
+
# Raised when passed parameters are missing or contain wrong values.
|
5
|
+
module Error
|
6
|
+
class Validations < ClientError
|
7
|
+
def initialize(errors)
|
8
|
+
super(
|
9
|
+
generate_message(
|
10
|
+
:problem => '',
|
11
|
+
:summary => '',
|
12
|
+
:resolution => ''
|
13
|
+
)
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end # Error
|
18
|
+
end # BitBucket
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket
|
4
|
+
module Error
|
5
|
+
class BitBucketError < StandardError
|
6
|
+
attr_reader :response_message, :response_headers
|
7
|
+
|
8
|
+
def initialize(message)
|
9
|
+
super message
|
10
|
+
@response_message = message
|
11
|
+
end
|
12
|
+
|
13
|
+
# def inspect
|
14
|
+
# %(#<#{self.class}>)
|
15
|
+
# end
|
16
|
+
end
|
17
|
+
end # Error
|
18
|
+
end # BitBucket
|
19
|
+
|
20
|
+
%w[
|
21
|
+
service_error
|
22
|
+
not_found
|
23
|
+
forbidden
|
24
|
+
bad_request
|
25
|
+
unauthorized
|
26
|
+
service_unavailable
|
27
|
+
internal_server_error
|
28
|
+
unprocessable_entity
|
29
|
+
client_error
|
30
|
+
invalid_options
|
31
|
+
required_params
|
32
|
+
unknown_value
|
33
|
+
].each do |error|
|
34
|
+
require "bitbucket_rest_api/error/#{error}"
|
35
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket
|
4
|
+
class Invitations < API
|
5
|
+
def invite(user_name, repo_name, emailaddress, perm)
|
6
|
+
_update_user_repo_params(user_name, repo_name)
|
7
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
8
|
+
_validate_presence_of emailaddress
|
9
|
+
perm ||= "write"
|
10
|
+
|
11
|
+
post_request("/invitations/#{user}/#{repo.downcase}/#{emailaddress}",
|
12
|
+
permission: perm)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|