Class: Breacan::Client
- Inherits:
-
Object
- Object
- Breacan::Client
- Includes:
- Authentication, Api, Auth, Channels, Chat, Emoji, Files, Groups, Im, OAuth, Rtm, Search, Star, Usergroups, Users, Configurable
- Defined in:
- lib/breacan/client.rb,
lib/breacan/client/im.rb,
lib/breacan/client/api.rb,
lib/breacan/client/rtm.rb,
lib/breacan/client/auth.rb,
lib/breacan/client/chat.rb,
lib/breacan/client/star.rb,
lib/breacan/client/emoji.rb,
lib/breacan/client/files.rb,
lib/breacan/client/oauth.rb,
lib/breacan/client/users.rb,
lib/breacan/client/groups.rb,
lib/breacan/client/search.rb,
lib/breacan/client/channels.rb,
lib/breacan/client/usergroups.rb
Defined Under Namespace
Modules: Api, Auth, Channels, Chat, Emoji, Files, Groups, Im, OAuth, Rtm, Search, Star, Usergroups, Users
Constant Summary collapse
- CONVENIENCE_HEADERS =
Set.new(%i(accept content_type))
Constants included from Configurable
Breacan::Configurable::OPTIONS_KEYS
Instance Method Summary collapse
- #agent ⇒ Object
- #delete(url, options = {}) ⇒ Object
- #get(url, options = {}) ⇒ Object
- #head(url, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #patch(url, options = {}) ⇒ Object
- #post(url, options = {}) ⇒ Object
- #put(url, options = {}) ⇒ Object
- #same_options?(opts) ⇒ Boolean
Methods included from Usergroups
#usergroups_create, #usergroups_disable, #usergroups_enable, #usergroups_list, #usergroups_update, #usergroups_users_list, #usergroups_users_update
Methods included from Users
#user_by_name, #users_get_presence, #users_info, #users_list, #users_set_active, #users_set_presence
Methods included from Star
Methods included from Search
#search_all, #search_files, #search_messages
Methods included from Rtm
Methods included from OAuth
Methods included from Im
#im_close, #im_history, #im_list, #im_mark, #im_open
Methods included from Groups
#groups_archive, #groups_create, #groups_history, #groups_info, #groups_info_by_name, #groups_invite, #groups_join, #groups_kick, #groups_leave, #groups_list, #groups_mark, #groups_rename, #groups_set_purpose, #groups_set_topic, #groups_unarchive
Methods included from Files
#files_delete, #files_info, #files_list, #files_upload
Methods included from Emoji
Methods included from Chat
#chat_delete, #chat_post_message, #chat_update
Methods included from Channels
#channel_by_name, #channels_archive, #channels_create, #channels_history, #channels_info, #channels_invite, #channels_join, #channels_kick, #channels_leave, #channels_list, #channels_mark, #channels_rename, #channels_set_purpose, #channels_set_topic, #channels_unarchive
Methods included from Auth
Methods included from Api
Methods included from Configurable
#api_endpoint, #configure, keys, #options, #reset!, #web_endpoint
Methods included from Authentication
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
40 41 42 43 44 |
# File 'lib/breacan/client.rb', line 40 def initialize( = {}) Breacan::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", [key] || Breacan.instance_variable_get(:"@#{key}")) end end |
Instance Method Details
#agent ⇒ Object
74 75 76 77 78 79 |
# File 'lib/breacan/client.rb', line 74 def agent @agent ||= Sawyer::Agent.new(api_endpoint, ) do |http| http.headers[:accept] = media_type http.headers[:user_agent] = user_agent end end |
#delete(url, options = {}) ⇒ Object
66 67 68 |
# File 'lib/breacan/client.rb', line 66 def delete(url, = {}) request :delete, url, end |
#get(url, options = {}) ⇒ Object
50 51 52 |
# File 'lib/breacan/client.rb', line 50 def get(url, = {}) request :get, url, parse_query_and_convenience_headers() end |
#head(url, options = {}) ⇒ Object
70 71 72 |
# File 'lib/breacan/client.rb', line 70 def head(url, = {}) request :head, url, parse_query_and_convenience_headers() end |
#patch(url, options = {}) ⇒ Object
62 63 64 |
# File 'lib/breacan/client.rb', line 62 def patch(url, = {}) request :patch, url, end |
#post(url, options = {}) ⇒ Object
54 55 56 |
# File 'lib/breacan/client.rb', line 54 def post(url, = {}) request :post, url, end |
#put(url, options = {}) ⇒ Object
58 59 60 |
# File 'lib/breacan/client.rb', line 58 def put(url, = {}) request :put, url, end |
#same_options?(opts) ⇒ Boolean
46 47 48 |
# File 'lib/breacan/client.rb', line 46 def (opts) opts.hash == .hash end |