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.
data/lib/yammer/thread.rb DELETED
@@ -1,58 +0,0 @@
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
- class Thread < Yammer::Base
17
-
18
- attr_accessor_deffered :participants, :web_url, :references, :thread_starter_id,
19
- :type, :privacy, :has_attachments, :attachments_meta, :topics, :url, :attachments,
20
- :direct_message, :participants_count, :stats
21
-
22
- def first_reply_id
23
- stats[:first_reply_id]
24
- end
25
-
26
- def first_reply
27
- @first_reply ||= first_reply_id ? Yammer::Message.new(:id => first_reply_id) : nil
28
- end
29
-
30
- def latest_reply_id
31
- stats[:latest_reply_id]
32
- end
33
-
34
- def last_reply
35
- @latest_reply ||= latest_reply_id ? Yammer::Message.new(:id => latest_reply_id) : nil
36
- end
37
-
38
- def people
39
- @people ||= begin
40
- @participants.map do |part|
41
- next unless part[:type] == 'user'
42
- Yammer::User.new(:id => part[:id])
43
- end
44
- end
45
- @people
46
- end
47
-
48
- def messages
49
- @messages = {}
50
- result = api_handler.messages_in_thread(self.id)
51
- msgs = result.body[:messages].each do |message|
52
- msg = Yammer::Message.new(message)
53
- @messages["#{msg.id}"] = msg
54
- end
55
- @messages
56
- end
57
- end
58
- end
data/lib/yammer/user.rb DELETED
@@ -1,66 +0,0 @@
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
- module Yammer
15
- class User < Yammer::Base
16
-
17
-
18
- # Returns authenticated user's details
19
- # @!scope class
20
- def self.current
21
- result = api_handler.current_user
22
- return nil unless result.success?
23
- new(result.body)
24
- end
25
-
26
- # Creates a new user from email address
27
- # @!scope class
28
- def self.create(email)
29
- result = api_handler.create_user(:email => email)
30
- return nil unless result.created?
31
- id = result.headers[:location].split('/').last.to_i
32
- new(:id => id)
33
- end
34
-
35
- attr_accessor_deffered :first_name, :last_name, :full_name, :hire_date, :mugshot, :state,
36
- :type, :admin, :verified_admin, :expertise, :birth_date, :stats, :show_ask_for_photo, :job_title,
37
- :web_url, :url, :external_urls, :activated_at, :summary, :department, :previous_companies,
38
- :follow_general_messages, :schools, :interests, :significant_other, :network_name, :network_id,
39
- :can_broadcast, :web_preferences, :network_domains, :location, :contact, :kids_names, :guid,
40
- :name, :mugshot_url, :mugshot_url_template, :settings, :timezone
41
-
42
- # Returns user's primary email
43
- def email
44
- @email ||= begin
45
- self.contact[:email_addresses].map do |e|
46
- e[:address] if e[:type] == 'primary'
47
- end.first
48
- end
49
- end
50
-
51
- # Returns all users that this user is following
52
- def following
53
- api_handler.users_followed_by(@id)
54
- end
55
-
56
- # Returns all user's follwing this user
57
- def followers
58
- api_handler.users_following(@id)
59
- end
60
-
61
- # Updates the user attributes
62
- def update!(params)
63
- api_handler.update_user(@id, params)
64
- end
65
- end
66
- end