yam 0.0.6 → 1.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.
Files changed (88) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.travis.yml +5 -0
  3. data/.yardopts +10 -0
  4. data/AUTHORS +1 -0
  5. data/CHANGELOG.md +7 -0
  6. data/CONTRIBUTING.md +0 -7
  7. data/Gemfile +27 -1
  8. data/README.md +190 -67
  9. data/Rakefile +9 -3
  10. data/certs/public.pem +20 -0
  11. data/lib/yammer.rb +47 -0
  12. data/lib/yammer/api.rb +29 -0
  13. data/lib/yammer/api/autocomplete.rb +39 -0
  14. data/lib/yammer/api/group.rb +92 -0
  15. data/lib/yammer/api/group_membership.rb +46 -0
  16. data/lib/yammer/api/invitation.rb +39 -0
  17. data/lib/yammer/api/like.rb +57 -0
  18. data/lib/yammer/api/message.rb +227 -0
  19. data/lib/yammer/api/network.rb +35 -0
  20. data/lib/yammer/api/notification.rb +32 -0
  21. data/lib/yammer/api/open_graph_object.rb +92 -0
  22. data/lib/yammer/api/pending_attachment.rb +64 -0
  23. data/lib/yammer/api/search.rb +42 -0
  24. data/lib/yammer/api/subscription.rb +32 -0
  25. data/lib/yammer/api/thread.rb +37 -0
  26. data/lib/yammer/api/topic.rb +37 -0
  27. data/lib/yammer/api/user.rb +168 -0
  28. data/lib/yammer/api_handler.rb +27 -0
  29. data/lib/yammer/api_response.rb +57 -0
  30. data/lib/yammer/base.rb +208 -0
  31. data/lib/yammer/client.rb +100 -0
  32. data/lib/yammer/configurable.rb +81 -0
  33. data/lib/yammer/error.rb +75 -0
  34. data/lib/yammer/group.rb +27 -0
  35. data/lib/yammer/group_membership.rb +25 -0
  36. data/lib/yammer/http_adapter.rb +100 -0
  37. data/lib/yammer/identity_map.rb +56 -0
  38. data/lib/yammer/message.rb +32 -0
  39. data/lib/yammer/message_body.rb +27 -0
  40. data/lib/yammer/pending_attachment.rb +19 -0
  41. data/lib/yammer/thread.rb +58 -0
  42. data/lib/yammer/user.rb +66 -0
  43. data/lib/yammer/version.rb +32 -0
  44. data/{lib/yam/configuration.rb → spec/api/autocomplete_spec.rb} +18 -23
  45. data/spec/api/group_membership_spec.rb +48 -0
  46. data/spec/api/group_spec.rb +76 -0
  47. data/spec/api/invitation_spec.rb +60 -0
  48. data/spec/api/like_spec.rb +46 -0
  49. data/spec/api/message_spec.rb +136 -0
  50. data/spec/api/network_spec.rb +41 -0
  51. data/{lib/yam/client.rb → spec/api/notification_spec.rb} +22 -4
  52. data/spec/api/open_graph_object_spec.rb +67 -0
  53. data/spec/api/pending_attachment_spec.rb +56 -0
  54. data/{lib/yam/constants.rb → spec/api/search_spec.rb} +21 -8
  55. data/spec/api/subscription_spec.rb +41 -0
  56. data/{lib/yam.rb → spec/api/thread_spec.rb} +19 -12
  57. data/{lib/yam/request.rb → spec/api/topic_spec.rb} +19 -15
  58. data/spec/api/user_spec.rb +108 -0
  59. data/spec/api_response.rb +86 -0
  60. data/spec/client_spec.rb +364 -0
  61. data/spec/error_spec.rb +88 -0
  62. data/spec/fixtures/group.json +1 -0
  63. data/spec/fixtures/message.json +1 -0
  64. data/spec/fixtures/messages_in_thread.json +1 -0
  65. data/spec/fixtures/portal_thread.json +1 -0
  66. data/spec/fixtures/private_thread.json +1 -0
  67. data/spec/fixtures/public_thread.json +1 -0
  68. data/spec/fixtures/user.json +1 -0
  69. data/spec/fixtures/users_followed.json +1 -0
  70. data/spec/fixtures/users_following.json +1 -0
  71. data/spec/http_adapter_spec.rb +109 -0
  72. data/spec/identity_map_spec.rb +127 -0
  73. data/spec/mocks/attachment.txt +1 -0
  74. data/spec/model/base_spec.rb +196 -0
  75. data/spec/model/group_membership_spec.rb +57 -0
  76. data/spec/model/group_spec.rb +73 -0
  77. data/spec/model/message_spec.rb +74 -0
  78. data/spec/model/thread_spec.rb +91 -0
  79. data/spec/model/user_spec.rb +222 -0
  80. data/spec/spec_helper.rb +39 -14
  81. data/yam.gemspec +50 -28
  82. metadata +270 -187
  83. metadata.gz.sig +0 -0
  84. data/lib/yam/api.rb +0 -53
  85. data/lib/yam/connection.rb +0 -57
  86. data/lib/yam/version.rb +0 -20
  87. data/spec/yam/client_spec.rb +0 -50
  88. data/spec/yam_spec.rb +0 -87
