platforms-yammer 0.1.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 (37) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +157 -0
  4. data/Rakefile +18 -0
  5. data/lib/generators/platforms/yammer/install/USAGE +11 -0
  6. data/lib/generators/platforms/yammer/install/install_generator.rb +29 -0
  7. data/lib/generators/platforms/yammer/install/templates/platforms_yammer.rb +4 -0
  8. data/lib/platforms/yammer.rb +15 -0
  9. data/lib/platforms/yammer/api.rb +39 -0
  10. data/lib/platforms/yammer/api/base.rb +20 -0
  11. data/lib/platforms/yammer/api/group_memberships.rb +35 -0
  12. data/lib/platforms/yammer/api/groups.rb +22 -0
  13. data/lib/platforms/yammer/api/invitations.rb +23 -0
  14. data/lib/platforms/yammer/api/messages.rb +165 -0
  15. data/lib/platforms/yammer/api/networks.rb +22 -0
  16. data/lib/platforms/yammer/api/oauth.rb +28 -0
  17. data/lib/platforms/yammer/api/open_graph_objects.rb +29 -0
  18. data/lib/platforms/yammer/api/pending_attachments.rb +34 -0
  19. data/lib/platforms/yammer/api/relationships.rb +39 -0
  20. data/lib/platforms/yammer/api/search.rb +22 -0
  21. data/lib/platforms/yammer/api/streams.rb +21 -0
  22. data/lib/platforms/yammer/api/subscriptions.rb +53 -0
  23. data/lib/platforms/yammer/api/suggestions.rb +31 -0
  24. data/lib/platforms/yammer/api/supervisor_mode.rb +22 -0
  25. data/lib/platforms/yammer/api/threads.rb +23 -0
  26. data/lib/platforms/yammer/api/topics.rb +23 -0
  27. data/lib/platforms/yammer/api/uploaded_files.rb +22 -0
  28. data/lib/platforms/yammer/api/users.rb +109 -0
  29. data/lib/platforms/yammer/authentication.rb +233 -0
  30. data/lib/platforms/yammer/client.rb +228 -0
  31. data/lib/platforms/yammer/configuration.rb +76 -0
  32. data/lib/platforms/yammer/engine.rb +27 -0
  33. data/lib/platforms/yammer/omni_auth_setup.rb +31 -0
  34. data/lib/platforms/yammer/railtie.rb +19 -0
  35. data/lib/platforms/yammer/version.rb +7 -0
  36. data/lib/tasks/platforms/yammer_tasks.rake +4 -0
  37. metadata +280 -0
