yam 1.1.0 → 2.0.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.travis.yml +1 -2
- data/CHANGELOG.md +7 -1
- data/README.md +6 -7
- data/lib/yammer/http_adapter.rb +65 -65
- data/lib/yammer/resources/base.rb +210 -0
- data/lib/yammer/{group.rb → resources/group.rb} +9 -7
- data/lib/yammer/{group_membership.rb → resources/group_membership.rb} +7 -5
- data/lib/yammer/resources/identity_map.rb +58 -0
- data/lib/yammer/resources/message.rb +34 -0
- data/lib/yammer/{message.rb → resources/message_body.rb} +10 -13
- data/lib/yammer/{pending_attachment.rb → resources/pending_attachment.rb} +0 -0
- data/lib/yammer/resources/thread.rb +60 -0
- data/lib/yammer/resources/user.rb +67 -0
- data/lib/yammer/{message_body.rb → resources.rb} +8 -13
- data/lib/yammer/version.rb +2 -2
- data/lib/yammer.rb +1 -7
- data/spec/{model → resources}/base_spec.rb +2 -2
- data/spec/{model → resources}/group_membership_spec.rb +2 -2
- data/spec/{model → resources}/group_spec.rb +2 -2
- data/spec/{identity_map_spec.rb → resources/identity_map_spec.rb} +6 -6
- data/spec/{model → resources}/message_spec.rb +2 -2
- data/spec/{model → resources}/thread_spec.rb +7 -7
- data/spec/{model → resources}/user_spec.rb +7 -7
- data.tar.gz.sig +0 -0
- metadata +25 -24
- metadata.gz.sig +0 -0
- data/lib/yammer/base.rb +0 -208
- data/lib/yammer/identity_map.rb +0 -56
- data/lib/yammer/thread.rb +0 -58
- data/lib/yammer/user.rb +0 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2374b08700b4fa2d18344496c086d0b8480107da
|
4
|
+
data.tar.gz: 6720b27fa642e2697352f125ee27a9005cae2a9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6f739f3511bcc24e9254a444ddc5ee27b35c08dfd1029e34565664a36a7004e390bfe37bf6a13cf3a064fffe2f3c4291985c9c5ca2504bc2082c276bf85e0d9
|
7
|
+
data.tar.gz: bc52ae55b4c8fbec4b6652fee1287c3826e9123bb00ffe46e93d106f0b6187d15eb5c7f1e3864804d3388a1041ab45621ab7236d2cb8fad58f83a1cb93046b5c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
+
1.1.0
|
2
|
+
====================================
|
3
|
+
- added support for activity api
|
4
|
+
- added support for liking and unliking messages
|
5
|
+
- small improvements to documentation
|
6
|
+
|
1
7
|
1.0.0
|
2
8
|
====================================
|
3
9
|
- Customized fork of yammer-client (https://github.com/tiabas/yammer-client)
|
4
10
|
|
5
11
|
0.0.6
|
6
12
|
====================================
|
7
|
-
- Alpha
|
13
|
+
- Alpha
|
data/README.md
CHANGED
@@ -239,8 +239,8 @@ The object model is an abstraction that makes it easy to manipulate the JSON dat
|
|
239
239
|
|
240
240
|
|
241
241
|
```ruby
|
242
|
-
u = Yammer::User.current
|
243
|
-
#> <Yammer::User:0x007f9f4b0c39c8>
|
242
|
+
u = Yammer::Resources::User.current
|
243
|
+
#> <Yammer::Resources::User:0x007f9f4b0c39c8>
|
244
244
|
|
245
245
|
u.full_name
|
246
246
|
#> 'Kevin Mutyaba'
|
@@ -254,7 +254,7 @@ The object model is an abstraction that makes it easy to manipulate the JSON dat
|
|
254
254
|
- *fetch a thread with a given id*
|
255
255
|
|
256
256
|
```ruby
|
257
|
-
t = Yammer::Thread.get(3)
|
257
|
+
t = Yammer::Resources::Thread.get(3)
|
258
258
|
```
|
259
259
|
|
260
260
|
View the participants in the thread
|
@@ -268,27 +268,26 @@ The object model is an abstraction that makes it easy to manipulate the JSON dat
|
|
268
268
|
|
269
269
|
```ruby
|
270
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>]
|
271
|
+
#> [#<Yammer::Resources::User:0x007f9f4c086630 @modified_attributes={}, @attrs={}, @new_record=false, @id=18>, #<Yammer::Resources::User:0x007f9f4c086568 @modified_attributes={}, @attrs={}, @new_record=false, @id=64>]
|
272
272
|
```
|
273
273
|
|
274
274
|
Object models are lazyly loaded. Calling an accessor on a model will hydrate it
|
275
275
|
|
276
276
|
```ruby
|
277
277
|
peepl[0]
|
278
|
-
#> #<Yammer::User:0x007f9f4c086568 @modified_attributes={}, @attrs={}, @new_record=false, @id=18>
|
278
|
+
#> #<Yammer::Resources::User:0x007f9f4c086568 @modified_attributes={}, @attrs={}, @new_record=false, @id=18>
|
279
279
|
|
280
280
|
peepl[0].permalink
|
281
281
|
#> 'thekev'
|
282
282
|
|
283
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 >
|
284
|
+
#=> #<Yammer::Resources::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
285
|
```
|
286
286
|
|
287
287
|
## Supported Ruby Versions
|
288
288
|
This library aims to support and is [tested against][travis] the following Ruby
|
289
289
|
version:
|
290
290
|
|
291
|
-
* Ruby 1.8.7
|
292
291
|
* Ruby 1.9.2
|
293
292
|
* Ruby 1.9.3
|
294
293
|
* Ruby 2.0.0
|
data/lib/yammer/http_adapter.rb
CHANGED
@@ -17,84 +17,84 @@ require 'multi_json'
|
|
17
17
|
require 'addressable/uri'
|
18
18
|
|
19
19
|
module Yammer
|
20
|
-
|
20
|
+
class HttpAdapter
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
def self.log=(output)
|
23
|
+
RestClient.log = output
|
24
|
+
end
|
25
25
|
|
26
|
-
|
26
|
+
attr_reader :site_url, :connection_options
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
@site_url = site_url
|
33
|
-
@connection_options = opts
|
28
|
+
def initialize(site_url, opts={})
|
29
|
+
unless site_url =~ /^https?/
|
30
|
+
raise ArgumentError, "site_url must include either http or https scheme"
|
34
31
|
end
|
32
|
+
@site_url = site_url
|
33
|
+
@connection_options = opts
|
34
|
+
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
36
|
+
# set the url to be used for creating an http connection
|
37
|
+
# @param url [string]
|
38
|
+
def site_url=(url)
|
39
|
+
@site_url = url
|
40
|
+
@host = nil
|
41
|
+
@scheme = nil
|
42
|
+
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
def host
|
45
|
+
@host ||= parsed_url.host
|
46
|
+
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
def scheme
|
49
|
+
@scheme ||= parsed_url.scheme
|
50
|
+
end
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
def absolute_url(path='')
|
53
|
+
"#{@site_url}#{path}"
|
54
|
+
end
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
def connection_options=(opts)
|
57
|
+
raise ArgumentError, 'expected Hash' unless opts.is_a?(Hash)
|
58
|
+
@connection_options = opts
|
59
|
+
end
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
resp = RestClient::Request.execute(req_opts)
|
83
|
-
|
84
|
-
result = Yammer::ApiResponse.new(resp.headers, resp.body, resp.code)
|
85
|
-
rescue => e
|
86
|
-
if e.is_a?(RestClient::ExceptionWithResponse)
|
87
|
-
e.response
|
88
|
-
else
|
89
|
-
raise e
|
90
|
-
end
|
61
|
+
def send_request(method, path, opts={})
|
62
|
+
begin
|
63
|
+
params = opts.fetch(:params, {})
|
64
|
+
|
65
|
+
req_opts = self.connection_options.merge({
|
66
|
+
:method => method,
|
67
|
+
:headers => opts.fetch(:headers, {})
|
68
|
+
})
|
69
|
+
|
70
|
+
case method
|
71
|
+
when :get, :delete
|
72
|
+
query = Addressable::URI.form_encode(params)
|
73
|
+
normalized_path = query.empty? ? path : [path, query].join("?")
|
74
|
+
req_opts[:url] = absolute_url(normalized_path)
|
75
|
+
when :post, :put
|
76
|
+
req_opts[:payload] = params
|
77
|
+
req_opts[:url] = absolute_url(path)
|
78
|
+
else
|
79
|
+
raise "Unsupported HTTP method, #{method}"
|
91
80
|
end
|
92
|
-
end
|
93
81
|
|
94
|
-
|
95
|
-
|
96
|
-
|
82
|
+
resp = RestClient::Request.execute(req_opts)
|
83
|
+
|
84
|
+
result = Yammer::ApiResponse.new(resp.headers, resp.body, resp.code)
|
85
|
+
rescue => e
|
86
|
+
if e.is_a?(RestClient::ExceptionWithResponse)
|
87
|
+
e.response
|
88
|
+
else
|
89
|
+
raise e
|
90
|
+
end
|
97
91
|
end
|
92
|
+
end
|
98
93
|
|
94
|
+
private
|
95
|
+
def parsed_url
|
96
|
+
Addressable::URI.parse(@site_url)
|
99
97
|
end
|
98
|
+
|
99
|
+
end
|
100
100
|
end
|
@@ -0,0 +1,210 @@
|
|
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 Resources
|
17
|
+
class Base
|
18
|
+
class << self
|
19
|
+
include ApiHandler
|
20
|
+
|
21
|
+
# Returns the non-qualified class name
|
22
|
+
# @!scope class
|
23
|
+
def base_name
|
24
|
+
@base_name ||= begin
|
25
|
+
word = "#{name.split(/::/).last}"
|
26
|
+
word.gsub!(/::/, '/')
|
27
|
+
word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
28
|
+
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
29
|
+
word.tr!("-", "_")
|
30
|
+
word.downcase!
|
31
|
+
word
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Fetches JSON reprsentation for object model with provided `id`
|
36
|
+
# and returns a model instance with attributes
|
37
|
+
# @return [Yammer::Base]
|
38
|
+
# @param id [Integer]
|
39
|
+
# @!scope class
|
40
|
+
def get(id)
|
41
|
+
attrs = fetch(id)
|
42
|
+
attrs ? new(attrs) : nil
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
# @!scope class
|
47
|
+
def fetch(id)
|
48
|
+
return unless identity_map
|
49
|
+
attributes = identity_map.get("#{base_name}_#{id}")
|
50
|
+
unless attributes
|
51
|
+
result = api_handler.send("get_#{base_name}", id)
|
52
|
+
attributes = result.empty? ? nil : result.body
|
53
|
+
unless attributes.empty?
|
54
|
+
identity_map.put("#{base_name}_#{id}", attributes)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
attributes
|
58
|
+
end
|
59
|
+
|
60
|
+
# @!scope class
|
61
|
+
def identity_map
|
62
|
+
@identity_map ||= Yammer::Resources::IdentityMap.new
|
63
|
+
end
|
64
|
+
|
65
|
+
# Returns a hash of all attributes that are meant to trigger an HTTP request
|
66
|
+
# @!scope class
|
67
|
+
def model_attributes
|
68
|
+
@model_attributes ||= {}
|
69
|
+
end
|
70
|
+
|
71
|
+
protected
|
72
|
+
|
73
|
+
def attr_accessor_deffered(*symbols)
|
74
|
+
symbols.each do |key|
|
75
|
+
# track attributes that should trigger a fetch
|
76
|
+
model_attributes[key] = false
|
77
|
+
|
78
|
+
# getter
|
79
|
+
define_method(key.to_s) do
|
80
|
+
load_deferred_attribute!(key)
|
81
|
+
instance_variable_get("@#{key}")
|
82
|
+
end
|
83
|
+
|
84
|
+
# setter
|
85
|
+
define_method("#{key}=") do |value|
|
86
|
+
load_deferred_attribute!(key)
|
87
|
+
if persisted? && loaded?
|
88
|
+
@modified_attributes[key] = value
|
89
|
+
else
|
90
|
+
@attrs[key] = value
|
91
|
+
end
|
92
|
+
instance_variable_set("@#{key}", value)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
attr_reader :id, :attrs
|
99
|
+
|
100
|
+
def initialize(props={})
|
101
|
+
@klass = self.class
|
102
|
+
@modified_attributes = {}
|
103
|
+
@new_record = true
|
104
|
+
@loaded = false
|
105
|
+
@attrs = props
|
106
|
+
self.id = @attrs.delete(:id)
|
107
|
+
self.update(@attrs)
|
108
|
+
|
109
|
+
yield self if block_given?
|
110
|
+
end
|
111
|
+
|
112
|
+
def api_handler
|
113
|
+
@klass.api_handler
|
114
|
+
end
|
115
|
+
|
116
|
+
def base_name
|
117
|
+
@klass.base_name
|
118
|
+
end
|
119
|
+
|
120
|
+
def new_record?
|
121
|
+
@new_record
|
122
|
+
end
|
123
|
+
|
124
|
+
def persisted?
|
125
|
+
!new_record?
|
126
|
+
end
|
127
|
+
|
128
|
+
def changes
|
129
|
+
@modified_attributes
|
130
|
+
end
|
131
|
+
|
132
|
+
def modified?
|
133
|
+
!changes.empty?
|
134
|
+
end
|
135
|
+
|
136
|
+
def loaded?
|
137
|
+
@loaded
|
138
|
+
end
|
139
|
+
|
140
|
+
def load!
|
141
|
+
@attrs = @klass.fetch(@id)
|
142
|
+
@loaded = true
|
143
|
+
update(@attrs)
|
144
|
+
self
|
145
|
+
end
|
146
|
+
|
147
|
+
def reload!
|
148
|
+
reset!
|
149
|
+
load!
|
150
|
+
end
|
151
|
+
|
152
|
+
def save
|
153
|
+
return self if ((persisted? && @modified_attributes.empty?) || @attrs.empty?)
|
154
|
+
|
155
|
+
result = if new_record?
|
156
|
+
api_handler.send("create_#{base_name}", @attrs)
|
157
|
+
else
|
158
|
+
api_handler.send("update_#{base_name}", @id, @modified_attributes)
|
159
|
+
end
|
160
|
+
@modified_attributes = {}
|
161
|
+
self
|
162
|
+
end
|
163
|
+
|
164
|
+
def delete!
|
165
|
+
return if new_record?
|
166
|
+
result = api_handler.send("delete_#{base_name}", @id)
|
167
|
+
result.success?
|
168
|
+
end
|
169
|
+
|
170
|
+
private
|
171
|
+
|
172
|
+
def id=(model_id)
|
173
|
+
return if model_id.nil?
|
174
|
+
@id = model_id.to_i
|
175
|
+
@new_record = false
|
176
|
+
end
|
177
|
+
|
178
|
+
# clear the entire class
|
179
|
+
def reset!
|
180
|
+
@modified_attributes = {}
|
181
|
+
@attrs = {}
|
182
|
+
@new_record = true
|
183
|
+
@loaded = false
|
184
|
+
end
|
185
|
+
|
186
|
+
protected
|
187
|
+
# loads model
|
188
|
+
def load_deferred_attribute!(key)
|
189
|
+
if @attrs.empty? && persisted? && !loaded?
|
190
|
+
load!
|
191
|
+
if !@attrs.has_key?(key)
|
192
|
+
raise "The key: #{key} appears not to be supported for model: #{self.base_name} \n #{@attrs.keys.inspect}"
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
# set all fetchable attributes
|
198
|
+
def update(attrs={})
|
199
|
+
attrs.each do |key, value|
|
200
|
+
send("#{key}=", value)
|
201
|
+
end
|
202
|
+
if persisted? && !loaded?
|
203
|
+
@loaded = @klass.model_attributes.keys.inject(true) do |result, key|
|
204
|
+
result && @attrs.has_key?(key)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
@@ -13,15 +13,17 @@
|
|
13
13
|
# permissions and limitations under the License.
|
14
14
|
|
15
15
|
module Yammer
|
16
|
-
|
16
|
+
module Resources
|
17
|
+
class Group < Yammer::Resources::Base
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
attr_accessor_deffered :show_in_directory, :privacy, :description, :creator_type,
|
20
|
+
:creator_id, :mugshot_id, :stats, :state, :web_url, :name, :created_at, :type,
|
21
|
+
:mugshot_url, :url, :full_name, :mugshot_url_template, :description
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
# @!scope class
|
24
|
+
def self.create(params={})
|
25
|
+
api_handler.create_group(params)
|
26
|
+
end
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
@@ -13,13 +13,15 @@
|
|
13
13
|
# permissions and limitations under the License.
|
14
14
|
|
15
15
|
module Yammer
|
16
|
-
|
16
|
+
module Resources
|
17
|
+
class GroupMembership < Yammer::Resources::Base
|
17
18
|
|
18
|
-
|
19
|
+
attr_accessor_deffered
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
# @!scope class
|
22
|
+
def self.create(id)
|
23
|
+
api_handler.create_group_membership(id)
|
24
|
+
end
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -0,0 +1,58 @@
|
|
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 Resources
|
17
|
+
class IdentityMap
|
18
|
+
|
19
|
+
class InvalidKeyError < StandardError; end
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
@map = {}
|
23
|
+
@size = 0
|
24
|
+
end
|
25
|
+
|
26
|
+
# @note retrives key from identity map
|
27
|
+
# @return [Hash]
|
28
|
+
# @param key [string]
|
29
|
+
# @param default [Hash]
|
30
|
+
def get(key, default=nil)
|
31
|
+
@map["#{key}"] || default
|
32
|
+
end
|
33
|
+
|
34
|
+
# @note inserts a hash of attributes into identity map
|
35
|
+
# @return [Hash]
|
36
|
+
# @param key [string]
|
37
|
+
# @param value [Hash]
|
38
|
+
def put(key, value)
|
39
|
+
if key.nil? || key.empty?
|
40
|
+
raise InvalidKeyError.new
|
41
|
+
end
|
42
|
+
@map["#{key}"] = value
|
43
|
+
end
|
44
|
+
|
45
|
+
# @note returns the current size of identity map
|
46
|
+
# @return [Integer]
|
47
|
+
def size
|
48
|
+
@map.keys.count
|
49
|
+
end
|
50
|
+
|
51
|
+
# clears the entire identity map
|
52
|
+
# @return [Hash]
|
53
|
+
def purge!
|
54
|
+
@map = {}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,34 @@
|
|
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 Resources
|
17
|
+
class Message < Yammer::Resources::Base
|
18
|
+
|
19
|
+
attr_accessor_deffered :direct_message, :privacy, :group_id, :created_at,
|
20
|
+
:attachments, :liked_by, :chat_client_sequence, :client_url, :content_excerpt,
|
21
|
+
:message_type, :url, :web_url, :network_id, :system_message, :client_type,
|
22
|
+
:sender_type, :sender_id, :thread_id, :conversation_id, :replied_to_id, :body
|
23
|
+
|
24
|
+
attr_reader :replied_to_id
|
25
|
+
|
26
|
+
# Creates a new message
|
27
|
+
# @!scope class
|
28
|
+
def self.create(body, params={})
|
29
|
+
api_handler.create_message(body, params)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -13,20 +13,17 @@
|
|
13
13
|
# permissions and limitations under the License.
|
14
14
|
|
15
15
|
module Yammer
|
16
|
-
|
16
|
+
module Models
|
17
|
+
class MessageBody
|
18
|
+
attr_reader :urls, :parsed, :rich
|
19
|
+
attr_accessor :plain
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
# Creates a new message
|
26
|
-
# @!scope class
|
27
|
-
def self.create(body, params={})
|
28
|
-
api_handler.create_message(body, params)
|
21
|
+
def initialize(opts={})
|
22
|
+
@plain = opts.fetch(:plain,'')
|
23
|
+
@parsed = opts.fetch(:parsed,'')
|
24
|
+
@rich = opts.fetch(:rich,'')
|
25
|
+
@urls = opts.fetch(:urls,'')
|
26
|
+
end
|
29
27
|
end
|
30
|
-
|
31
28
|
end
|
32
29
|
end
|
File without changes
|
@@ -0,0 +1,60 @@
|
|
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 Resources
|
17
|
+
class Thread < Yammer::Resources::Base
|
18
|
+
|
19
|
+
attr_accessor_deffered :participants, :web_url, :references, :thread_starter_id,
|
20
|
+
:type, :privacy, :has_attachments, :attachments_meta, :topics, :url, :attachments,
|
21
|
+
:direct_message, :participants_count, :stats
|
22
|
+
|
23
|
+
def first_reply_id
|
24
|
+
stats[:first_reply_id]
|
25
|
+
end
|
26
|
+
|
27
|
+
def first_reply
|
28
|
+
@first_reply ||= first_reply_id ? Yammer::Resources::Message.new(:id => first_reply_id) : nil
|
29
|
+
end
|
30
|
+
|
31
|
+
def latest_reply_id
|
32
|
+
stats[:latest_reply_id]
|
33
|
+
end
|
34
|
+
|
35
|
+
def last_reply
|
36
|
+
@latest_reply ||= latest_reply_id ? Yammer::Resources::Message.new(:id => latest_reply_id) : nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def people
|
40
|
+
@people ||= begin
|
41
|
+
@participants.map do |part|
|
42
|
+
next unless part[:type] == 'user'
|
43
|
+
Yammer::Resources::User.new(:id => part[:id])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
@people
|
47
|
+
end
|
48
|
+
|
49
|
+
def messages
|
50
|
+
@messages = {}
|
51
|
+
result = api_handler.messages_in_thread(self.id)
|
52
|
+
msgs = result.body[:messages].each do |message|
|
53
|
+
msg = Yammer::Resources::Message.new(message)
|
54
|
+
@messages["#{msg.id}"] = msg
|
55
|
+
end
|
56
|
+
@messages
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|