Class: Platforms::Yammer::Client
- Inherits:
-
Object
- Object
- Platforms::Yammer::Client
- Defined in:
- lib/platforms/yammer/client.rb
Overview
A REST client for Yammer
Assumes all of the OAuth2 authentication has been done previously, and a valid token is available.
Uses Faraday to conduct HTTP requests and receive responses, with OAuth2 FaradayMiddleWare.
Instance Attribute Summary collapse
-
#connection ⇒ Faraday::Connection
readonly
Giving access to the underlying Faraday connection allows setting headers and other more detailed configuration.
Instance Method Summary collapse
-
#group_memberships ⇒ Api::GroupMemberships
Create new Api::GroupMemberships using #connection.
-
#groups ⇒ Api::Groups
Create new Api::Groups using #connection.
-
#initialize(token, errors = true) {|f| ... } ⇒ Client
constructor
Initialize class with a token.
-
#invitations ⇒ Api::Invitations
Create new Api::Invitations using #connection.
-
#messages ⇒ Api::Messages
Create new Api::Messages using #connection.
-
#networks ⇒ Api::Networks
Create new Api::Networks using #connection.
-
#oauth ⇒ Api::Oauth
Create new Api::Oauth using #connection.
-
#open_graph_objects ⇒ Api::OpenGraphObjets
Create new Api::OpenGraphObjects using #connection.
-
#pending_attachments ⇒ Api::PendingAttachments
Create new Api::PendingAttachments using #connection.
-
#relationships ⇒ Api::Relationships
Create new Api::Relationships using #connection.
-
#request(method, endpoint, options = {}, headers = {}) ⇒ Faraday::Response
Generic request, can be used for new, updated, or undocumented endpoints.
-
#search ⇒ Api::Search
Create new Api::Search using #connection.
-
#streams ⇒ Api::Streams
Create new Api::Streams using #connection.
-
#subscriptions ⇒ Api::Subscriptions
Create new Api::Subscriptions using #connection.
-
#suggestions ⇒ Api::Suggestions
Create new Api::Suggestions using #connection.
-
#supervisor_mode ⇒ Api::SupervisorMode
Create new Api::SupervisorMode using #connection.
-
#threads ⇒ Api::Threads
Create new Api::Threads using #connection.
-
#topics ⇒ Api::Topics
Create new Api::Topics using #connection.
-
#uploaded_files ⇒ Api::UploadedFiles
Create new Api::UploadedFiles using #connection.
-
#users ⇒ Api::Users
Create new Api::Users using #connection.
Constructor Details
#initialize(token, errors = true) {|f| ... } ⇒ Client
Initialize class with a token
Construct a new Faraday #connection which uses the token provided. Uses OAuth2 with Bearer authentication.
Requests are sent with JSON encoding by default, and responses are parsed as JSON if the Content-type header of the response is set accordingly.
To change the default base URL, use the Platforms::Yammer::Configuration settings in an initializer.
Connection configuration can be performed using the yield block, or can be done through the #connection variable as shown in the examples.
To override default connection headers with request-specific headers, use the headers parameter in any of the request functions.
Errors can be turned off if the application explicitly checks the HTTP status codes. By default these are left on.
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/platforms/yammer/client.rb', line 57 def initialize token, errors=true, &block api_base = Platforms::Yammer.configuration.api_base @connection = ::Faraday.new api_base do |faraday| faraday.request :oauth2, token, token_type: 'bearer' faraday.request :json faraday.response :json, :content_type => /\bjson$/ faraday.use Faraday::Response::RaiseError if errors block.call(faraday) if block_given? end end |
Instance Attribute Details
#connection ⇒ Faraday::Connection (readonly)
Giving access to the underlying Faraday connection allows setting headers and other more detailed configuration.
22 23 24 |
# File 'lib/platforms/yammer/client.rb', line 22 def connection @connection end |
Instance Method Details
#group_memberships ⇒ Api::GroupMemberships
Create new Api::GroupMemberships using #connection
124 125 126 |
# File 'lib/platforms/yammer/client.rb', line 124 def group_memberships Api::GroupMemberships.new @connection end |
#groups ⇒ Api::Groups
Create new Api::Groups using #connection
132 133 134 |
# File 'lib/platforms/yammer/client.rb', line 132 def groups Api::Groups.new @connection end |
#invitations ⇒ Api::Invitations
Create new Api::Invitations using #connection
180 181 182 |
# File 'lib/platforms/yammer/client.rb', line 180 def invitations Api::Invitations.new @connection end |
#messages ⇒ Api::Messages
Create new Api::Messages using #connection
84 85 86 |
# File 'lib/platforms/yammer/client.rb', line 84 def Api::Messages.new @connection end |
#networks ⇒ Api::Networks
Create new Api::Networks using #connection
196 197 198 |
# File 'lib/platforms/yammer/client.rb', line 196 def networks Api::Networks.new @connection end |
#oauth ⇒ Api::Oauth
Create new Api::Oauth using #connection
222 223 224 |
# File 'lib/platforms/yammer/client.rb', line 222 def oauth Api::Oauth.new @connection end |
#open_graph_objects ⇒ Api::OpenGraphObjets
Create new Api::OpenGraphObjects using #connection
204 205 206 |
# File 'lib/platforms/yammer/client.rb', line 204 def open_graph_objects Api::OpenGraphObjects.new @connection end |
#pending_attachments ⇒ Api::PendingAttachments
Create new Api::PendingAttachments using #connection
92 93 94 |
# File 'lib/platforms/yammer/client.rb', line 92 def Api::PendingAttachments.new @connection end |
#relationships ⇒ Api::Relationships
Create new Api::Relationships using #connection
148 149 150 |
# File 'lib/platforms/yammer/client.rb', line 148 def relationships Api::Relationships.new @connection end |
#request(method, endpoint, options = {}, headers = {}) ⇒ Faraday::Response
Generic request, can be used for new, updated, or undocumented endpoints.
76 77 78 |
# File 'lib/platforms/yammer/client.rb', line 76 def request method, endpoint, ={}, headers={} connection.send(method, endpoint, , headers) end |
#search ⇒ Api::Search
Create new Api::Search using #connection
188 189 190 |
# File 'lib/platforms/yammer/client.rb', line 188 def search Api::Search.new @connection end |
#streams ⇒ Api::Streams
Create new Api::Streams using #connection
156 157 158 |
# File 'lib/platforms/yammer/client.rb', line 156 def streams Api::Streams.new @connection end |
#subscriptions ⇒ Api::Subscriptions
Create new Api::Subscriptions using #connection
172 173 174 |
# File 'lib/platforms/yammer/client.rb', line 172 def subscriptions Api::Subscriptions.new @connection end |
#suggestions ⇒ Api::Suggestions
Create new Api::Suggestions using #connection
164 165 166 |
# File 'lib/platforms/yammer/client.rb', line 164 def suggestions Api::Suggestions.new @connection end |
#supervisor_mode ⇒ Api::SupervisorMode
Create new Api::SupervisorMode using #connection
213 214 215 |
# File 'lib/platforms/yammer/client.rb', line 213 def supervisor_mode Api::SupervisorMode.new @connection end |
#threads ⇒ Api::Threads
Create new Api::Threads using #connection
108 109 110 |
# File 'lib/platforms/yammer/client.rb', line 108 def threads Api::Threads.new @connection end |
#topics ⇒ Api::Topics
Create new Api::Topics using #connection
116 117 118 |
# File 'lib/platforms/yammer/client.rb', line 116 def topics Api::Topics.new @connection end |
#uploaded_files ⇒ Api::UploadedFiles
Create new Api::UploadedFiles using #connection
100 101 102 |
# File 'lib/platforms/yammer/client.rb', line 100 def uploaded_files Api::UploadedFiles.new @connection end |
#users ⇒ Api::Users
Create new Api::Users using #connection
140 141 142 |
# File 'lib/platforms/yammer/client.rb', line 140 def users Api::Users.new @connection end |