@@ -0,0 +1,35 @@
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 Network
18
+
19
+ # @see https://developer.yammer.com/restapi/#rest-network
20
+ # @api_path /api/v1//networks/current
21
+ # @rate_limited Yes
22
+ # @authentication authenticated user context
23
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
24
+ # @return [Yammer::ApiResponse]
25
+ # @param [Hash] opts the options to fetch a thread with
26
+ # @option opts [Boolean] :include_suspended
27
+ # @option opts [Boolean] :exclude_own_messages_from_unseen
28
+ # @example Fetch all networks that the current user is a member of
29
+ # Yammer.current_networks
30
+ def current_networks(opts={})
31
+ get('/api/v1/networks/current', opts)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,32 @@
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 Notification
18
+
19
+ # @see https://developer.yammer.com/restapi/#rest-notifications
20
+ # @api_path /api/v1/streams/notifications
21
+ # @rate_limited Yes
22
+ # @authentication authenticated user context
23
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
24
+ # @return [Yammer::ApiResponse]
25
+ # @example Fetch notifications for authenticated user
26
+ # Yammer.notifications
27
+ def notifications
28
+ get('/api/v1/streams/notifications')
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,92 @@
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 OpenGraphObject
18
+
19
+ # @see https://developer.yammer.com/
20
+ # @api_path /api/v1/open_graph_objects/
21
+ # @rate_limited Yes
22
+ # @authentication Requires user context
23
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
24
+ # @return [Yammer::ApiResponse]
25
+ # @param [String] url The URL of the open graph object
26
+ # @param [Hash] props The properties of this open graph object
27
+ # @option props [String] :image
28
+ # @option props [String] :description
29
+ # @option props [String] :site_name
30
+ # @option props [String] :title
31
+ # @option props [String] :media_url
32
+ # @option props [String] :media_type
33
+ # @option props [String] :media_width
34
+ # @option props [String] :media_height
35
+ # @example Create a new open graph object
36
+ #
37
+ # Yammer.create_open_graph_object('http://www.microsoft.com', {
38
+ # :site_name => 'Microsoft'
39
+ # :image => 'https://microsoft.com/global/images/test.jpg'
40
+ # })
41
+ def create_open_graph_object(url, props={})
42
+ post("/api/v1/open_graph_objects", { :url => url, :properites => props })
43
+ end
44
+
45
+ # Subscribes the current user to the open graph object with the request id.
46
+ # @see https://developer.yammer.com/
47
+ # @api_path /api/v1/open_graph_objects/
48
+ # @rate_limited Yes
49
+ # @authentication Requires user context
50
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
51
+ # @return [Yammer::ApiResponse]
52
+ # @param [Integer] id The ID of the open graph object
53
+ # @example Subscribe to open graph object
54
+ #
55
+ # => Yammer.follow_open_graph_object(8)
56
+ def follow_open_graph_object(id)
57
+ post('/api/v1/subscriptions', :target_id => id, :target_type => 'OpenGraphObject')
58
+ end
59
+
60
+ # Determines if the current user follows an open graph object
61
+ # @see https://developer.yammer.com/
62
+ # @api_path /api/v1/open_graph_objects/
63
+ # @rate_limited Yes
64
+ # @authentication Requires user context
65
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
66
+ # @return [Yammer::ApiResponse]
67
+ # @param [Integer] id The ID of the open graph object
68
+ # @example Verify to open graph object
69
+ #
70
+ # => Yammer.following_open_graph_object?(89)
71
+ def is_following_open_graph_object?(id)
72
+ get("/api/v1/subscriptions/to_open_graph_object/#{id}")
73
+ end
74
+
75
+
76
+ # Returns open graph objects in a user's activity stream
77
+ # @see https://developer.yammer.com/
78
+ # @api_path /api/v1/streams/activities
79
+ # @rate_limited Yes
80
+ # @authentication Requires user context
81
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
82
+ # @return [Yammer::ApiResponse]
83
+ # @param [Integer] id The ID of the users whose stream of open graph objects we want to fetch
84
+ # @example Get open graph object in a given user's activity stream
85
+ #
86
+ # Yammer.get_activity_stream_open_graph_objects?(3)
87
+ def get_activity_stream_open_graph_objects(id)
88
+ get("/api/v1/streams/activities", :owner_type => 'open_graph_object', :owner_id => id)
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,64 @@
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 PendingAttachment
18
+
19
+ # Create a new pending attachment owned by authenticated user
20
+ # @see https://developer.yammer.com/restapi/#rest-messages
21
+ # @api_path /api/v1/pending_attachments
22
+ # @rate_limited Yes
23
+ # @authentication User context
24
+ # @raise [Yammer::Error::Unauthorized Yammer::Error::Forbidden] Error when supplied user credentials are not valid
25
+ # when user network does not allow attachments
26
+ # @return [Yammer::ApiResponse]
27
+ # @example Fetch existing pending attachment
28
+ # Yammer.get_pending_attachment(62)
29
+ def get_pending_attachment(id)
30
+ get("/api/v1/pending_attachments/#{id}")
31
+ end
32
+
33
+ # Delete a pending attachment owned by the authenticated user
34
+ # @see https://developer.yammer.com/restapi/#rest-messages
35
+ # @api_path /api/v1/pending_attachments
36
+ # @rate_limited Yes
37
+ # @authentication User context
38
+ # @raise [Yammer::Error::Unauthorized Yammer::Error::NotFound] Error raised when supplied user credentials are not valid
39
+ # when attachment cannot be found
40
+ # @return [Yammer::ApiResponse]
41
+ # @example Delete existing pending attachment
42
+ # Yammer.delete_pending_attachment(34)
43
+ def delete_pending_attachment(id)
44
+ delete("/api/v1/pending_attachments/#{id}")
45
+ end
46
+
47
+ # Fetch a pending attachment owned by authenticated user
48
+ # @see https://developer.yammer.com/restapi/#rest-messages
49
+ # @api_path /api/v1/pending_attachments
50
+ # @rate_limited Yes
51
+ # @authentication User context
52
+ # @raise [Yammer::Error::Unauthorized Yammer::Error::NotFound] Error raised when supplied user credentials are not valid
53
+ # when attachment cannot be found
54
+ # @return [Yammer::ApiResponse]
55
+ # @example Create new pending attachment
56
+ # file = File.open('~/attachment.txt', 'r')
57
+ # Yammer.create_pending_attachment(file)
58
+ #
59
+ def create_pending_attachment(attachment)
60
+ post("/api/v1/pending_attachments", :attachment => attachment)
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,42 @@
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 Search
18
+
19
+ # @see https://developer.yammer.com/restapi/#rest-search
20
+ # @api_path /api/v1/search
21
+ # @rate_limited Yes
22
+ # @authentication Requires user context
23
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
24
+ # @return [Yammer::ApiResponse]
25
+ # @param [Hash] opts the options to fetch a thread with
26
+ # @option opts [Integer] :num_per_page
27
+ # @option opts [Integer] :page
28
+ # @option opts [Integer] :search_group
29
+ # @option opts [Integer] :search_user
30
+ # @option opts [String] :search_sort
31
+ # @option opts [String] :match
32
+ # @option opts [String] :model_types
33
+ # @option opts [String] :search_startdate
34
+ # @option opts [String] :search_enddate
35
+ # @example Search for a particular term on within current user's network
36
+ # Yammer.search(:search => 'documents')
37
+ def search(opts={})
38
+ get('/api/v1/search', opts)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,32 @@
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 Subscription
18
+
19
+ # @see https://developer.yammer.com/
20
+ # @api_path /api/v1/subscriptions/
21
+ # @rate_limited Yes
22
+ # @authentication Requires user context
23
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
24
+ # @return [Yammer::ApiResponse]
25
+ # @param [Integer] id
26
+ # @param [String] type
27
+ def create_subscription(type, id)
28
+ post('/api/v1/subscriptions', :target_id => id, :target_type => type)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,37 @@
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 Thread
18
+
19
+ # @see https://developer.yammer.com/restapi/#rest-threads
20
+ # @api_path /api/v1/threads/id
21
+ # @rate_limited Yes
22
+ # @authentication Requires user context
23
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
24
+ # @return [Yammer::Response]
25
+ # @param id [Integer] the thread ID
26
+ # @param [Hash] opts the options to fetch a thread with
27
+ # @option opts [Integer] :newer_than
28
+ # @option opts [String] :threaded
29
+ # @option opts [Boolean] :exclude_own_messages_from_unseen
30
+ # @example Fetch data for the thread
31
+ # Yammer.get_thread(42)
32
+ def get_thread(id, opts={})
33
+ get("/api/v1/threads/#{id}", opts)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
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 Topic
18
+
19
+ # @see https://developer.yammer.com/restapi/#rest-topics
20
+ # @api_path /api/v1/topics
21
+ # @rate_limited Yes
22
+ # @authentication Requires user context
23
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied
24
+ # user credentials are not valid.
25
+ # @return [Yammer::ApiResponse]
26
+ # @param id [Integer]
27
+ # @param [Hash] opts the options to fetch a thread with
28
+ # @option opts [Integer] :is_followed_by include if specified user
29
+ # is following topic that is being fetched
30
+ # @example Fetch data for the thread
31
+ # Yammer.get_topic(42, :is_followed_by => 2)
32
+ def get_topic(id, opts={})
33
+ get("/api/v1/topics/#{id}", opts)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,168 @@
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 User
18
+
19
+ # @see https://developer.yammer.com/restapi/#rest-users
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 opts [Hash] A customizable set of options.
25
+ # @option opts [String] :email
26
+ # @option opts [String] :full_name
27
+ # @option opts [String] :guid
28
+ # @option opts [String] :job_title
29
+ # @option opts [String] :location
30
+ # @option opts [String] :im_provider
31
+ # @option opts [String] :im_username
32
+ # @option opts [String] :work_telephone
33
+ # @option opts [String] :work_extension
34
+ # @option opts [String] :mobile_telephone
35
+ # @option opts [String] :external_profiles
36
+ # @option opts [String] :significant_other
37
+ # @option opts [String] :kids_names
38
+ # @option opts [String] :interests
39
+ # @option opts [String] :summary
40
+ # @option opts [String] :expertise
41
+ # @option opts [String] :schools_csv
42
+ # @option opts [String] :previous_companies_csv
43
+ # @option opts [String] :preferred_my_feed
44
+ # @option opts [String] :sticky_my_feed
45
+ # @option opts [String] :prescribed_my_feed
46
+ # @example create a user with the email `thekev@yammer.com`
47
+ # Yammer.create_user('thekev@yammer.com')
48
+ def create_user(opts={})
49
+ post("/api/v1/users", opts)
50
+ end
51
+
52
+ # @see https://developer.yammer.com/restapi/#rest-users
53
+ # @rate_limited Yes
54
+ # @authentication Requires user context
55
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
56
+ # @return [Yammer::ApiResponse]
57
+ # @param opts [Hash] A customizable set of options.
58
+ # @option opts [String] :email
59
+ # @option opts [String] :full_name
60
+ # @option opts [String] :guid
61
+ # @option opts [String] :job_title
62
+ # @option opts [String] :location
63
+ # @option opts [String] :im_provider
64
+ # @option opts [String] :im_username
65
+ # @option opts [String] :work_telephone
66
+ # @option opts [String] :work_extension
67
+ # @option opts [String] :mobile_telephone
68
+ # @option opts [String] :external_profiles
69
+ # @option opts [String] :significant_other
70
+ # @option opts [String] :kids_names
71
+ # @option opts [String] :interests
72
+ # @option opts [String] :summary
73
+ # @option opts [String] :expertise
74
+ # @option opts [String] :schools_csv
75
+ # @option opts [String] :previous_companies_csv
76
+ # @option opts [String] :preferred_my_feed
77
+ # @option opts [String] :sticky_my_feed
78
+ # @option opts [String] :prescribed_my_feed
79
+ # @example update info for a user with the email `thekev@yammer.com`
80
+ # Yammer.update_user(1, :job_title => 'software engineer')
81
+ def update_user(id, opts={})
82
+ put("/api/v1/users/#{id}", opts)
83
+ end
84
+
85
+ # @see https://developer.yammer.com/restapi/#rest-users
86
+ # @rate_limited Yes
87
+ # @authentication Requires user context
88
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
89
+ # @return [Yammer::ApiResponse]
90
+ # @param id [Integer, String] A Yammer user ID
91
+ # @example Delete user with ID 2
92
+ # Yammer.delete_user(2)
93
+ def delete_user(id)
94
+ delete("/api/v1/users/#{id}")
95
+ end
96
+
97
+ # @see https://developer.yammer.com/restapi/#rest-users
98
+ # @rate_limited Yes
99
+ # @authentication Requires user context
100
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
101
+ # @return [Yammer::ApiResponse]
102
+ # @param id [Integer, String] A Yammer user ID
103
+ # @example Fetch data user with ID 2
104
+ # Yammer.get_user(2)
105
+ def get_user(id)
106
+ get("/api/v1/users/#{id}")
107
+ end
108
+
109
+ # @see https://developer.yammer.com/restapi/#rest-users
110
+ # @rate_limited Yes
111
+ # @authentication Requires user context
112
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
113
+ # @return [Yammer::ApiResponse]
114
+ # @param email [Integer, String] A Yammer user ID
115
+ # @example Fetch data user with email `thekev@yammer.com`
116
+ # Yammer.get_user_by_email('thekev@yammer.com')
117
+ def get_user_by_email(email)
118
+ get("/api/v1/users/by_email", :email => email)
119
+ end
120
+
121
+ # @see https://developer.yammer.com/restapi/#rest-users
122
+ # @rate_limited Yes
123
+ # @authentication Requires user context
124
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
125
+ # @return [Yammer::ApiResponse]
126
+ # @example Fetch data for the authenticated user
127
+ # Yammer.current_user
128
+ def current_user
129
+ get("/api/v1/users/current")
130
+ end
131
+
132
+ # @see https://developer.yammer.com/restapi/#rest-users
133
+ # @rate_limited Yes
134
+ # @authentication Requires user context
135
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
136
+ # @return [Yammer::ApiResponse]
137
+ # @param opts [Hash] A customizable set of opts.
138
+ # @option opts [Integer] :page
139
+ # @example Fetch users from the authenticated user's network
140
+ # Yammer.all_users
141
+ def all_users(opts={})
142
+ get("/api/v1/users", opts)
143
+ end
144
+
145
+ # @rate_limited Yes
146
+ # @authentication Requires user context
147
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
148
+ # @return [Yammer::ApiResponse]
149
+ # @param id [Integer] the ID of the user whose followers you want to get
150
+ # @example Fetch users from the authenticated user's network following user whose ID is provided
151
+ # Yammer.users_following(1)
152
+ def users_following(id)
153
+ get("/api/v1/users/following/#{id}")
154
+ end
155
+
156
+ # @rate_limited Yes
157
+ # @authentication Requires user context
158
+ # @raise [Yammer::Error::Unauthorized] Error raised when supplied user credentials are not valid.
159
+ # @return [Yammer::ApiResponse]
160
+ # @param id [Integer] the ID of the user for whom you want to get the users being followed
161
+ # @example Fetch users from the authenticated user's network followed by the user whose ID is provided
162
+ # Yammer.users_followed(1)
163
+ def users_followed_by(id)
164
+ get("/api/v1/users/followed_by/#{id}")
165
+ end
166
+ end
167
+ end
168
+ end