Class: Breacan::Client

Inherits:
Object
  • Object
show all
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

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

#star_list

Methods included from Search

#search_all, #search_files, #search_messages

Methods included from Rtm

#rtm_start

Methods included from OAuth

#oauth_access

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

#emoji_list

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

#auth_test

Methods included from Api

#api_test

Methods included from Configurable

#api_endpoint, #configure, keys, #options, #reset!, #web_endpoint

Methods included from Authentication

#token_authenticated?

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(options = {})
  Breacan::Configurable.keys.each do |key|
    instance_variable_set(:"@#{key}", options[key] || Breacan.instance_variable_get(:"@#{key}"))
  end
end

Instance Method Details

#agentObject



74
75
76
77
78
79
# File 'lib/breacan/client.rb', line 74

def agent
  @agent ||= Sawyer::Agent.new(api_endpoint, sawyer_options) 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, options = {})
  request :delete, url, options
end

#get(url, options = {}) ⇒ Object



50
51
52
# File 'lib/breacan/client.rb', line 50

def get(url, options = {})
  request :get, url, parse_query_and_convenience_headers(options)
end

#head(url, options = {}) ⇒ Object



70
71
72
# File 'lib/breacan/client.rb', line 70

def head(url, options = {})
  request :head, url, parse_query_and_convenience_headers(options)
end

#patch(url, options = {}) ⇒ Object



62
63
64
# File 'lib/breacan/client.rb', line 62

def patch(url, options = {})
  request :patch, url, options
end

#post(url, options = {}) ⇒ Object



54
55
56
# File 'lib/breacan/client.rb', line 54

def post(url, options = {})
  request :post, url, options
end

#put(url, options = {}) ⇒ Object



58
59
60
# File 'lib/breacan/client.rb', line 58

def put(url, options = {})
  request :put, url, options
end

#same_options?(opts) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/breacan/client.rb', line 46

def same_options?(opts)
  opts.hash == options.hash
end