codenamev_bitbucket_api 0.4.0

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.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +43 -0
  3. data/README.md +169 -0
  4. data/Rakefile +3 -0
  5. data/lib/bitbucket_rest_api/api/actions.rb +50 -0
  6. data/lib/bitbucket_rest_api/api/arguments.rb +248 -0
  7. data/lib/bitbucket_rest_api/api/config/property.rb +30 -0
  8. data/lib/bitbucket_rest_api/api/config/property_set.rb +118 -0
  9. data/lib/bitbucket_rest_api/api/config.rb +107 -0
  10. data/lib/bitbucket_rest_api/api/factory.rb +29 -0
  11. data/lib/bitbucket_rest_api/api.rb +242 -0
  12. data/lib/bitbucket_rest_api/authorization.rb +34 -0
  13. data/lib/bitbucket_rest_api/client/invitations.rb +16 -0
  14. data/lib/bitbucket_rest_api/client/issues/comments.rb +109 -0
  15. data/lib/bitbucket_rest_api/client/issues/components.rb +103 -0
  16. data/lib/bitbucket_rest_api/client/issues/milestones.rb +103 -0
  17. data/lib/bitbucket_rest_api/client/issues.rb +214 -0
  18. data/lib/bitbucket_rest_api/client/repos/changesets.rb +55 -0
  19. data/lib/bitbucket_rest_api/client/repos/following.rb +40 -0
  20. data/lib/bitbucket_rest_api/client/repos/keys.rb +88 -0
  21. data/lib/bitbucket_rest_api/client/repos/pull_requests/comments.rb +42 -0
  22. data/lib/bitbucket_rest_api/client/repos/pull_requests/commits.rb +24 -0
  23. data/lib/bitbucket_rest_api/client/repos/pull_requests.rb +199 -0
  24. data/lib/bitbucket_rest_api/client/repos/services.rb +104 -0
  25. data/lib/bitbucket_rest_api/client/repos/sources.rb +32 -0
  26. data/lib/bitbucket_rest_api/client/repos.rb +224 -0
  27. data/lib/bitbucket_rest_api/client/user.rb +96 -0
  28. data/lib/bitbucket_rest_api/client/users/account.rb +54 -0
  29. data/lib/bitbucket_rest_api/client/users.rb +14 -0
  30. data/lib/bitbucket_rest_api/client.rb +54 -0
  31. data/lib/bitbucket_rest_api/compatibility.rb +23 -0
  32. data/lib/bitbucket_rest_api/configuration.rb +59 -0
  33. data/lib/bitbucket_rest_api/connection.rb +61 -0
  34. data/lib/bitbucket_rest_api/constants.rb +50 -0
  35. data/lib/bitbucket_rest_api/core_ext/array.rb +17 -0
  36. data/lib/bitbucket_rest_api/core_ext/hash.rb +56 -0
  37. data/lib/bitbucket_rest_api/core_ext/ordered_hash.rb +107 -0
  38. data/lib/bitbucket_rest_api/deprecation.rb +39 -0
  39. data/lib/bitbucket_rest_api/error/bad_request.rb +12 -0
  40. data/lib/bitbucket_rest_api/error/client_error.rb +20 -0
  41. data/lib/bitbucket_rest_api/error/forbidden.rb +12 -0
  42. data/lib/bitbucket_rest_api/error/internal_server_error.rb +12 -0
  43. data/lib/bitbucket_rest_api/error/invalid_options.rb +18 -0
  44. data/lib/bitbucket_rest_api/error/not_found.rb +12 -0
  45. data/lib/bitbucket_rest_api/error/required_params.rb +18 -0
  46. data/lib/bitbucket_rest_api/error/service_error.rb +19 -0
  47. data/lib/bitbucket_rest_api/error/service_unavailable.rb +12 -0
  48. data/lib/bitbucket_rest_api/error/unauthorized.rb +12 -0
  49. data/lib/bitbucket_rest_api/error/unknown_value.rb +18 -0
  50. data/lib/bitbucket_rest_api/error/unprocessable_entity.rb +12 -0
  51. data/lib/bitbucket_rest_api/error/validations.rb +18 -0
  52. data/lib/bitbucket_rest_api/error.rb +35 -0
  53. data/lib/bitbucket_rest_api/ext/faraday.rb +38 -0
  54. data/lib/bitbucket_rest_api/middleware.rb +31 -0
  55. data/lib/bitbucket_rest_api/normalizer.rb +27 -0
  56. data/lib/bitbucket_rest_api/null_encoder.rb +25 -0
  57. data/lib/bitbucket_rest_api/page_iterator.rb +90 -0
  58. data/lib/bitbucket_rest_api/page_links.rb +33 -0
  59. data/lib/bitbucket_rest_api/paged_request.rb +29 -0
  60. data/lib/bitbucket_rest_api/pagination.rb +97 -0
  61. data/lib/bitbucket_rest_api/parameter_filter.rb +32 -0
  62. data/lib/bitbucket_rest_api/params_hash.rb +100 -0
  63. data/lib/bitbucket_rest_api/request/basic_auth.rb +33 -0
  64. data/lib/bitbucket_rest_api/request/jsonize.rb +51 -0
  65. data/lib/bitbucket_rest_api/request/oauth.rb +51 -0
  66. data/lib/bitbucket_rest_api/request/verbs.rb +53 -0
  67. data/lib/bitbucket_rest_api/request.rb +91 -0
  68. data/lib/bitbucket_rest_api/response/header.rb +68 -0
  69. data/lib/bitbucket_rest_api/response/helpers.rb +21 -0
  70. data/lib/bitbucket_rest_api/response/jsonize.rb +30 -0
  71. data/lib/bitbucket_rest_api/response/mashify.rb +24 -0
  72. data/lib/bitbucket_rest_api/response/raise_error.rb +31 -0
  73. data/lib/bitbucket_rest_api/response/xmlize.rb +26 -0
  74. data/lib/bitbucket_rest_api/response.rb +28 -0
  75. data/lib/bitbucket_rest_api/response_wrapper.rb +157 -0
  76. data/lib/bitbucket_rest_api/result.rb +68 -0
  77. data/lib/bitbucket_rest_api/users.rb +20 -0
  78. data/lib/bitbucket_rest_api/utils/url.rb +56 -0
  79. data/lib/bitbucket_rest_api/validations/format.rb +24 -0
  80. data/lib/bitbucket_rest_api/validations/presence.rb +30 -0
  81. data/lib/bitbucket_rest_api/validations/required.rb +24 -0
  82. data/lib/bitbucket_rest_api/validations/token.rb +43 -0
  83. data/lib/bitbucket_rest_api/validations.rb +25 -0
  84. data/lib/bitbucket_rest_api/version.rb +11 -0
  85. data/lib/bitbucket_rest_api.rb +136 -0
  86. metadata +238 -0
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ require 'faraday'
4
+
5
+ module BitBucket
6
+ class Request
7
+ class OAuth < Faraday::Middleware
8
+ include BitBucket::Utils::Url
9
+
10
+ AUTH_HEADER = 'Authorization'.freeze
11
+
12
+ dependency 'simple_oauth'
13
+
14
+ def call(env)
15
+ # Extract parameters from the query
16
+ params = { }.update query_params(env[:url])
17
+
18
+ if (@token and @secret) and (!@token.empty? and !@secret.empty?)
19
+ access_token = ::OAuth::AccessToken.new(@consumer, @token, @secret)
20
+ env[:url].query = build_query params
21
+
22
+ puts oauth_helper.header
23
+ puts oauth_helper.header.class
24
+ env[:request_headers].merge!(AUTH_HEADER => oauth_helper.header)
25
+ end
26
+
27
+ env[:url].query = build_query params
28
+
29
+
30
+
31
+ @app.call env
32
+ end
33
+
34
+ def initialize(app, *args)
35
+ super app
36
+ @app = app
37
+ @consumer = args.shift
38
+ @token = args.shift
39
+ @secret = args.shift
40
+ end
41
+
42
+ def query_params(url)
43
+ if url.query.nil? or url.query.empty?
44
+ {}
45
+ else
46
+ parse_query url.query
47
+ end
48
+ end
49
+ end # OAuth
50
+ end # Request
51
+ end # BitBucket
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ # A class responsible for dispatching http requests
5
+ class Request
6
+
7
+ # Defines HTTP verbs
8
+ module Verbs
9
+ # Make a get request
10
+ #
11
+ # @api public
12
+ def get_request(path, params = ParamsHash.empty)
13
+ request = Request.new(:get, path, self).call(current_options, params)
14
+ request.auto_paginate
15
+ end
16
+
17
+ # Make a patch request
18
+ #
19
+ # @api public
20
+ def patch_request(path, params = ParamsHash.empty)
21
+ Request.new(:patch, path, self).call(current_options, params)
22
+ end
23
+
24
+ # Make a post request
25
+ #
26
+ # @api public
27
+ def post_request(path, params = ParamsHash.empty)
28
+ Request.new(:post, path, self).call(current_options, params)
29
+ end
30
+
31
+ # Make a put request
32
+ #
33
+ # @api public
34
+ def put_request(path, params = ParamsHash.empty)
35
+ Request.new(:put, path, self).call(current_options, params)
36
+ end
37
+
38
+ # Make a delete request
39
+ #
40
+ # @api public
41
+ def delete_request(path, params = ParamsHash.empty)
42
+ Request.new(:delete, path, self).call(current_options, params)
43
+ end
44
+
45
+ # Make a options request
46
+ #
47
+ # @api public
48
+ def options_request(path, params = ParamsHash.empty)
49
+ Request.new(:options, path, self).call(current_options, params)
50
+ end
51
+ end # Verbs
52
+ end # Request
53
+ end # BitBucket
@@ -0,0 +1,91 @@
1
+ # encoding: utf-8
2
+
3
+ require 'bitbucket_rest_api/request/oauth'
4
+ require 'bitbucket_rest_api/request/basic_auth'
5
+ require 'bitbucket_rest_api/request/jsonize'
6
+
7
+ require 'bitbucket_rest_api/connection'
8
+
9
+ module BitBucket
10
+ # Defines HTTP verbs
11
+ class Request
12
+ include Connection
13
+
14
+ HTTP_METHODS = [:get, :post, :put, :delete, :patch]
15
+ METHODS_WITH_BODIES = [ :post, :put, :patch ]
16
+
17
+ # Return http verb
18
+ #
19
+ # @return [Symbol]
20
+ attr_reader :action
21
+
22
+ # Return url
23
+ #
24
+ # @return [String]
25
+ attr_accessor :path
26
+
27
+ # Return api this request is associated with
28
+ #
29
+ # @return [BitBucket::API]
30
+ attr_reader :api
31
+
32
+ # Create a new Request
33
+ #
34
+ # @return [BitBucket::Request]
35
+ #
36
+ # @api public
37
+ def initialize(action, path, api)
38
+ @action = action
39
+ @path = path
40
+ @api = api
41
+ end
42
+
43
+ # Performs a request
44
+ #
45
+ # @param [Symbol] method - The Symbol the HTTP verb
46
+ # @param [String] path - String relative URL to access
47
+ # @param [Hash] params - Hash to configure the request API
48
+ #
49
+ # @return [BitBucket::ResponseWrapper]
50
+ #
51
+ # @api private
52
+ def call(current_options, params)
53
+ unless HTTP_METHODS.include?(action)
54
+ raise ArgumentError, "unknown http method: #{method}"
55
+ end
56
+
57
+ puts "EXECUTED: #{action} - #{path} with PARAMS: #{params}" if ENV['DEBUG']
58
+
59
+ request_options = params.options
60
+ connection_options = current_options.merge(request_options)
61
+ conn = connection(api, connection_options)
62
+
63
+ if conn.path_prefix != '/' && self.path.index(conn.path_prefix) != 0
64
+ self.path = (conn.path_prefix + self.path).gsub(/\/(\/)*/, '/')
65
+ end
66
+
67
+ response = conn.send(action) do |request|
68
+ case action.to_sym
69
+ when *(HTTP_METHODS - METHODS_WITH_BODIES)
70
+ request.body = params.data if params.has_key?('data')
71
+ if params.has_key?('encoder')
72
+ request.params.params_encoder(params.encoder)
73
+ end
74
+ request.url(self.path, params.to_hash)
75
+ when *METHODS_WITH_BODIES
76
+ request.url(self.path, connection_options[:query] || {})
77
+ request.body = extract_data_from_params(params) unless params.empty?
78
+ end
79
+ end
80
+ ResponseWrapper.new(response, api)
81
+ end
82
+
83
+ private
84
+
85
+ def extract_data_from_params(params) # :nodoc:
86
+ return params['data'] if params.has_key?('data') and !params['data'].nil?
87
+ return params
88
+ end
89
+
90
+ end # Request
91
+ end # BitBucket
@@ -0,0 +1,68 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Response
5
+
6
+ # Represents http response header
7
+ class Header < Struct.new(:env)
8
+ include BitBucket::Constants
9
+
10
+ SUCCESSFUL_STATUSES = 200..299
11
+
12
+ def loaded?
13
+ !!env
14
+ end
15
+
16
+ # Requests are limited to API v3 to 5000 per hour.
17
+ def ratelimit_limit
18
+ loaded? ? env[:response_headers][RATELIMIT_LIMIT] : nil
19
+ end
20
+
21
+ def ratelimit_remaining
22
+ loaded? ? env[:response_headers][RATELIMIT_REMAINING] : nil
23
+ end
24
+
25
+ def cache_control
26
+ loaded? ? env[:response_headers][CACHE_CONTROL] : nil
27
+ end
28
+
29
+ def content_type
30
+ loaded? ? env[:response_headers][CONTENT_TYPE] : nil
31
+ end
32
+
33
+ def content_length
34
+ loaded? ? env[:response_headers][CONTENT_LENGTH] : nil
35
+ end
36
+
37
+ def etag
38
+ loaded? ? env[:response_headers][ETAG] : nil
39
+ end
40
+
41
+ def date
42
+ loaded? ? env[:response_headers][DATE] : nil
43
+ end
44
+
45
+ def location
46
+ loaded? ? env[:response_headers][LOCATION] : nil
47
+ end
48
+
49
+ def server
50
+ loaded? ? env[:response_headers][SERVER] : nil
51
+ end
52
+
53
+ def status
54
+ loaded? ? env[:status] : nil
55
+ end
56
+
57
+ def success?
58
+ SUCCESSFUL_STATUSES.include? status
59
+ end
60
+
61
+ # Returns raw body
62
+ def body
63
+ loaded? ? env[:body] : nil
64
+ end
65
+
66
+ end # Header
67
+ end # Response
68
+ end # BitBucket
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ require 'faraday'
4
+
5
+ module BitBucket
6
+ class Response::Helpers < Response
7
+
8
+ def on_complete(env)
9
+ env[:body].class.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
10
+ include BitBucket::Result
11
+
12
+ def env
13
+ @env
14
+ end
15
+
16
+ RUBY_EVAL
17
+ env[:body].instance_eval { @env = env }
18
+ end
19
+
20
+ end # Response::Helpers
21
+ end # BitBucket
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+
3
+ require 'faraday'
4
+
5
+ module BitBucket
6
+ class Response::Jsonize < Response
7
+ dependency 'multi_json'
8
+
9
+ define_parser do |body|
10
+ if MultiJson.respond_to?(:load)
11
+ MultiJson.load body
12
+ else
13
+ MultiJson.decode body
14
+ end
15
+ end
16
+
17
+ def parse(body)
18
+ case body
19
+ when ''
20
+ nil
21
+ when 'true'
22
+ true
23
+ when 'false'
24
+ false
25
+ else
26
+ self.class.parser.call body
27
+ end
28
+ end
29
+ end # Response::Jsonize
30
+ end # BitBucket
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ require 'faraday'
4
+
5
+ module BitBucket
6
+ class Response::Mashify < Response
7
+ dependency 'hashie/mash'
8
+
9
+ define_parser do |body|
10
+ ::Hashie::Mash.new body
11
+ end
12
+
13
+ def parse(body)
14
+ case body
15
+ when Hash
16
+ self.class.parser.call body
17
+ when Array
18
+ body.map { |item| item.is_a?(Hash) ? self.class.parser.call(item) : item }
19
+ else
20
+ body
21
+ end
22
+ end
23
+ end # Response::Mashify
24
+ end # BitBucket
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+
3
+ require 'faraday'
4
+ require 'bitbucket_rest_api/error'
5
+
6
+ module BitBucket
7
+ class Response::RaiseError < Faraday::Response::Middleware
8
+
9
+ def on_complete(env)
10
+ case env[:status].to_i
11
+ when 400
12
+ raise BitBucket::Error::BadRequest.new(env)
13
+ when 401
14
+ raise BitBucket::Error::Unauthorized.new(env)
15
+ when 403
16
+ raise BitBucket::Error::Forbidden.new(env)
17
+ when 404
18
+ raise BitBucket::Error::NotFound.new(env)
19
+ when 422
20
+ raise BitBucket::Error::UnprocessableEntity.new(env)
21
+ when 500
22
+ raise BitBucket::Error::InternalServerError.new(env)
23
+ when 503
24
+ raise BitBucket::Error::ServiceUnavailable.new(env)
25
+ when 400...600
26
+ raise BitBucket::Error::ServiceError.new(env)
27
+ end
28
+ end
29
+
30
+ end # Response::RaiseError
31
+ end # BitBucket
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ require 'faraday'
4
+
5
+ module BitBucket
6
+ class Response::Xmlize < Response
7
+ dependency 'nokogiri'
8
+
9
+ define_parser do |body|
10
+ ::Nokogiri::XML body
11
+ end
12
+
13
+ def parse(body)
14
+ case body
15
+ when ''
16
+ nil
17
+ when 'true'
18
+ true
19
+ when 'false'
20
+ false
21
+ else
22
+ self.class.parser.call body
23
+ end
24
+ end
25
+ end # Response::Xmlize
26
+ end # BitBucket
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+
3
+ require 'faraday'
4
+
5
+ module BitBucket
6
+ # Contains methods and attributes that act on the response returned from the
7
+ # request
8
+ class Response < Faraday::Response::Middleware
9
+ CONTENT_TYPE = 'Content-Type'.freeze
10
+
11
+ class << self
12
+ attr_accessor :parser
13
+ end
14
+
15
+ def self.define_parser(&block)
16
+ @parser = block
17
+ end
18
+
19
+ def response_type(env)
20
+ env[:response_headers][CONTENT_TYPE].to_s
21
+ end
22
+
23
+ def parse_response?(env)
24
+ env[:body].respond_to? :to_str
25
+ end
26
+
27
+ end # Response
28
+ end # BitBucket
@@ -0,0 +1,157 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+
5
+ # A class responsible for proxing to faraday response
6
+ class ResponseWrapper
7
+ extend Forwardable
8
+ include Pagination
9
+ include Enumerable
10
+
11
+ attr_reader :response
12
+
13
+ attr_reader :current_api
14
+
15
+ attr_reader :env
16
+
17
+ def_delegators :body, :empty?, :size, :include?, :length, :to_a, :first, :flatten, :include?, :keys, :[]
18
+
19
+ def initialize(response, current_api)
20
+ @response = response
21
+ @current_api = current_api
22
+ @env = response.env
23
+ end
24
+
25
+ # Overwrite methods to hash keys
26
+ #
27
+ ['id', 'type', 'fork'].each do |method_name|
28
+ define_method(method_name) do
29
+ self.body.fetch(method_name.to_s)
30
+ end
31
+ end
32
+
33
+ # Request url
34
+ #
35
+ def url
36
+ response.env[:url].to_s
37
+ end
38
+
39
+ def body=(value)
40
+ @body = value
41
+ @env[:body] = value
42
+ end
43
+
44
+ # Response raw body
45
+ #
46
+ def body
47
+ @body ? @body : response.body
48
+ end
49
+
50
+ # Response status
51
+ #
52
+ def status
53
+ response.status
54
+ end
55
+
56
+ def success?
57
+ response.success?
58
+ end
59
+
60
+ def redirect?
61
+ status.to_i >= 300 && status.to_i < 400
62
+ end
63
+
64
+ def client_error?
65
+ status.to_i >= 400 && status.to_i < 500
66
+ end
67
+
68
+ def server_error?
69
+ status.to_i >= 500 && status.to_i < 600
70
+ end
71
+
72
+ # Return response headers
73
+ #
74
+ def headers
75
+ BitBucket::Response::Header.new(env)
76
+ end
77
+
78
+ # Lookup an attribute from the body if hash, otherwise behave like array index.
79
+ # Convert any key to string before calling.
80
+ #
81
+ def [](key)
82
+ if self.body.is_a?(Array)
83
+ self.body[key]
84
+ else
85
+ self.body.send(:"#{key}")
86
+ end
87
+ end
88
+
89
+ # Return response body as string
90
+ #
91
+ def to_s
92
+ body.to_s
93
+ end
94
+
95
+ # Convert the ResponseWrapper into a Hash
96
+ #
97
+ def to_hash
98
+ body.to_hash
99
+ end
100
+
101
+ # Convert the ResponseWrapper into an Array
102
+ #
103
+ def to_ary
104
+ body.to_ary
105
+ end
106
+
107
+ # Iterate over each resource inside the body
108
+ #
109
+ def each
110
+ body_parts = self.body.respond_to?(:each) ? self.body : [self.body]
111
+ return body_parts.to_enum unless block_given?
112
+ body_parts.each { |part| yield(part) }
113
+ end
114
+
115
+ # Check if body has an attribute
116
+ #
117
+ def has_key?(key)
118
+ self.body.is_a?(Hash) && self.body.has_key?(key)
119
+ end
120
+
121
+ # Coerce any method calls for body attributes
122
+ #
123
+ def method_missing(method_name, *args, &block)
124
+ if self.has_key?(method_name.to_s)
125
+ self.[](method_name, &block)
126
+ else
127
+ super
128
+ end
129
+ end
130
+
131
+ # Check if method is defined on the body
132
+ #
133
+ def respond_to?(method_name)
134
+ if self.has_key?(method_name.to_s)
135
+ true
136
+ else
137
+ super
138
+ end
139
+ end
140
+
141
+ # Print only response body
142
+ #
143
+ def inspect
144
+ "#<#{self.class.name} @body=\"#{self.body}\">"
145
+ end
146
+
147
+ # Compare the wrapper with other wrapper for equality
148
+ #
149
+ def ==(other)
150
+ return false unless other.is_a?(self.class)
151
+ return false unless (other.respond_to?(:env) && other.respond_to?(:body))
152
+ self.env == other.env && self.body == other.body
153
+ end
154
+ alias eql? ==
155
+
156
+ end # ResponseWrapper
157
+ end # BitBucket
@@ -0,0 +1,68 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ module Result
5
+ include BitBucket::Constants
6
+ include Pagination
7
+
8
+ # TODO Add result counts method to check total items looking at result links
9
+
10
+ def paginated?
11
+ loaded? ? !@env[:body][PARAM_PAGE].nil? : false
12
+ end
13
+
14
+ def ratelimit_limit
15
+ loaded? ? @env[:response_headers][RATELIMIT_LIMIT] : nil
16
+ end
17
+
18
+ def ratelimit_remaining
19
+ loaded? ? @env[:response_headers][RATELIMIT_REMAINING] : nil
20
+ end
21
+
22
+ def cache_control
23
+ loaded? ? @env[:response_headers][CACHE_CONTROL] : nil
24
+ end
25
+
26
+ def content_type
27
+ loaded? ? @env[:response_headers][CONTENT_TYPE] : nil
28
+ end
29
+
30
+ def content_length
31
+ loaded? ? @env[:response_headers][CONTENT_LENGTH] : nil
32
+ end
33
+
34
+ def etag
35
+ loaded? ? @env[:response_headers][ETAG] : nil
36
+ end
37
+
38
+ def date
39
+ loaded? ? @env[:response_headers][DATE] : nil
40
+ end
41
+
42
+ def location
43
+ loaded? ? @env[:response_headers][LOCATION] : nil
44
+ end
45
+
46
+ def server
47
+ loaded? ? @env[:response_headers][SERVER] : nil
48
+ end
49
+
50
+ def status
51
+ loaded? ? @env[:status] : nil
52
+ end
53
+
54
+ def success?
55
+ (200..299).include? status
56
+ end
57
+
58
+ # Returns raw body
59
+ def body
60
+ loaded? ? @env[:body] : nil
61
+ end
62
+
63
+ def loaded?
64
+ !!@env
65
+ end
66
+
67
+ end # Result
68
+ end # BitBucket
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Client::Users < API
5
+ @version = '1.0'
6
+
7
+ require_all 'bitbucket_rest_api/users', 'account'
8
+
9
+
10
+ # Creates new Users API
11
+ def initialize(options = { })
12
+ super(options)
13
+ end
14
+
15
+ # Access to Users::Account API
16
+ namespace :account
17
+
18
+
19
+ end # Users
20
+ end # BitBucket