yammer-client 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +1 -2
- data/lib/yammer/configurable.rb +15 -0
- data/lib/yammer/http_adapter.rb +31 -19
- data/lib/yammer/version.rb +1 -1
- data/spec/client_spec.rb +2 -2
- metadata +1 -1
- metadata.gz.sig +2 -2
data.tar.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
�
|
2
|
-
:�`"�HiH&�
|
1
|
+
�h,�5�s��]y���*������iK�? ��s�5_ˬ�֍s�"M0�Q$a�)�_p���D�H�ap���+��#
|
data/lib/yammer/configurable.rb
CHANGED
@@ -48,5 +48,20 @@ module Yammer
|
|
48
48
|
yield self if block_given?
|
49
49
|
self
|
50
50
|
end
|
51
|
+
|
52
|
+
def enable_logging(output='stdout')
|
53
|
+
self.http_adapter.log = output
|
54
|
+
end
|
55
|
+
|
56
|
+
def disable_logging
|
57
|
+
self.http_adapter.log = nil
|
58
|
+
end
|
59
|
+
|
60
|
+
def with_logging(output)
|
61
|
+
cached_output = self.http_adapter.log
|
62
|
+
enable_logging(output)
|
63
|
+
yield self if block_given?
|
64
|
+
self.http_adapter.log = cached_output
|
65
|
+
end
|
51
66
|
end
|
52
67
|
end
|
data/lib/yammer/http_adapter.rb
CHANGED
@@ -5,6 +5,10 @@ require 'addressable/uri'
|
|
5
5
|
module Yammer
|
6
6
|
class HttpAdapter
|
7
7
|
|
8
|
+
def self.log=(output)
|
9
|
+
RestClient.log = output
|
10
|
+
end
|
11
|
+
|
8
12
|
attr_reader :site_url, :connection_options
|
9
13
|
|
10
14
|
def initialize(site_url, opts={})
|
@@ -41,28 +45,36 @@ module Yammer
|
|
41
45
|
end
|
42
46
|
|
43
47
|
def send_request(method, path, opts={})
|
44
|
-
|
48
|
+
begin
|
49
|
+
params = opts.fetch(:params, {})
|
45
50
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
51
|
+
req_opts = self.connection_options.merge({
|
52
|
+
:method => method,
|
53
|
+
:headers => opts.fetch(:headers, {})
|
54
|
+
})
|
50
55
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
56
|
+
case method
|
57
|
+
when :get, :delete
|
58
|
+
query = Addressable::URI.form_encode(params)
|
59
|
+
normalized_path = query.empty? ? path : [path, query].join("?")
|
60
|
+
req_opts[:url] = absolute_url(normalized_path)
|
61
|
+
when :post, :put
|
62
|
+
req_opts[:payload] = params
|
63
|
+
req_opts[:url] = absolute_url(path)
|
64
|
+
else
|
65
|
+
raise "Unsupported HTTP method, #{method}"
|
66
|
+
end
|
62
67
|
|
63
|
-
|
64
|
-
|
65
|
-
|
68
|
+
resp = RestClient::Request.execute(req_opts)
|
69
|
+
|
70
|
+
result = Yammer::ApiResponse.new(resp.headers, resp.body, resp.code)
|
71
|
+
rescue => e
|
72
|
+
if e.is_a?(RestClient::ExceptionWithResponse)
|
73
|
+
e.response
|
74
|
+
else
|
75
|
+
raise e
|
76
|
+
end
|
77
|
+
end
|
66
78
|
end
|
67
79
|
|
68
80
|
private
|
data/lib/yammer/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -328,7 +328,7 @@ describe Yammer::Client do
|
|
328
328
|
:body => '{ "response": { "message": "Token not found.", "code": 16, "stat": "fail" } }',
|
329
329
|
:status => 401)
|
330
330
|
|
331
|
-
expect
|
331
|
+
expect(subject.get('/users/1')).to eq ('{ "response": { "message": "Token not found.", "code": 16, "stat": "fail" } }')
|
332
332
|
end
|
333
333
|
end
|
334
334
|
|
@@ -338,7 +338,7 @@ describe Yammer::Client do
|
|
338
338
|
:body => '{ "response": { "message": "Rate limited due to excessive requests.", "code": 33, "stat": "fail" } }',
|
339
339
|
:status => 429
|
340
340
|
)
|
341
|
-
expect
|
341
|
+
expect(subject.get('/users/1')).to eq ('{ "response": { "message": "Rate limited due to excessive requests.", "code": 33, "stat": "fail" } }')
|
342
342
|
end
|
343
343
|
end
|
344
344
|
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
��9h:N���e�Ut9LR8U!G7Q�|�
|
2
|
+
A�_�8�>��z"�?�èD�Y�,H�B�_B�,�% 5�}<�i7 ��2��Gt?(2:-����U�ݽt!<e��V�p�ڟѢ5ע�y[͏�H��������1��ƀ����E ��-
|