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 CHANGED
@@ -1,2 +1 @@
1
- c=�0�T�n�|ZOT�'��'�׭h�0n���n �?���r�C�6�8�ၮM��M��o5[���LOX(UV��-���2���$.R��\_YcE0�v��[�i7-�M ��O�Ûs��9P��EZ(hO��{D�ў��w1?����A��"o'�=s��^����1��v%���Li�)M1 p0BNQZ�9 t!C�ou[1Z�[l0Z��
2
- :�`"�HiH&�
1
+ �h,�5�߻s��]y���*������iK�?‰ ��s5_ˬ�֍s�"M0Q$a�)�_p���DH�ap���+��#
@@ -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
@@ -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
- params = opts.fetch(:params, {})
48
+ begin
49
+ params = opts.fetch(:params, {})
45
50
 
46
- req_opts = self.connection_options.merge({
47
- :method => method,
48
- :headers => opts.fetch(:headers, {})
49
- })
51
+ req_opts = self.connection_options.merge({
52
+ :method => method,
53
+ :headers => opts.fetch(:headers, {})
54
+ })
50
55
 
51
- case method
52
- when :get, :delete
53
- query = Addressable::URI.form_encode(params)
54
- normalized_path = query.empty? ? path : [path, query].join("?")
55
- req_opts[:url] = absolute_url(normalized_path)
56
- when :post, :put
57
- req_opts[:payload] = params
58
- req_opts[:url] = absolute_url(path)
59
- else
60
- raise "Unsupported HTTP method, #{method}"
61
- end
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
- resp = RestClient::Request.execute(req_opts)
64
-
65
- result = Yammer::ApiResponse.new(resp.headers, resp.body, resp.code)
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
@@ -2,7 +2,7 @@ module Yammer
2
2
  class Version
3
3
  MAJOR = 0 unless defined? Yammer::MAJOR
4
4
  MINOR = 1 unless defined? Yammer::MINOR
5
- PATCH = 7 unless defined? Yammer::PATCH
5
+ PATCH = 8 unless defined? Yammer::PATCH
6
6
  PRE = nil unless defined? Yammer::PRE
7
7
 
8
8
  class << self
@@ -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 { subject.get('/users/1') }.to raise_error(RestClient::Unauthorized)
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 { subject.get('/users/1') }.to raise_error(RestClient::RequestFailed)
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
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yammer-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
metadata.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- �f$�E{D�4��G�]NP�&Q���|�w�R��D��>9�t�_����8V����5p&)��jR��`����
2
- r8��hW5��
1
+ ��9h:N���eUt9LR8U!G7Q�|�
2
+ A�_�8�>��z"�?�èD� Y�,HB�_B�,�% 5�}<�i7 ��2��Gt?(2:-����U�ݽt!<e��V�p�ڟѢ5ע�y[͏ �H��������1��ƀ�� ��E ��-