yam 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dfcfc553032f8390dc3e9152712c014c2e2121e3
4
+ data.tar.gz: 542b4d2bc6af453b05f4be934e4cb30616562354
5
+ SHA512:
6
+ metadata.gz: c067db8b3bb4ccd6b0841826218620127c5b806771589dc446415960be20cc999cfee10c51750653cda64034fd70a527394eb111ae0103629bbf01c0d76421f0
7
+ data.tar.gz: 450d9ec398c7f513cdd1d8b612f63ee06ac6327a1dafd2d4efb239b5c0dcf16489f7d064224d4c741c3b0aefe0a95897c5caf11e03a485bb1e28c43e0b0e6ac2
checksums.yaml.gz.sig ADDED
@@ -0,0 +1 @@
1
+ ��<c2im��I/Ȳ&���3�(��L6��q׷�?I���E�;� �"�������cC�q��k�QKx/
data/.travis.yml CHANGED
@@ -5,7 +5,6 @@ rvm:
5
5
  - 1.9.2
6
6
  - 1.8.7
7
7
  - ree
8
- - rbx-19mode
9
8
  branches:
10
9
  only:
11
10
  - master
data/README.md CHANGED
@@ -1,14 +1,13 @@
1
1
  Yam
2
2
  =============
3
+
3
4
  [![Gem Version](https://badge.fury.io/rb/yam.png)](http://badge.fury.io/rb/yam)
4
- [![Build Status](https://travis-ci.org/yammer/yam.png?branch=master)][travis]
5
+ [![Build Status](https://travis-ci.org/yammer/yam.png?branch=master)](https://travis-ci.org/yammer/yam)
5
6
  [![Coverage Status](https://coveralls.io/repos/yammer/yam/badge.png)](https://coveralls.io/r/yammer/yam)
7
+ [![Code Climate](https://codeclimate.com/github/yammer/yam.png)](https://codeclimate.com/github/yammer/yam)
6
8
 
7
- [gemversion]: (http://badge.fury.io/rb/yam)
8
- [travis]: (https://travis-ci.org/yammer/yam)
9
- [coveralls]: (https://coveralls.io/r/yammer/yam)
10
9
 
11
- A Yammer Ruby gem
10
+ The Yammer Ruby gem
12
11
 
13
12
  ## Documentation
14
13
 
@@ -45,7 +44,7 @@ The Yammer API requires authentication for access to certain endpoints. Below ar
45
44
 
46
45
  ### Register your application
47
46
 
48
- Setup a Yammer client application as described in [Build your first Yammer App](https://developer.yammer.com/introduction/)
47
+ Setup a Yammer client application as described on the [Yammer Developer site](https://developer.yammer.com/introduction/)
49
48
 
50
49
  ### Obtaining an access token
51
50
 
@@ -59,23 +58,11 @@ Setup a Yammer client application as described in [Build your first Yammer App](
59
58
 
60
59
  5. The authorization server will respond with an access token
61
60
 
62
- ```
61
+ ```ruby
63
62
  "access_token": {
64
- "view_subscriptions": true,
65
- "expires_at": null,
66
- authorized_at": "2011/04/06 16:25:46 +0000",
67
- "modify_subscriptions": true,
68
- "modify_messages": true,
69
- "network_permalink": "yammer-inc.com",
70
- "view_members": true,
71
- "view_tags": true,
72
- "network_id": 155465488,
73
- "user_id": 1014216,
74
- "view_groups": true,
75
- "token": "abcdefghijklmn",
76
- "network_name": "Yammer",
77
- "view_messages": true,
78
- "created_at": "2011/04/06 16:25:46 +0000"
63
+ ...
64
+ "token": "abcxyz12345",
65
+ ...
79
66
  }
80
67
  ```
81
68
 
@@ -96,102 +83,149 @@ You may change this configuration by using the `configure` method
96
83
  Yammer.configure do |c|
97
84
  c.client_id = '[client_id]'
98
85
  c.client_secret = '[client_secret]'
99
- c.token = '[access_token]'
100
86
  end
101
87
  #> Yammer
102
88
  ```
103
89
 
104
- At this point, your new settings will take effect
90
+ At this point, your new settings will take effect.
105
91
 
106
92
  ```ruby
107
93
  Yammer.options
108
- #> {:site_url=>"https://www.yammer.com", :client_id=>'[client_id]', :client_secret=>'[client_secret]', :access_token=>'[access_token]', :http_adapter=>Yammer::Connection, :connection_options=>{ :max_redirects=>5, :use_ssl=>true }}
94
+ #> {:site_url=>"https://www.yammer.com", :client_id=>'[client_id]', :client_secret=>'[client_secret]', :access_token=>nil, :http_adapter=>Yammer::Connection, :connection_options=>{ :max_redirects=>5, :use_ssl=>true }}
109
95
  ```
96
+ Take note of the fact that the `access_token` is nil. This will need to be set and, in the next section, we will see how to do this.
110
97
 
111
98
  ## Usage
112
99
 
113
- `yammer-client` provides two ways to access Yammer's API. One of these ways is by using HTTP helper methods on and instance of `Yammer::Client`. The other
114
- way is using methods on the object models that come bundled with this gem.
100
+ - This gem offers three ways to interact Yammer's API:
101
+ - Calling methods on the Yammer i.e `Yammer`
102
+ - Calling methods on an instance of `Yammer::Client`.
103
+ - Calling methods on the custom object models (Experimental)
115
104
 
116
- ### Using the client
105
+ ### Calling methods on the Yammer module
106
+ In order for this to work, you will need to set up your access_token. This assumes that you already configured the client with your default options as was described above.
117
107
 
118
- 1. Create an instance of the Yammer client
108
+ ```ruby
109
+ # set up your access token
110
+ Yammer.configure do |c|
111
+ c.access_token = '[access_token]'
112
+ end
113
+ #=> <Yammer: {:http_adapter=>Yammer::HttpAdapter, :client_secret=>"[client_secret]", :access_token=>"[access_token]", :site_url=>"https://www.yammer.com", :connection_options=>{:max_redirects=>5, :verify_ssl=>true}, :default_headers=>{"Accept"=>"application/json", "User-Agent"=>"Yammer Ruby Gem 0.1.8"}, :client_id=>"[client_id]"}>
119
114
 
120
- ```ruby
121
- yamr = Yammer::Client.new(
122
- :client_id => 'vAbMcg9qjgKsp4jjpm1pw',
123
- :client_secret => 'Wn0kp7Lu0TCY4GtZWkmSsqGErg10DmMADyjWkf2U',
124
- :access_token => 'HqsKG3ka9Uls2DxahNi78A'
125
- )
115
+ # get the current user
116
+ Yammer.current_user
126
117
  ```
127
118
 
128
- 2. Call methods on the instance:
119
+ ### Calling methods on an instance of Yammer::Client
120
+ NOTE: Use this if you wish to create multiple client instances with diffrent client_id, client_secret and access token.
121
+ If your application uses a signle pair of client_id and client_secret credentials, you ONLY need to sepecify the access token
129
122
 
130
- **User**
131
-
132
- *find a user by email*
123
+ - Create an instance of the Yammer client
133
124
 
134
125
  ```ruby
135
- yamr.get_user_by_email('user@example.com')
136
- #<Yammer::ApiResponse:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
137
- ```
126
+ # create a client instance using the access token: HqsKG3ka9Uls2DxahNi78A
127
+ yamr = Yammer::Client.new(:access_token => 'HqsKG3ka9Uls2DxahNi78A')
138
128
 
139
- *find a user by user id*
140
129
 
141
- ```ruby
142
- yamr.get_user('1588')
143
- #<Yammer::ApiResponse:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
144
- ```
130
+ # create multiple clients, each using a different access token
131
+ client1 = Yammer::Client.new(:access_token => 'fG4mhFDf2GUUptztU0Qo9g')
145
132
 
146
- *get the current user*
133
+ client2 = Yammer::Client.new(:access_token => 'ruZy4vFYyTWqnx7adO9ow')
147
134
 
148
- ```ruby
149
- yamr.current_user
150
- #<Yammer::ApiResponse:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
151
135
  ```
152
136
 
137
+ - Call methods on the instance:
153
138
 
154
- **Message**
139
+ - **User**
155
140
 
156
- *post a update as the current user*
141
+ - *find a user by email*
157
142
 
158
- ```ruby
159
- yamr.create_message('status update')
160
- #<Yammer::ApiResponse:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
161
- ```
143
+ ```ruby
144
+ yamr.get_user_by_email('user@example.com')
145
+ #<Yammer::ApiResponse:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
146
+ ```
162
147
 
163
- *send a private message to another Yammer user*
148
+ - *find a user by user id*
164
149
 
165
- ```ruby
166
- yamr.create_message('private message', :direct_to_id => 24)
167
- #<Yammer::ApiResponse:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
168
- ```
150
+ ```ruby
151
+ yamr.get_user('1588')
152
+ #<Yammer::ApiResponse:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
153
+ ```
169
154
 
170
- *send a message with an Open Graph Object as an attachment*
155
+ - *get the current user*
171
156
 
172
- ```ruby
173
- yamr.create_message('here is my open graph object', :og_url => "https://www.yammer.com/example/graph/31415926")
174
- #<Yammer::ApiResponse:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
175
- ```
157
+ ```ruby
158
+ yamr.current_user
159
+ #<Yammer::ApiResponse:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
160
+ ```
176
161
 
162
+ - **Message**
177
163
 
178
- **Search**
164
+ - *post a update as the current user*
179
165
 
180
- *search for a term within the context of current user*
166
+ ```ruby
167
+ yamr.create_message('status update')
168
+ #<Yammer::ApiResponse:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
169
+ ```
181
170
 
182
- ```ruby
183
- yamr.search(:search => 'thekev', :model_types => 'users;groups')
184
- #<Yammer::ApiResponse:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
185
- ```
171
+ - *send a private message to another Yammer user*
186
172
 
187
- **Thread**
173
+ ```ruby
174
+ yamr.create_message('private message', :direct_to_id => 24)
175
+ #<Yammer::ApiResponse:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
176
+ ```
188
177
 
189
- *fetch a thread with a given id*
178
+ - *send a message with an Open Graph Object as an attachment*
190
179
 
191
- ```ruby
192
- yamr.get_thread(42)
193
- #<Yammer::ApiResponse:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
194
- ```
180
+ ```ruby
181
+ yamr.create_message('here is my open graph object', :og_url => "https://www.yammer.com/example/graph/31415926")
182
+ #<Yammer::ApiResponse:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
183
+ ```
184
+
185
+
186
+ - **Search**
187
+
188
+ - *search for a term within the context of current user*
189
+
190
+ ```ruby
191
+ yamr.search(:search => 'thekev', :model_types => 'users;groups')
192
+ #<Yammer::ApiResponse:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
193
+ ```
194
+
195
+ - **Thread**
196
+
197
+ - *fetch a thread with a given id*
198
+
199
+ ```ruby
200
+ yamr.get_thread(42)
201
+ #<Yammer::ApiResponse:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
202
+ ```
203
+
204
+ - **Activity**
205
+
206
+ - *create and post an activity*
207
+
208
+ ```ruby
209
+ yamr.create_activity(
210
+ activity: {
211
+ actor: {
212
+ name: 'John Doe',
213
+ email: 'jdoe@yammer-inc.com'
214
+ },
215
+ action: 'create',
216
+ object: {
217
+ url: 'www.example.com',
218
+ title: 'Example event name',
219
+ },
220
+ message: 'Posting activity',
221
+ users: [{
222
+ name: 'Example Invitee',
223
+ email: 'example@yammer-inc.com'
224
+ }]
225
+ }
226
+ )
227
+ #<Yammer::ApiResponse:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
228
+ ```
195
229
 
196
230
 
197
231
  ### Using the object models (Experimental)
@@ -199,56 +233,56 @@ yamr.get_thread(42)
199
233
  The object model is an abstraction that makes it easy to manipulate the JSON data return when accessing Yammer's API. Each model has accessor methods for all keys contained in the JSON response for a given model type.
200
234
 
201
235
 
202
- **User**
236
+ - **User**
203
237
 
204
- *get the current user*
238
+ - *get the current user*
205
239
 
206
240
 
207
- ```ruby
208
- u = Yammer::User.current
209
- #> <Yammer::User:0x007f9f4b0c39c8>
241
+ ```ruby
242
+ u = Yammer::User.current
243
+ #> <Yammer::User:0x007f9f4b0c39c8>
210
244
 
211
- u.full_name
212
- #> 'Kevin Mutyaba'
245
+ u.full_name
246
+ #> 'Kevin Mutyaba'
213
247
 
214
- u.update!(:job_title => 'k0dR')
215
- ```
248
+ u.update!(:job_title => 'k0dR')
249
+ ```
216
250
 
217
251
 
218
- **Thread**
252
+ - **Thread**
219
253
 
220
- *fetch a thread with a given id*
254
+ - *fetch a thread with a given id*
221
255
 
222
- ```ruby
223
- t = Yammer::Thread.get(3)
224
- ```
256
+ ```ruby
257
+ t = Yammer::Thread.get(3)
258
+ ```
225
259
 
226
- View the participants in the thread
260
+ View the participants in the thread
227
261
 
228
- ```ruby
229
- parts = t.participants
230
- #> [{:type=>"user", :id=>18}, {:type=>"user", :id=>64}]
231
- ```
262
+ ```ruby
263
+ parts = t.participants
264
+ #> [{:type=>"user", :id=>18}, {:type=>"user", :id=>64}]
265
+ ```
232
266
 
233
- View the participants in the thread as user object models
267
+ View the participants in the thread as user object models
234
268
 
235
- ```ruby
236
- peepl = t.people
237
- #> [#<Yammer::User:0x007f9f4c086630 @modified_attributes={}, @attrs={}, @new_record=false, @id=18>, #<Yammer::User:0x007f9f4c086568 @modified_attributes={}, @attrs={}, @new_record=false, @id=64>]
238
- ```
269
+ ```ruby
270
+ peepl = t.people
271
+ #> [#<Yammer::User:0x007f9f4c086630 @modified_attributes={}, @attrs={}, @new_record=false, @id=18>, #<Yammer::User:0x007f9f4c086568 @modified_attributes={}, @attrs={}, @new_record=false, @id=64>]
272
+ ```
239
273
 
240
- Object models are lazyly loaded. Calling an accessor on a model will hydrate it
274
+ Object models are lazyly loaded. Calling an accessor on a model will hydrate it
241
275
 
242
- ```ruby
243
- peepl[0]
244
- #> #<Yammer::User:0x007f9f4c086568 @modified_attributes={}, @attrs={}, @new_record=false, @id=18>
276
+ ```ruby
277
+ peepl[0]
278
+ #> #<Yammer::User:0x007f9f4c086568 @modified_attributes={}, @attrs={}, @new_record=false, @id=18>
245
279
 
246
- peepl[0].permalink
247
- #> 'thekev'
280
+ peepl[0].permalink
281
+ #> 'thekev'
248
282
 
249
- peepl[0]
250
- #=> #<Yammer::User:0x007f9f4c086568 @modified_attributes={}, @attrs={:last_name=>"Mutyaba", :network_id=>1, :first_name=>"Kevin", :id => 18, :permalink=>"thekev" }, @network_id=1, @first_name="Kev", @full_name="Tiaba", @permalink="thekev", @id=18 >
251
- ```
283
+ peepl[0]
284
+ #=> #<Yammer::User:0x007f9f4c086568 @modified_attributes={}, @attrs={:last_name=>"Mutyaba", :network_id=>1, :first_name=>"Kevin", :id => 18, :permalink=>"thekev" }, @network_id=1, @first_name="Kev", @full_name="Tiaba", @permalink="thekev", @id=18 >
285
+ ```
252
286
 
253
287
  ## Supported Ruby Versions
254
288
  This library aims to support and is [tested against][travis] the following Ruby
@@ -0,0 +1,61 @@
1
+ # Copyright (c) Microsoft Corporation
2
+ # All rights reserved.
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR
8
+ # CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
9
+ # WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE,
10
+ # FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
11
+
12
+ # See the Apache Version 2.0 License for specific language governing
13
+ # permissions and limitations under the License.
14
+
15
+ module Yammer
16
+ module Api
17
+ module Activity
18
+
19
+ # @see https://developer.yammer.com/opengraph
20
+ # @rate_limited Yes
21
+ # @authentication Requires user context
22
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
23
+ # @return [Yammer::ApiResponse]
24
+ # @param [Hash] opts the opts to post the activity with
25
+ # @option opts [Hash] actor The user performing the action
26
+ # @option actor [String] :email
27
+ # @option actor [String] :name
28
+ # @option opts [Hash] object The object on which the action is being performed
29
+ # @option object [String] :url
30
+ # @option object [String] :title
31
+ # @option opts [String] :action
32
+ # @option opts [Array<Hash>] :users
33
+ # @option users [String] :name
34
+ # @option users [String] :email
35
+ # @option opts [Boolean] :private
36
+ # @option opts [String] :message
37
+ # @example Create a new public group
38
+ # Yammer.create_activity(
39
+ # activity: {
40
+ # actor: {
41
+ # name: 'John Doe',
42
+ # email: 'jdoe@yammer-inc.com'
43
+ # },
44
+ # action: 'create',
45
+ # object: {
46
+ # url: 'www.example.com',
47
+ # title: 'Example name',
48
+ # }
49
+ # },
50
+ # message: 'Posting activity',
51
+ # users: [{
52
+ # name: 'Example Invitee',
53
+ # email: 'example@yammer-inc.com'
54
+ # }]
55
+ # }
56
+ def create_activity(opts = {})
57
+ post('/api/v1/activity', opts)
58
+ end
59
+ end
60
+ end
61
+ end
@@ -195,6 +195,32 @@ module Yammer
195
195
  get("/api/v1/messages/liked_by/#{id}", opts)
196
196
  end
197
197
 
198
+ # @see https://developer.yammer.com/restapi/#rest-messages
199
+ # @api_path /api/v1/messages/liked_by/current.json?message_id=[:id]
200
+ # @rate_limited Yes
201
+ # @authentication Requires user context
202
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
203
+ # @return [Yammer::ApiResponse]
204
+ # @param id [Integer] the ID of the message for which you want the current user to mark as liked
205
+ # @example Marks the specified message as liked by the current user
206
+ # msgs = Yammer.like_message(10)
207
+ def like_message(id)
208
+ post("/api/v1/messages/liked_by/current.json?message_id=#{id}", {})
209
+ end
210
+
211
+ # @see https://developer.yammer.com/restapi/#rest-messages
212
+ # @api_path /api/v1/messages/liked_by/current.json?message_id=[:id]
213
+ # @rate_limited Yes
214
+ # @authentication Requires user context
215
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
216
+ # @return [Yammer::ApiResponse]
217
+ # @param id [Integer] the ID of the message for which you want the current user to remove the like mark
218
+ # @example Removes the like mark on the specified message for the current user
219
+ # msgs = Yammer.like_message(10)
220
+ def unlike_message(id)
221
+ delete("/api/v1/messages/liked_by/current.json?message_id=#{id}", {})
222
+ end
223
+
198
224
  # @see https://developer.yammer.com/restapi/#rest-messages
199
225
  # @api_path /api/v1/messages
200
226
  # @rate_limited Yes
data/lib/yammer/api.rb CHANGED
@@ -12,6 +12,7 @@
12
12
  # See the Apache Version 2.0 License for specific language governing
13
13
  # permissions and limitations under the License.
14
14
 
15
+ require 'yammer/api/activity'
15
16
  require 'yammer/api/user'
16
17
  require 'yammer/api/group'
17
18
  require 'yammer/api/group_membership'
@@ -26,4 +27,4 @@ require 'yammer/api/notification'
26
27
  require 'yammer/api/pending_attachment'
27
28
  require 'yammer/api/invitation'
28
29
  require 'yammer/api/subscription'
29
- require 'yammer/api/open_graph_object'
30
+ require 'yammer/api/open_graph_object'
data/lib/yammer/client.rb CHANGED
@@ -35,6 +35,7 @@ module Yammer
35
35
  include Yammer::Api::PendingAttachment
36
36
  include Yammer::Api::Subscription
37
37
  include Yammer::Api::OpenGraphObject
38
+ include Yammer::Api::Activity
38
39
 
39
40
  attr_reader :site_url, :default_headers, :connection_options
40
41
 
data/lib/yammer/group.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  # Copyright (c) Microsoft Corporation
2
2
  # All rights reserved.
3
- # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
5
+ # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
6
  #
7
- # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR
8
- # CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
7
+ # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR
8
+ # CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
9
9
  # WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE,
10
- # FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
10
+ # FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
11
11
 
12
12
  # See the Apache Version 2.0 License for specific language governing
13
13
  # permissions and limitations under the License.
@@ -15,13 +15,13 @@
15
15
  module Yammer
16
16
  class Group < Yammer::Base
17
17
 
18
- attr_accessor_deffered :show_in_directory, :privacy, :description, :creator_type,
19
- :creator_id, :mugshot_id, :stats, :state, :web_url, :name, :created_at, :type,
18
+ attr_accessor_deffered :show_in_directory, :privacy, :description, :creator_type,
19
+ :creator_id, :mugshot_id, :stats, :state, :web_url, :name, :created_at, :type,
20
20
  :mugshot_url, :url, :full_name, :mugshot_url_template, :description
21
21
 
22
22
  # @!scope class
23
23
  def self.create(params={})
24
- result = api_handler.create_group(params)
24
+ api_handler.create_group(params)
25
25
  end
26
26
  end
27
- end
27
+ end
@@ -15,7 +15,7 @@
15
15
  module Yammer
16
16
  class Version
17
17
  MAJOR = 1 unless defined? Yammer::MAJOR
18
- MINOR = 0 unless defined? Yammer::MINOR
18
+ MINOR = 1 unless defined? Yammer::MINOR
19
19
  PATCH = 0 unless defined? Yammer::PATCH
20
20
  PRE = nil unless defined? Yammer::PRE
21
21
 
data/lib/yammer.rb CHANGED
@@ -44,4 +44,7 @@ module Yammer
44
44
  end
45
45
  end
46
46
  end
47
+
48
+ Yam = Yammer
49
+
47
50
  Yammer.reset!
@@ -0,0 +1,60 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ # Copyright (c) Microsoft Corporation
4
+ # All rights reserved.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
13
+ # ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
14
+ # IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
15
+ # PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
16
+ #
17
+ # See the Apache Version 2.0 License for specific language governing
18
+ # permissions and limitations under the License.
19
+
20
+ require File.expand_path('../../spec_helper', __FILE__)
21
+ require 'ostruct'
22
+
23
+ describe Yammer::Api::Activity do
24
+
25
+ before :all do
26
+ @client = Yammer::Client.new(
27
+ :site_url => 'https://yammer.com',
28
+ :client_id => 'PRbTcg9qjgKsp4jjpm1pw',
29
+ :client_secret => 'Xn7kp7Ly0TCY4GtZWkmSsqGEPg10DmMADyjWkf2U',
30
+ :access_token => 'TolNOFka9Uls2DxahNi78A'
31
+ )
32
+ end
33
+
34
+ subject { @client }
35
+
36
+ describe '#create_activity' do
37
+ it 'should post activity' do
38
+ params = {
39
+ activity: {
40
+ actor: {
41
+ name: 'John Doe',
42
+ email: 'jdoe@yammer-inc.com'
43
+ },
44
+ action: 'create',
45
+ object: {
46
+ url: 'www.example.com',
47
+ title: 'Example event name',
48
+ }
49
+ },
50
+ message: 'Posting activity',
51
+ users: [{
52
+ name: 'Example Invitee',
53
+ email: 'example@yammer-inc.com'
54
+ }]
55
+ }
56
+ subject.should_receive(:post).with('/api/v1/activity', params)
57
+ @client.create_activity(params)
58
+ end
59
+ end
60
+ end
@@ -127,6 +127,20 @@ describe Yammer::Api::Message do
127
127
  end
128
128
  end
129
129
 
130
+ describe '#like_message' do
131
+ it 'should like the message as a the specified user' do
132
+ subject.should_receive(:post).with('/api/v1/messages/liked_by/current.json?message_id=97', {})
133
+ subject.like_message(97)
134
+ end
135
+ end
136
+
137
+ describe '#unlike_message' do
138
+ it 'should unlike the message as a the specified user' do
139
+ subject.should_receive(:delete).with('/api/v1/messages/liked_by/current.json?message_id=97', {})
140
+ subject.unlike_message(97)
141
+ end
142
+ end
143
+
130
144
  describe '#messages_in_thread' do
131
145
  it 'should fetch messages in thread' do
132
146
  subject.should_receive(:get).with('/api/v1/messages/in_thread/97', {})
@@ -25,38 +25,38 @@ describe Yammer::Api::User do
25
25
  before :all do
26
26
  @client = Yammer::Client.new(
27
27
  :site_url => 'https://yammer.com',
28
- :client_id => "PRbTcg9qjgKsp4jjpm1pw",
29
- :client_secret => "Xn7kp7Ly0TCY4GtZWkmSsqGEPg10DmMADyjWkf2U",
30
- :access_token => "TolNOFka9Uls2DxahNi78A"
28
+ :client_id => 'PRbTcg9qjgKsp4jjpm1pw',
29
+ :client_secret => 'Xn7kp7Ly0TCY4GtZWkmSsqGEPg10DmMADyjWkf2U',
30
+ :access_token => 'TolNOFka9Uls2DxahNi78A'
31
31
  )
32
32
  end
33
33
 
34
34
  subject { @client }
35
35
 
36
- describe "users" do
37
- it "makes an http request" do
36
+ describe 'all_users' do
37
+ it 'makes an http request' do
38
38
  @client.should_receive(:get).with('/api/v1/users', { :page => 1, :letter => 'm' })
39
39
  @client.all_users({:page => 1, :letter => 'm'})
40
40
  end
41
41
  end
42
42
 
43
- describe "create_user" do
44
- it "makes an http request" do
43
+ describe 'create_user' do
44
+ it 'makes an http request' do
45
45
  params = {:first_name => 'john', :last_name => 'doe', :email => 'jdoe@yammer-inc.com'}
46
46
  @client.should_receive(:post).with('/api/v1/users', params)
47
47
  @client.create_user(params)
48
48
  end
49
49
  end
50
50
 
51
- describe "get_user" do
52
- it "makes an http request" do
51
+ describe 'get_user' do
52
+ it 'makes an http request' do
53
53
  @client.should_receive(:get).with('/api/v1/users/1')
54
54
  @client.get_user(1)
55
55
  end
56
56
  end
57
57
 
58
- describe "update_user" do
59
- it "makes an http request" do
58
+ describe 'update_user' do
59
+ it 'makes an http request' do
60
60
  params = {:first_name => 'jane', :last_name => 'smith'}
61
61
  @client.should_receive(:put).with('/api/v1/users/1', params)
62
62
  @client.update_user(1, params)
@@ -71,38 +71,38 @@ describe Yammer::Api::User do
71
71
  end
72
72
  end
73
73
 
74
- describe "delete_user" do
75
- it "makes an http request" do
74
+ describe 'delete_user' do
75
+ it 'makes an http request' do
76
76
  @client.should_receive(:delete).with('/api/v1/users/1')
77
77
  @client.delete_user(1)
78
78
  end
79
79
  end
80
80
 
81
- describe "user_by_email" do
82
- it "makes an http request" do
81
+ describe 'get_user_by_email' do
82
+ it 'makes an http request' do
83
83
  @client.should_receive(:get).with('/api/v1/users/by_email', :email => 'bob@yammer-inc.com')
84
84
  @client.get_user_by_email('bob@yammer-inc.com')
85
85
  end
86
86
  end
87
87
 
88
- describe "current_user" do
89
- it "makes an http request" do
88
+ describe 'current_user' do
89
+ it 'makes an http request' do
90
90
  @client.should_receive(:get).with('/api/v1/users/current')
91
91
  @client.current_user
92
92
  end
93
93
  end
94
94
 
95
- describe "users_following" do
96
- it "makes an http request" do
95
+ describe 'users_following' do
96
+ it 'makes an http request' do
97
97
  @client.should_receive(:get).with('/api/v1/users/following/3')
98
98
  @client.users_following(3)
99
99
  end
100
100
  end
101
101
 
102
- describe "users_followed_by" do
103
- it "makes an http request" do
102
+ describe 'users_followed_by' do
103
+ it 'makes an http request' do
104
104
  @client.should_receive(:get).with('/api/v1/users/followed_by/4')
105
105
  @client.users_followed_by(4)
106
106
  end
107
107
  end
108
- end
108
+ end
data/yam.gemspec CHANGED
@@ -25,10 +25,11 @@ Gem::Specification.new do |s|
25
25
  s.name = 'yam'
26
26
  s.version = Yammer::Version
27
27
 
28
- s.date = %q{2013-06-18}
28
+ s.date = %q{2013-11-26}
29
29
  s.summary = "Yammer API Client"
30
+
30
31
  s.description = "A Ruby wrapper for accessing Yammer's REST API"
31
- s.authors = ["Kevin Mutyaba"]
32
+ s.authors = ["Kevin Mutyaba", "Jessie A. Young", "Jason Nochlin"]
32
33
  s.email = %q{kmutyaba@yammer-inc.com}
33
34
  s.homepage = 'http://yammer.github.io/yam'
34
35
  s.rubygems_version = Yammer::Version
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,19 +1,15 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: yam
3
- version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 0
10
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Kevin Mutyaba
8
+ - Jessie A. Young
9
+ - Jason Nochlin
14
10
  autorequire:
15
11
  bindir: bin
16
- cert_chain:
12
+ cert_chain:
17
13
  - |
18
14
  -----BEGIN CERTIFICATE-----
19
15
  MIIDMjCCAhqgAwIBAgIBADANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAh0aWFi
@@ -35,141 +31,126 @@ cert_chain:
35
31
  B+kZ9/4dAvmKkr2NPSoxBQtO7Rz0HDNLtjMxkXbQUWMDsGnB6Kk1WUBb/w3kQ9Ah
36
32
  JgIHF4cG
37
33
  -----END CERTIFICATE-----
38
-
39
- date: 2013-06-18 00:00:00 Z
40
- dependencies:
41
- - !ruby/object:Gem::Dependency
34
+ date: 2013-11-26 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
42
37
  name: oj
43
- prerelease: false
44
- requirement: &id001 !ruby/object:Gem::Requirement
45
- none: false
46
- requirements:
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
47
40
  - - ~>
48
- - !ruby/object:Gem::Version
49
- hash: 27
50
- segments:
51
- - 2
52
- - 0
53
- - 10
41
+ - !ruby/object:Gem::Version
54
42
  version: 2.0.10
55
43
  type: :runtime
56
- version_requirements: *id001
57
- - !ruby/object:Gem::Dependency
58
- name: multi_json
59
44
  prerelease: false
60
- requirement: &id002 !ruby/object:Gem::Requirement
61
- none: false
62
- requirements:
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
63
47
  - - ~>
64
- - !ruby/object:Gem::Version
65
- hash: 9
66
- segments:
67
- - 1
68
- - 3
69
- version: "1.3"
48
+ - !ruby/object:Gem::Version
49
+ version: 2.0.10
50
+ - !ruby/object:Gem::Dependency
51
+ name: multi_json
52
+ requirement: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: '1.3'
70
57
  type: :runtime
71
- version_requirements: *id002
72
- - !ruby/object:Gem::Dependency
73
- name: rest-client
74
58
  prerelease: false
75
- requirement: &id003 !ruby/object:Gem::Requirement
76
- none: false
77
- requirements:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
78
61
  - - ~>
79
- - !ruby/object:Gem::Version
80
- hash: 1
81
- segments:
82
- - 1
83
- - 6
84
- - 7
62
+ - !ruby/object:Gem::Version
63
+ version: '1.3'
64
+ - !ruby/object:Gem::Dependency
65
+ name: rest-client
66
+ requirement: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
85
70
  version: 1.6.7
86
71
  type: :runtime
87
- version_requirements: *id003
88
- - !ruby/object:Gem::Dependency
89
- name: addressable
90
72
  prerelease: false
91
- requirement: &id004 !ruby/object:Gem::Requirement
92
- none: false
93
- requirements:
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.6.7
78
+ - !ruby/object:Gem::Dependency
79
+ name: addressable
80
+ requirement: !ruby/object:Gem::Requirement
81
+ requirements:
94
82
  - - ~>
95
- - !ruby/object:Gem::Version
96
- hash: 5
97
- segments:
98
- - 2
99
- - 3
100
- - 3
83
+ - !ruby/object:Gem::Version
101
84
  version: 2.3.3
102
85
  type: :runtime
103
- version_requirements: *id004
104
- - !ruby/object:Gem::Dependency
105
- name: rake
106
86
  prerelease: false
107
- requirement: &id005 !ruby/object:Gem::Requirement
108
- none: false
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- hash: 3
113
- segments:
114
- - 0
115
- version: "0"
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ~>
90
+ - !ruby/object:Gem::Version
91
+ version: 2.3.3
92
+ - !ruby/object:Gem::Dependency
93
+ name: rake
94
+ requirement: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
116
99
  type: :development
117
- version_requirements: *id005
118
- - !ruby/object:Gem::Dependency
119
- name: rspec
120
100
  prerelease: false
121
- requirement: &id006 !ruby/object:Gem::Requirement
122
- none: false
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- hash: 3
127
- segments:
128
- - 0
129
- version: "0"
101
+ version_requirements: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ - !ruby/object:Gem::Dependency
107
+ name: rspec
108
+ requirement: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
130
113
  type: :development
131
- version_requirements: *id006
132
- - !ruby/object:Gem::Dependency
133
- name: simplecov
134
114
  prerelease: false
135
- requirement: &id007 !ruby/object:Gem::Requirement
136
- none: false
137
- requirements:
138
- - - ">="
139
- - !ruby/object:Gem::Version
140
- hash: 1
141
- segments:
142
- - 0
143
- - 7
144
- - 1
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ - !ruby/object:Gem::Dependency
121
+ name: simplecov
122
+ requirement: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - '>='
125
+ - !ruby/object:Gem::Version
145
126
  version: 0.7.1
146
127
  type: :development
147
- version_requirements: *id007
148
- - !ruby/object:Gem::Dependency
149
- name: webmock
150
128
  prerelease: false
151
- requirement: &id008 !ruby/object:Gem::Requirement
152
- none: false
153
- requirements:
154
- - - ">="
155
- - !ruby/object:Gem::Version
156
- hash: 51
157
- segments:
158
- - 1
159
- - 9
160
- - 0
129
+ version_requirements: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - '>='
132
+ - !ruby/object:Gem::Version
133
+ version: 0.7.1
134
+ - !ruby/object:Gem::Dependency
135
+ name: webmock
136
+ requirement: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - '>='
139
+ - !ruby/object:Gem::Version
161
140
  version: 1.9.0
162
141
  type: :development
163
- version_requirements: *id008
142
+ prerelease: false
143
+ version_requirements: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - '>='
146
+ - !ruby/object:Gem::Version
147
+ version: 1.9.0
164
148
  description: A Ruby wrapper for accessing Yammer's REST API
165
149
  email: kmutyaba@yammer-inc.com
166
150
  executables: []
167
-
168
151
  extensions: []
169
-
170
152
  extra_rdoc_files: []
171
-
172
- files:
153
+ files:
173
154
  - .gitignore
174
155
  - .travis.yml
175
156
  - .yardopts
@@ -183,6 +164,7 @@ files:
183
164
  - certs/public.pem
184
165
  - lib/yammer.rb
185
166
  - lib/yammer/api.rb
167
+ - lib/yammer/api/activity.rb
186
168
  - lib/yammer/api/autocomplete.rb
187
169
  - lib/yammer/api/group.rb
188
170
  - lib/yammer/api/group_membership.rb
@@ -214,6 +196,7 @@ files:
214
196
  - lib/yammer/thread.rb
215
197
  - lib/yammer/user.rb
216
198
  - lib/yammer/version.rb
199
+ - spec/api/activity_spec.rb
217
200
  - spec/api/autocomplete_spec.rb
218
201
  - spec/api/group_membership_spec.rb
219
202
  - spec/api/group_spec.rb
@@ -253,39 +236,31 @@ files:
253
236
  - spec/spec_helper.rb
254
237
  - yam.gemspec
255
238
  homepage: http://yammer.github.io/yam
256
- licenses:
239
+ licenses:
257
240
  - MIT
258
- post_install_message: " Thanks for installing! For API help go to http://developer.yammer.com "
241
+ metadata: {}
242
+ post_install_message: ' Thanks for installing! For API help go to http://developer.yammer.com '
259
243
  rdoc_options: []
260
-
261
- require_paths:
244
+ require_paths:
262
245
  - lib
263
- required_ruby_version: !ruby/object:Gem::Requirement
264
- none: false
265
- requirements:
266
- - - ">="
267
- - !ruby/object:Gem::Version
268
- hash: 3
269
- segments:
270
- - 0
271
- version: "0"
272
- required_rubygems_version: !ruby/object:Gem::Requirement
273
- none: false
274
- requirements:
275
- - - ">="
276
- - !ruby/object:Gem::Version
277
- hash: 3
278
- segments:
279
- - 0
280
- version: "0"
246
+ required_ruby_version: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - '>='
249
+ - !ruby/object:Gem::Version
250
+ version: '0'
251
+ required_rubygems_version: !ruby/object:Gem::Requirement
252
+ requirements:
253
+ - - '>='
254
+ - !ruby/object:Gem::Version
255
+ version: '0'
281
256
  requirements: []
282
-
283
257
  rubyforge_project:
284
- rubygems_version: 1.8.24
258
+ rubygems_version: 2.1.10
285
259
  signing_key:
286
- specification_version: 3
260
+ specification_version: 4
287
261
  summary: Yammer API Client
288
- test_files:
262
+ test_files:
263
+ - spec/api/activity_spec.rb
289
264
  - spec/api/autocomplete_spec.rb
290
265
  - spec/api/group_membership_spec.rb
291
266
  - spec/api/group_spec.rb
@@ -323,4 +298,3 @@ test_files:
323
298
  - spec/model/thread_spec.rb
324
299
  - spec/model/user_spec.rb
325
300
  - spec/spec_helper.rb
326
- has_rdoc:
metadata.gz.sig CHANGED
Binary file