@@ -0,0 +1,22 @@
1
+ module Platforms
2
+ module Yammer
3
+ module Api
4
+ # Networks on Yammer
5
+ # @author Benjamin Elias
6
+ # @since 0.1.0
7
+ class Networks < Base
8
+
9
+ # Get the user's current Network
10
+ # @param options [Hash] Options for the request
11
+ # @param headers [Hash] Additional headers to send with the request
12
+ # @return [Faraday::Response] the API response
13
+ # @see https://developer.yammer.com/docs/networkscurrentjson
14
+ def current options={}, headers={}
15
+ @connection.get 'networks/current.json', options, headers
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,28 @@
1
+ module Platforms
2
+ module Yammer
3
+ module Api
4
+ # OAuth2 tokens in Yammer, useful for verified admins to impoersonate
5
+ # other users, or to switch networks.
6
+ #
7
+ # @note This class is called Oauth and not OAuth (or OAuth2), because
8
+ # of the syntax of the Yammer API path.
9
+ # There is no underscore between the O and A.
10
+ #
11
+ # @author Benjamin Elias
12
+ # @since 0.1.0
13
+ class Oauth < Base
14
+
15
+ # Get tokens
16
+ # @param options [Hash] Options for the request
17
+ # @param headers [Hash] Additional headers to send with the request
18
+ # @return [Faraday::Response] the API response
19
+ # @see https://developer.yammer.com/docs/impersonation
20
+ def tokens options={}, headers={}
21
+ @connection.get "oauth/tokens.json", options, headers
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
28
+
@@ -0,0 +1,29 @@
1
+ module Platforms
2
+ module Yammer
3
+ module Api
4
+ # Open Graph Objects in Yammer
5
+ #
6
+ # This is read-only through the API.
7
+ #
8
+ # @author Benjamin Elias
9
+ # @since 0.1.0
10
+ class OpenGraphObjects < Base
11
+
12
+ # Get open graph obects
13
+ # URL is actually a required parameter so require that when
14
+ # calling this function.
15
+ # @param url [#to_s] URL of the OG item to get
16
+ # @param options [Hash] Options for the request
17
+ # @param headers [Hash] Additional headers to send with the request
18
+ # @return [Faraday::Response] the API response
19
+ # @see https://developer.yammer.com/docs/open_graph_objects
20
+ def get url, options={}, headers={}
21
+ params = options.merge({url: url})
22
+ @connection.get 'open_graph_objects.json', params, headers
23
+ end
24
+
25
+ end
26
+ end
27
+ end
28
+ end
29
+
@@ -0,0 +1,34 @@
1
+ module Platforms
2
+ module Yammer
3
+ module Api
4
+ # Pending attachments in Yammer
5
+ # @author Benjamin Elias
6
+ # @since 0.1.0
7
+ class PendingAttachments < Base
8
+
9
+ # Add a pending attachment
10
+ # @param upload_io [Faraday::UploadIO] The file payload
11
+ # @param options [Hash] Additional options for the request
12
+ # @param headers [Hash] Additional headers to send with the request
13
+ # @return [Faraday::Response] the API response
14
+ # @see https://developer.yammer.com/docs/pending_attachments
15
+ # @see https://stackoverflow.com/questions/16725195/upload-files-using-faraday
16
+ def post upload_io, options={}, headers={}
17
+ body = { file: upload_io }.reverse_merge(options)
18
+ @connection.post 'pending_attachments.json', body, headers
19
+ end
20
+
21
+ # Delete a pending attachment
22
+ # @param id [#to_s] ID of pending attachment to delete
23
+ # @param options [Hash] Options for the request
24
+ # @param headers [Hash] Additional headers to send with the request
25
+ # @return [Faraday::Response] the API response
26
+ # @see https://developer.yammer.com/docs/pending_attachmentsid
27
+ def delete id, options={}, headers={}
28
+ @connection.delete "pending_attachments/#{id}.json", options, headers
29
+ end
30
+
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,39 @@
1
+ module Platforms
2
+ module Yammer
3
+ module Api
4
+ # Relationships in Yammer
5
+ # @todo confirm documentation, which currently (2020-03-25) is confused
6
+ # around parameters and mentions updating relationships as part of a
7
+ # GET request
8
+ #
9
+ # @author Benjamin Elias
10
+ # @since 0.1.0
11
+ class Relationships < Base
12
+
13
+ # Get relationships
14
+ # @param options [Hash] Options for the request
15
+ # @param headers [Hash] Additional headers to send with the request
16
+ # @return [Faraday::Response] the API response
17
+ # @see https://developer.yammer.com/docs/relationshipsjson
18
+ def get options={}, headers={}
19
+ @connection.get 'relationships.json', options, headers
20
+ end
21
+
22
+
23
+ # Update relationships
24
+ #
25
+ # It is unclear how exactly this works with subordinates, and "all
26
+ # three can be passed in one request".
27
+ #
28
+ # @param options [Hash] Options for the request body
29
+ # @param headers [Hash] Additional headers to send with the request
30
+ # @return [Faraday::Response] the API response
31
+ # @see https://developer.yammer.com/docs/relationshipsjson-1
32
+ def post options={}, headers={}
33
+ @connection.post 'relationships.json', options, headers
34
+ end
35
+
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,22 @@
1
+ module Platforms
2
+ module Yammer
3
+ module Api
4
+ # Search within Yammer
5
+ # @author Benjamin Elias
6
+ # @since 0.1.0
7
+ class Search < Base
8
+
9
+ # Get search results
10
+ # @param options [Hash] Options for the request
11
+ # @param headers [Hash] Additional headers to send with the request
12
+ # @return [Faraday::Response] the API response
13
+ # @see https://developer.yammer.com/docs/searchjson
14
+ def get options={}, headers={}
15
+ @connection.get 'search.json', options, headers
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,21 @@
1
+ module Platforms
2
+ module Yammer
3
+ module Api
4
+ # The notification stream in Yammer
5
+ # @author Benjamin Elias
6
+ # @since 0.1.0
7
+ class Streams < Base
8
+
9
+ # Get the notifications stream for the current user
10
+ # @param options [Hash] Options for the request
11
+ # @param headers [Hash] Additional headers to send with the request
12
+ # @return [Faraday::Response] the API response
13
+ # @see https://developer.yammer.com/docs/streamsnotificationsjson
14
+ def notifications options={}, headers={}
15
+ @connection.get "streams/notifications.json", options, headers
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,53 @@
1
+ module Platforms
2
+ module Yammer
3
+ module Api
4
+ # Yammer's subscription (following) management
5
+ # @author Benjamin Elias
6
+ # @since 0.1.0
7
+ class Subscriptions < Base
8
+
9
+ # Check if the current user is subscribed to (following) another user
10
+ # @param id [#to_s] The ID of the User
11
+ # @param options [Hash] Options for the request
12
+ # @param headers [Hash] Additional headers to send with the request
13
+ # @return [Faraday::Response] the API response
14
+ # @see https://developer.yammer.com/docs/subscriptionsto_useridjson
15
+ def to_user id, options={}, headers={}
16
+ @connection.get "subscriptions/to_user/#{id}.json", options, headers
17
+ end
18
+
19
+ # Check if the current user is subscribed to (following) a topic (hashtag)
20
+ # @param id [#to_s] The ID of the User
21
+ # @param options [Hash] Options for the request
22
+ # @param headers [Hash] Additional headers to send with the request
23
+ # @return [Faraday::Response] the API response
24
+ # @see https://developer.yammer.com/docs/subscriptionsto_topicidjson
25
+ def to_topic id, options={}, headers={}
26
+ @connection.get "subscriptions/to_topic/#{id}.json", options, headers
27
+ end
28
+
29
+ # Subscribe to a user or topic.
30
+ # This usually involves setting target_id and target_type in the JSON body.
31
+ # @param body [#to_s] Body of the request
32
+ # @param headers [Hash] Additional headers to send with the request
33
+ # @return [Faraday::Response] the API response
34
+ # @see https://developer.yammer.com/docs/subscriptions-1
35
+ def post body=nil, headers={}
36
+ @connection.post "subscriptions.json", body, headers
37
+ end
38
+
39
+ # Unsubscribe from a user or topic.
40
+ # This usually involves setting target_id and target_type in the options hash.
41
+ # @param options [Hash] Options for the request
42
+ # @param headers [Hash] Additional headers to send with the request
43
+ # @return [Faraday::Response] the API response
44
+ # @see https://developer.yammer.com/docs/subscriptions-1
45
+ def delete options={}, headers={}
46
+ @connection.delete "subscriptions.json", options, headers
47
+ end
48
+
49
+ end
50
+ end
51
+ end
52
+ end
53
+
@@ -0,0 +1,31 @@
1
+ module Platforms
2
+ module Yammer
3
+ module Api
4
+ # Yammer's suggestions for Users to follow
5
+ # @author Benjamin Elias
6
+ # @since 0.1.0
7
+ class Suggestions < Base
8
+
9
+ # Get suggested users to follow for the current user
10
+ # @param options [Hash] Options for the request
11
+ # @param headers [Hash] Additional headers to send with the request
12
+ # @return [Faraday::Response] the API response
13
+ # @see https://developer.yammer.com/docs/suggestionsjson
14
+ def get options={}, headers={}
15
+ @connection.get "suggestions.json", options, headers
16
+ end
17
+
18
+ # Decline a suggested user to follow
19
+ # @param options [Hash] Options for the request
20
+ # @param headers [Hash] Additional headers to send with the request
21
+ # @return [Faraday::Response] the API response
22
+ # @see https://developer.yammer.com/docs/suggestionsidjson
23
+ def delete suggestion_id, options={}, headers={}
24
+ @connection.delete "suggestions/#{suggestion_id}.json", options, headers
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
31
+
@@ -0,0 +1,22 @@
1
+ module Platforms
2
+ module Yammer
3
+ module Api
4
+ # Set supervisor mode in Yammer
5
+ # @author Benjamin Elias
6
+ # @since 0.1.0
7
+ class SupervisorMode < Base
8
+
9
+ # Toggle supervisor mode
10
+ # @param options [Hash] Options for the request
11
+ # @param headers [Hash] Additional headers to send with the request
12
+ # @return [Faraday::Response] the API response
13
+ # @see https://developer.yammer.com/docs/api-requests
14
+ def toggle options={}, headers={}
15
+ @connection.post "supervisor_mode/toggle.json", options, headers
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,23 @@
1
+ module Platforms
2
+ module Yammer
3
+ module Api
4
+ # Threads in Yammer
5
+ # @author Benjamin Elias
6
+ # @since 0.1.0
7
+ class Threads < Base
8
+
9
+ # Get information about a thread
10
+ # @param id [#to_s] The thread ID
11
+ # @param options [Hash] Options for the request
12
+ # @param headers [Hash] Additional headers to send with the request
13
+ # @return [Faraday::Response] the API response
14
+ # @see https://developer.yammer.com/docs/threadsidjson
15
+ def get id, options={}, headers={}
16
+ @connection.get "threads/#{id}.json", options, headers
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,23 @@
1
+ module Platforms
2
+ module Yammer
3
+ module Api
4
+ # Topics in Yammer
5
+ # @author Benjamin Elias
6
+ # @since 0.1.0
7
+ class Topics < Base
8
+
9
+ # Get information about a topic (hashtag)
10
+ # @param id [#to_s] The topic ID
11
+ # @param options [Hash] Options for the request
12
+ # @param headers [Hash] Additional headers to send with the request
13
+ # @return [Faraday::Response] the API response
14
+ # @see https://developer.yammer.com/docs/topicsidjson
15
+ def get id, options={}, headers={}
16
+ @connection.get "topics/#{id}.json", options, headers
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,22 @@
1
+ module Platforms
2
+ module Yammer
3
+ module Api
4
+ # Uploaded file in Yammer
5
+ # @author Benjamin Elias
6
+ # @since 0.1.0
7
+ class UploadedFiles < Base
8
+
9
+ # Delete an uploaded file
10
+ # @param id [#to_s] ID of file to delete
11
+ # @param options [Hash] Options for the request
12
+ # @param headers [Hash] Additional headers to send with the request
13
+ # @return [Faraday::Response] the API response
14
+ # @see https://developer.yammer.com/docs/uploaded_filesid
15
+ def delete id, options={}, headers={}
16
+ @connection.delete "uploaded_files/#{id}.json", options, headers
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,109 @@
1
+ module Platforms
2
+ module Yammer
3
+ module Api
4
+ # Users in Yammer
5
+ # @author Benjamin Elias
6
+ # @since 0.1.0
7
+ class Users < Base
8
+
9
+ # Get Users
10
+ #
11
+ # @note Called #get_users because of the potential confusion with
12
+ # GET /users/[:id].json
13
+ #
14
+ # @param options [Hash] Options for the request
15
+ # @param headers [Hash] Additional headers to send with the request
16
+ # @return [Faraday::Response] the API response
17
+ # @see https://developer.yammer.com/docs/usersjson
18
+ def get_users options={}, headers={}
19
+ @connection.get "users.json", options, headers
20
+ end
21
+
22
+ # Get current User
23
+ # @param options [Hash] Options for the request
24
+ # @param headers [Hash] Additional headers to send with the request
25
+ # @return [Faraday::Response] the API response
26
+ # @see https://developer.yammer.com/docs/userscurrentjson
27
+ def current options={}, headers={}
28
+ @connection.get "users/current.json", options, headers
29
+ end
30
+
31
+ # Get a User by id
32
+ #
33
+ # @note Called #get_user because of the potential confusion with
34
+ # GET /users.json
35
+ #
36
+ # @param id [#to_s] id of the User
37
+ # @param options [Hash] Options for the request
38
+ # @param headers [Hash] Additional headers to send with the request
39
+ # @return [Faraday::Response] the API response
40
+ # @see https://developer.yammer.com/docs/usersidjson
41
+ def get_user id, options={}, headers={}
42
+ @connection.get "users/#{id}.json", options, headers
43
+ end
44
+
45
+ # Get a User by email
46
+ # @param address [#to_s] email of the User
47
+ # @param options [Hash] Options for the request
48
+ # @param headers [Hash] Additional headers to send with the request
49
+ # @return [Faraday::Response] the API response
50
+ # @see https://developer.yammer.com/docs/usersby_emailjsonemailuserdomaincom
51
+ def by_email address, options={}, headers={}
52
+ params = options.merge({ email: address })
53
+ @connection.get "users/by_email.json", params, headers
54
+ end
55
+
56
+ # Get a Users in a Group
57
+ # @param group_id [#to_s] id of the Group
58
+ # @param options [Hash] Options for the request
59
+ # @param headers [Hash] Additional headers to send with the request
60
+ # @return [Faraday::Response] the API response
61
+ # @see https://developer.yammer.com/docs/usersin_groupidjson
62
+ def in_group group_id, options={}, headers={}
63
+ @connection.get "users/in_group/#{group_id}.json", options, headers
64
+ end
65
+
66
+ # Get Users who have liked a Message
67
+ # @param message_id [#to_s] id of the Message
68
+ # @param options [Hash] Options for the request
69
+ # @param headers [Hash] Additional headers to send with the request
70
+ # @return [Faraday::Response] the API response
71
+ # @see https://developer.yammer.com/docs/usersliked_messagemessage_idjson
72
+ def liked_message message_id, options={}, headers={}
73
+ @connection.get "users/liked_message/#{message_id}.json", options, headers
74
+ end
75
+
76
+ # Create a new User (verified admins only)
77
+ # @param body [Hash] Options for the request
78
+ # @param headers [Hash] Additional headers to send with the request
79
+ # @return [Faraday::Response] the API response
80
+ # @see https://developer.yammer.com/docs/usersjson-1
81
+ def post body=nil, headers={}
82
+ @connection.post "users.json", body, headers
83
+ end
84
+
85
+ # Update an existing User (verified admins only)
86
+ # @param user_id [#to_s] the id of the User to update
87
+ # @param options [Hash] Options for the request
88
+ # @param headers [Hash] Additional headers to send with the request
89
+ # @return [Faraday::Response] the API response
90
+ # @see https://developer.yammer.com/docs/usersidjson-1
91
+ def put user_id, options={}, headers={}
92
+ @connection.put "users/#{user_id}.json", options, headers
93
+ end
94
+
95
+ # Delete an existing User (admins and verified admins only)
96
+ # @param user_id [#to_s] the id of the User to update
97
+ # @param options [Hash] Options for the request
98
+ # @param headers [Hash] Additional headers to send with the request
99
+ # @return [Faraday::Response] the API response
100
+ # @see https://developer.yammer.com/docs/usersidjson-2
101
+ def delete user_id, options={}, headers={}
102
+ @connection.delete "users/#{user_id}.json", options, headers
103
+ end
104
+
105
+ end
106
+ end
107
+ end
108
+ end
109
+