platforms-yammer 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +157 -0
- data/Rakefile +18 -0
- data/lib/generators/platforms/yammer/install/USAGE +11 -0
- data/lib/generators/platforms/yammer/install/install_generator.rb +29 -0
- data/lib/generators/platforms/yammer/install/templates/platforms_yammer.rb +4 -0
- data/lib/platforms/yammer.rb +15 -0
- data/lib/platforms/yammer/api.rb +39 -0
- data/lib/platforms/yammer/api/base.rb +20 -0
- data/lib/platforms/yammer/api/group_memberships.rb +35 -0
- data/lib/platforms/yammer/api/groups.rb +22 -0
- data/lib/platforms/yammer/api/invitations.rb +23 -0
- data/lib/platforms/yammer/api/messages.rb +165 -0
- data/lib/platforms/yammer/api/networks.rb +22 -0
- data/lib/platforms/yammer/api/oauth.rb +28 -0
- data/lib/platforms/yammer/api/open_graph_objects.rb +29 -0
- data/lib/platforms/yammer/api/pending_attachments.rb +34 -0
- data/lib/platforms/yammer/api/relationships.rb +39 -0
- data/lib/platforms/yammer/api/search.rb +22 -0
- data/lib/platforms/yammer/api/streams.rb +21 -0
- data/lib/platforms/yammer/api/subscriptions.rb +53 -0
- data/lib/platforms/yammer/api/suggestions.rb +31 -0
- data/lib/platforms/yammer/api/supervisor_mode.rb +22 -0
- data/lib/platforms/yammer/api/threads.rb +23 -0
- data/lib/platforms/yammer/api/topics.rb +23 -0
- data/lib/platforms/yammer/api/uploaded_files.rb +22 -0
- data/lib/platforms/yammer/api/users.rb +109 -0
- data/lib/platforms/yammer/authentication.rb +233 -0
- data/lib/platforms/yammer/client.rb +228 -0
- data/lib/platforms/yammer/configuration.rb +76 -0
- data/lib/platforms/yammer/engine.rb +27 -0
- data/lib/platforms/yammer/omni_auth_setup.rb +31 -0
- data/lib/platforms/yammer/railtie.rb +19 -0
- data/lib/platforms/yammer/version.rb +7 -0
- data/lib/tasks/platforms/yammer_tasks.rake +4 -0
- metadata +280 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 772704cd07bae935f2988fda8cfb11dd803481e20c75efe12ade6db20c4f2f1b
|
4
|
+
data.tar.gz: 33c704d4e826872402bf47d242b8336d27fb249a81d4b7055dde320277977c27
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c6ac0318074dfabecd5391679c31ebb2a9af3acd6ae11a473f228f5a6b7a1722e5ec287d3bce1edb776057e6ae3ae4b8512a61d71fb9560f4591dd7021dab6a2
|
7
|
+
data.tar.gz: 056d5f6d146b90959ae87ac75b437bee282d29eaeb5d325ee4cdfab3429337a60dac11bf6b92f7af7cd48468b31e8911832f3da8880a590f0524b83bec57fed8
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2020 Benjamin Elias
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
# Platforms::Yammer
|
2
|
+
|
3
|
+
This is an easy-to-use Ruby library which takes all the hard work out of writing a Yammer App.
|
4
|
+
|
5
|
+
Platforms::Yammer supports all documented API endpoints, and has the flexibility of being able to call new, updated, or undocumented API endpoints too.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
This gem consists of two main parts. You need to have already [created an App](https://developer.yammer.com/docs/getting-started) in Yammer before using this gem.
|
10
|
+
|
11
|
+
### 1. Authentication
|
12
|
+
|
13
|
+
Assuming the "Redirect URI" for your App is `https://www.myapp.com/auth/yammer/callback`, in your routes file set that route to a controller of your choice. `SessionsController` is used in the examples below..
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
# config/routes.rb
|
17
|
+
|
18
|
+
Rails.application.routes.draw do
|
19
|
+
# ...
|
20
|
+
match '/auth/:provider/callback', to: 'sessions#callback', via: [:get, :post]
|
21
|
+
# ...
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
In the Sessions controller, include the `Platforms::Yammer::Authentication` module and call `save_identity` in the `callback` method:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
# app/controllers/sessions_controller
|
29
|
+
|
30
|
+
class SessionsController < ApplicationController
|
31
|
+
include Platforms::Yammer::Authentication
|
32
|
+
|
33
|
+
before_action :set_token
|
34
|
+
|
35
|
+
def callback
|
36
|
+
# ...
|
37
|
+
save_identity
|
38
|
+
# ...
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
This will give you instance variables `@platforms_user`, `@platforms_network`, `@token`, and `@switch_network_ids`, giving you details of the Yammer user.
|
45
|
+
Some of this information will be useful to store in a [session](https://guides.rubyonrails.org/security.html#session-storage).
|
46
|
+
See {Platforms::Yammer::Authentication#save_identity} for more details.
|
47
|
+
|
48
|
+
This callback method also has access to more detailed information about the logged-in user through `request.env[omniauth.auth']`. More information about the data that is stored in that variable can be found in the OmniAuth [Auth Hash Schema](https://github.com/omniauth/omniauth/wiki/Auth-Hash-Schema) description.
|
49
|
+
|
50
|
+
Switching between Yammer Networks is achieved through {Platforms::Yammer::Authentication#switch_identity}, which is treated as a regular API request.
|
51
|
+
|
52
|
+
### 2. API Requests
|
53
|
+
|
54
|
+
Use the `@token`, found during [Authentication](#authentication), to create a new {Platforms::Yammer::Client}. That client can then be used to make API requests.
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
client = Platforms::Yammer::Client.new(@token)
|
58
|
+
messages = client.messages.get
|
59
|
+
```
|
60
|
+
|
61
|
+
More detail on the configuration options for the {Platforms::Yammer::Client} can be found in the class documentation, including how to change the handling of HTTP errors.
|
62
|
+
|
63
|
+
Extra request parameters and headers can generally be passed in the subsequent parameters to a method:
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
messages = client.messages.get { :older_than => 123 }, { :custom => :header }
|
67
|
+
```
|
68
|
+
|
69
|
+
## Installation
|
70
|
+
|
71
|
+
Add this line to your application's Gemfile:
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
gem 'platforms-yammer'
|
75
|
+
```
|
76
|
+
|
77
|
+
And then execute:
|
78
|
+
|
79
|
+
```bash
|
80
|
+
$ bundle
|
81
|
+
```
|
82
|
+
|
83
|
+
Or install it yourself as:
|
84
|
+
|
85
|
+
```bash
|
86
|
+
$ gem install platforms-yammer
|
87
|
+
```
|
88
|
+
|
89
|
+
Once the gem is installed, from your Rails directory you can run the following generator to complete the installation:
|
90
|
+
|
91
|
+
```bash
|
92
|
+
$ rails generate platforms:yammer:install
|
93
|
+
```
|
94
|
+
|
95
|
+
This will:
|
96
|
+
|
97
|
+
* Complete the installation of the [Platforms::Core](https://github.com/collabital/platforms-core) gem; and
|
98
|
+
* Add a basic initializer to `config/initializers/platforms_yammer.rb`.
|
99
|
+
|
100
|
+
## Configuration
|
101
|
+
|
102
|
+
REST-based APIs require authentication to get started. Please refer to the Yammer documentation for how to configure an integration.
|
103
|
+
|
104
|
+
### Configuring the Keys
|
105
|
+
|
106
|
+
Edit the initializer to add the credentials of your Yammer integration:
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
# config/initializers/platforms_yammer.rb
|
110
|
+
|
111
|
+
```
|
112
|
+
|
113
|
+
### Starting a New App
|
114
|
+
|
115
|
+
Your application needs to have at least `Network` and `User` models. These can be created by calling the generator:
|
116
|
+
|
117
|
+
```bash
|
118
|
+
$ rails generate platforms:core:network foo some_info:string
|
119
|
+
$ rails generate platforms:core:user bar user more_info:string
|
120
|
+
$ rake db:migrate
|
121
|
+
```
|
122
|
+
|
123
|
+
Typically these would actually be called "Network" and "User", but here we have called them "Foo" and "Bar".
|
124
|
+
|
125
|
+
For more detailed instructions, refer to the documentation for configuring [Platforms::Core](https://github.com/collabital/platforms-core#configuration).
|
126
|
+
|
127
|
+
### Adding to an Existing App
|
128
|
+
|
129
|
+
If you already have `Network` and `User` models (which let's assume are called "Foo" and "Bar" respectively), you can configure them for Platforms::Core by using the generator with the `--existing-model` flag:
|
130
|
+
|
131
|
+
```bash
|
132
|
+
$ rails generate platforms:core:network foo --existing-model
|
133
|
+
$ rails generate platforms:core:user bar --existing-model
|
134
|
+
$ rake db:migrate
|
135
|
+
```
|
136
|
+
|
137
|
+
For more detailed instructions, refer to the documentation for configuring [Platforms::Core](https://github.com/collabital/platforms-core#configuration).
|
138
|
+
|
139
|
+
## Documentation
|
140
|
+
|
141
|
+
You can generate the documentation by running
|
142
|
+
|
143
|
+
```bash
|
144
|
+
$ rake yard
|
145
|
+
```
|
146
|
+
|
147
|
+
If not everything is documented, check this with:
|
148
|
+
```bash
|
149
|
+
$ yard stats --list-undoc
|
150
|
+
```
|
151
|
+
|
152
|
+
## Contributing
|
153
|
+
|
154
|
+
Please see [CONTRIBUTING.md](CONTRIBUTING.md).
|
155
|
+
|
156
|
+
## License
|
157
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'yard'
|
8
|
+
YARD::Rake::YardocTask.new do |t|
|
9
|
+
end
|
10
|
+
|
11
|
+
APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
|
12
|
+
load 'rails/tasks/engine.rake'
|
13
|
+
|
14
|
+
load 'rails/tasks/statistics.rake'
|
15
|
+
|
16
|
+
require 'bundler/gem_tasks'
|
17
|
+
|
18
|
+
task :default => ["app:spec"]
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Description:
|
2
|
+
This will install the required migrations, and set up initializers
|
3
|
+
|
4
|
+
Example:
|
5
|
+
rails generate platforms:yammer:install
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
The initializer in config/initializers/platforms_yammer.rb
|
9
|
+
Run $ rails generate platforms:core:install
|
10
|
+
|
11
|
+
Note that it will not run the migrations
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Platforms
|
4
|
+
module Yammer
|
5
|
+
|
6
|
+
# Simplify the installation of Platforms::Yammer by creating an
|
7
|
+
# initializer file and installing the migrations.
|
8
|
+
# This does not run the migrations.
|
9
|
+
# @author Benjamin Elias
|
10
|
+
# @since 0.1.0
|
11
|
+
class InstallGenerator < Rails::Generators::Base
|
12
|
+
source_root File.expand_path('templates', __dir__)
|
13
|
+
|
14
|
+
# Create config/initializers/platforms_yammer.rb according
|
15
|
+
# to the template.
|
16
|
+
def copy_initializer_file
|
17
|
+
copy_file "platforms_yammer.rb", "config/initializers/platforms_yammer.rb"
|
18
|
+
end
|
19
|
+
|
20
|
+
# Install Platforms::Core.
|
21
|
+
# This uses the built in Rails generate method to call the
|
22
|
+
# other gem's installer.
|
23
|
+
def install_core
|
24
|
+
generate "platforms:core:install"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "platforms/yammer/authentication"
|
2
|
+
require "platforms/yammer/configuration"
|
3
|
+
require "platforms/yammer/engine"
|
4
|
+
require "platforms/yammer/railtie"
|
5
|
+
require "platforms/yammer/client"
|
6
|
+
|
7
|
+
require "generators/platforms/yammer/install/install_generator"
|
8
|
+
|
9
|
+
# A flexible module to allow integrations with a number of enterprise social
|
10
|
+
# and collaboration platforms with Rails.
|
11
|
+
module Platforms
|
12
|
+
# A gem to build Yammer integrations with Rails
|
13
|
+
module Yammer
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "platforms/yammer/api/base"
|
2
|
+
require "platforms/yammer/api/messages"
|
3
|
+
require "platforms/yammer/api/pending_attachments"
|
4
|
+
require "platforms/yammer/api/uploaded_files"
|
5
|
+
require "platforms/yammer/api/threads"
|
6
|
+
require "platforms/yammer/api/topics"
|
7
|
+
require "platforms/yammer/api/group_memberships"
|
8
|
+
require "platforms/yammer/api/groups"
|
9
|
+
require "platforms/yammer/api/users"
|
10
|
+
require "platforms/yammer/api/relationships"
|
11
|
+
require "platforms/yammer/api/streams"
|
12
|
+
require "platforms/yammer/api/suggestions"
|
13
|
+
require "platforms/yammer/api/subscriptions"
|
14
|
+
require "platforms/yammer/api/invitations"
|
15
|
+
require "platforms/yammer/api/search"
|
16
|
+
require "platforms/yammer/api/networks"
|
17
|
+
require "platforms/yammer/api/open_graph_objects"
|
18
|
+
require "platforms/yammer/api/oauth"
|
19
|
+
require "platforms/yammer/api/supervisor_mode"
|
20
|
+
|
21
|
+
module Platforms
|
22
|
+
module Yammer
|
23
|
+
# Module for all Yammer's API endpoints
|
24
|
+
#
|
25
|
+
# These are organised per-class in the 'directory' of the namespace.
|
26
|
+
# Methods are generally called 'get', 'post', and 'delete' for simple
|
27
|
+
# requests and named methods if more complex.
|
28
|
+
#
|
29
|
+
# For example:
|
30
|
+
# * {Messages#get} maps to GET /messages.json
|
31
|
+
# * {Messages#post} maps to POST /messages.json
|
32
|
+
# * {Messages#my_feed} maps to GET /messages/my_feed.json
|
33
|
+
#
|
34
|
+
# @author Benjamin Elias
|
35
|
+
# @since 0.1.0
|
36
|
+
module Api
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Platforms
|
2
|
+
module Yammer
|
3
|
+
module Api
|
4
|
+
# Base class taking care of common setup for Platforms::Yammer::Api
|
5
|
+
# classes.
|
6
|
+
# @author Benjamin Elias
|
7
|
+
# @since 0.1.0
|
8
|
+
class Base
|
9
|
+
|
10
|
+
# Initialize with a Faraday connection
|
11
|
+
# @param [Faraday::Connection] connection The connection to use
|
12
|
+
def initialize connection
|
13
|
+
@connection = connection
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Platforms
|
2
|
+
module Yammer
|
3
|
+
module Api
|
4
|
+
# Group memberships in Yammer
|
5
|
+
# @author Benjamin Elias
|
6
|
+
# @since 0.1.0
|
7
|
+
class GroupMemberships < Base
|
8
|
+
|
9
|
+
# Join a Group
|
10
|
+
# @param group_id [#to_s] The ID of the Group to join
|
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/group_membershipsjsongroup_idid
|
15
|
+
def post group_id, options={}, headers={}
|
16
|
+
body = options.merge({ group_id: group_id})
|
17
|
+
@connection.post 'group_memberships.json', body, headers
|
18
|
+
end
|
19
|
+
|
20
|
+
# Leave a Group
|
21
|
+
# @param group_id [#to_s] ID of Group to leave
|
22
|
+
# @param options [Hash] Options for the request
|
23
|
+
# @param headers [Hash] Additional headers to send with the request
|
24
|
+
# @return [Faraday::Response] the API response
|
25
|
+
# @see https://developer.yammer.com/docs/group_membershipsjsongroup_idid-1
|
26
|
+
def delete group_id, options={}, headers={}
|
27
|
+
params = options.merge({group_id: group_id})
|
28
|
+
@connection.delete 'group_memberships.json', params, headers
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Platforms
|
2
|
+
module Yammer
|
3
|
+
module Api
|
4
|
+
# Groups in Yammer
|
5
|
+
# @author Benjamin Elias
|
6
|
+
# @since 0.1.0
|
7
|
+
class Groups < Base
|
8
|
+
|
9
|
+
# Get group memberships for a user
|
10
|
+
# @param user_id [#to_s] The user to query for memberships
|
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/groupsfor_useruser_idjson
|
15
|
+
def for_user user_id, options={}, headers={}
|
16
|
+
@connection.get "groups/for_user/#{user_id}.json", options, headers
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Platforms
|
2
|
+
module Yammer
|
3
|
+
module Api
|
4
|
+
# Invite people to a Yammer network
|
5
|
+
# @author Benjamin Elias
|
6
|
+
# @since 0.1.0
|
7
|
+
class Invitations < Base
|
8
|
+
|
9
|
+
# Post invitations
|
10
|
+
# @param body [#to_s] Body of the request. Typically has email and may
|
11
|
+
# have group_id (optional).
|
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/invitationsjson
|
15
|
+
def post body=nil, headers={}
|
16
|
+
@connection.post "invitations.json", body, headers
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,165 @@
|
|
1
|
+
module Platforms
|
2
|
+
module Yammer
|
3
|
+
module Api
|
4
|
+
# Messaging endpoints for the Yammer API
|
5
|
+
# @author Benjamin Elias
|
6
|
+
# @since 0.1.0
|
7
|
+
class Messages < Base
|
8
|
+
|
9
|
+
# Get Messages from my feed
|
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/messagesmy_feedjson
|
14
|
+
def my_feed options={}, headers={}
|
15
|
+
@connection.get "messages/my_feed.json", options, headers
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get Messages through the algorithmic feed
|
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/messagesalgojson
|
23
|
+
def algo options={}, headers={}
|
24
|
+
@connection.get "messages/algo.json", options, headers
|
25
|
+
end
|
26
|
+
|
27
|
+
# Get all messages
|
28
|
+
# @param options [Hash] Options for the request
|
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/messagesjson
|
32
|
+
def get options={}, headers={}
|
33
|
+
@connection.get "messages.json", options, headers
|
34
|
+
end
|
35
|
+
|
36
|
+
# Get messages in 'following' feed
|
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/messagesfollowingjson
|
41
|
+
def following options={}, headers={}
|
42
|
+
@connection.get "messages/following.json", options, headers
|
43
|
+
end
|
44
|
+
|
45
|
+
# Sent messages
|
46
|
+
# @param options [Hash] Options for the request
|
47
|
+
# @param headers [Hash] Additional headers to send with the request
|
48
|
+
# @return [Faraday::Response] the API response
|
49
|
+
# @see https://developer.yammer.com/docs/messagessentjson
|
50
|
+
def sent options={}, headers={}
|
51
|
+
@connection.get "messages/sent.json", options, headers
|
52
|
+
end
|
53
|
+
|
54
|
+
# Private messages
|
55
|
+
# @param options [Hash] Options for the request
|
56
|
+
# @param headers [Hash] Additional headers to send with the request
|
57
|
+
# @return [Faraday::Response] the API response
|
58
|
+
# @see https://developer.yammer.com/docs/messagesprivatejson
|
59
|
+
def private options={}, headers={}
|
60
|
+
@connection.get "messages/private.json", options, headers
|
61
|
+
end
|
62
|
+
|
63
|
+
# Received messages
|
64
|
+
# @param options [Hash] Options for the request
|
65
|
+
# @param headers [Hash] Additional headers to send with the request
|
66
|
+
# @return [Faraday::Response] the API response
|
67
|
+
# @see https://developer.yammer.com/docs/messagesreceivedjson
|
68
|
+
def received options={}, headers={}
|
69
|
+
@connection.get "messages/received.json", options, headers
|
70
|
+
end
|
71
|
+
|
72
|
+
# Messages in a thread
|
73
|
+
# @param thread_id [#to_s] The thread ID
|
74
|
+
# @param options [Hash] Options for the request
|
75
|
+
# @param headers [Hash] Additional headers to send with the request
|
76
|
+
# @return [Faraday::Response] the API response
|
77
|
+
# @see https://developer.yammer.com/docs/messagesin_threadthreadidjson
|
78
|
+
def in_thread thread_id, options={}, headers={}
|
79
|
+
@connection.get "messages/in_thread/#{thread_id}.json", options, headers
|
80
|
+
end
|
81
|
+
|
82
|
+
# Messages in a group
|
83
|
+
# @param group_id [#to_s] The group ID
|
84
|
+
# @param options [Hash] Options for the request
|
85
|
+
# @param headers [Hash] Additional headers to send with the request
|
86
|
+
# @return [Faraday::Response] the API response
|
87
|
+
# @see https://developer.yammer.com/docs/messagesin_groupgroup_id
|
88
|
+
def in_group group_id, options={}, headers={}
|
89
|
+
@connection.get "messages/in_group/#{group_id}.json", options, headers
|
90
|
+
end
|
91
|
+
|
92
|
+
# Messages about an Open Graph object
|
93
|
+
# @param id [#to_s] The Open Graph ID to filter by
|
94
|
+
# @param options [Hash] Options for the request
|
95
|
+
# @param headers [Hash] Additional headers to send with the request
|
96
|
+
# @return [Faraday::Response] the API response
|
97
|
+
# @see https://developer.yammer.com/docs/messagesopen_graph_objects
|
98
|
+
def open_graph_objects id, options={}, headers={}
|
99
|
+
@connection.get "messages/open_graph_objects/#{id}.json", options, headers
|
100
|
+
end
|
101
|
+
|
102
|
+
# Messages about a topic
|
103
|
+
# @param topic_id [#to_s] The topic to filter by
|
104
|
+
# @param options [Hash] Options for the request
|
105
|
+
# @param headers [Hash] Additional headers to send with the request
|
106
|
+
# @return [Faraday::Response] the API response
|
107
|
+
# @see https://developer.yammer.com/docs/messagesabout_topicidjson
|
108
|
+
def about_topic topic_id, options={}, headers={}
|
109
|
+
@connection.get "messages/about_topic/#{topic_id}.json", options, headers
|
110
|
+
end
|
111
|
+
|
112
|
+
# Post a new message
|
113
|
+
# @param body [#to_s] Body of the request
|
114
|
+
# @param headers [Hash] Additional headers to send with the request
|
115
|
+
# @return [Faraday::Response] the API response
|
116
|
+
# @see https://developer.yammer.com/docs/messages-json-post
|
117
|
+
def post body, headers={}
|
118
|
+
@connection.post "messages.json", body, headers
|
119
|
+
end
|
120
|
+
|
121
|
+
# E-mail a copy of the message to the current user
|
122
|
+
# @param message_id [#to_s] The ID of the message to delete
|
123
|
+
# @param body [#to_s] Body of the request (should not need to be used)
|
124
|
+
# @param headers [Hash] Additional headers to send with the request
|
125
|
+
# @return [Faraday::Response] the API response
|
126
|
+
# @see https://developer.yammer.com/docs/messagesemail
|
127
|
+
def email message_id, body=nil, headers={}
|
128
|
+
@connection.post "messages/email.json?message_id=#{message_id}", body, headers
|
129
|
+
end
|
130
|
+
|
131
|
+
# Like a message
|
132
|
+
# @param message_id [#to_s] The ID of the message to delete
|
133
|
+
# @param body [#to_s] Body of the request (should not need to be used)
|
134
|
+
# @param headers [Hash] Additional headers to send with the request
|
135
|
+
# @return [Faraday::Response] the API response
|
136
|
+
# @see https://developer.yammer.com/docs/messagesliked_bycurrentjsonmessage_idid
|
137
|
+
def like message_id, body=nil, headers={}
|
138
|
+
@connection.post "messages/liked_by/current.json?message_id=#{message_id}", body, headers
|
139
|
+
end
|
140
|
+
|
141
|
+
# Unlike a message
|
142
|
+
# @param message_id [#to_s] The ID of the message to delete
|
143
|
+
# @param options [Hash] Options for the request
|
144
|
+
# @param headers [Hash] Additional headers to send with the request
|
145
|
+
# @return [Faraday::Response] the API response
|
146
|
+
# @see https://developer.yammer.com/docs/messagesliked_bycurrentjsonmessage_idid-1
|
147
|
+
def unlike message_id, options=nil, headers={}
|
148
|
+
@connection.delete "messages/liked_by/current.json?message_id=#{message_id}", options, headers
|
149
|
+
end
|
150
|
+
|
151
|
+
# Delete a message
|
152
|
+
# @param message_id [#to_s] The ID of the message to delete
|
153
|
+
# @param options [Hash] Options for the request
|
154
|
+
# @param headers [Hash] Additional headers to send with the request
|
155
|
+
# @return [Faraday::Response] the API response
|
156
|
+
# @see https://developer.yammer.com/docs/messagesid
|
157
|
+
def delete message_id, options=nil, headers={}
|
158
|
+
@connection.delete "messages/#{message_id}.json", options, headers
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|