Class: ChatWork::Client

Defined Under Namespace

Modules: ContactsMethods, FileMethods, IncomingRequestMethods, InvitationLinkMethods, MeMethods, MemberMethods, MessageMethods, MyStatusMethods, MyTaskMethods, RoomMethods, TaskMethods

Instance Method Summary collapse

Methods included from TaskMethods

#create_task, #find_task, #get_tasks, #update_task_status

Methods included from RoomMethods

#create_room, #destroy_room, #find_room, #get_rooms, #update_room

Methods included from MyTaskMethods

#get_my_tasks

Methods included from MyStatusMethods

#get_my_status

Methods included from MessageMethods

#create_message, #destroy_message, #find_message, #get_messages, #read_message, #unread_message, #update_message

Methods included from MemberMethods

#get_members, #update_all_members

Methods included from MeMethods

#get_me

Methods included from InvitationLinkMethods

#create_invitation_link, #destroy_invitation_link, #get_invitation_link, #update_invitation_link

Methods included from IncomingRequestMethods

#destroy_incoming_request, #get_incoming_requests, #update_incoming_request

Methods included from FileMethods

#create_file, #find_file, #get_files

Methods included from ContactsMethods

#get_contacts

Methods inherited from BaseClient

#handle_response

Methods included from Converter

#boolean_to_integer

Constructor Details

#initialize(api_key: nil, access_token: nil, api_base: nil, api_version: nil) ⇒ Client

Note:

Either api_key or access_token is required

Returns a new instance of Client.

Parameters:

  • api_key (String) (defaults to: nil)
  • access_token (String) (defaults to: nil)
  • api_base (String) (defaults to: nil)

    default is ChatWork.api_base

  • api_version (String) (defaults to: nil)


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/chatwork/client.rb', line 32

def initialize(api_key: nil, access_token: nil, api_base: nil, api_version: nil)
  api_base    ||= ChatWork.api_base
  api_version ||= ChatWork.api_version

  header =
    if api_key
      { "X-ChatWorkToken" => api_key }
    elsif access_token
      { "Authorization" => "Bearer #{access_token}" }
    else
      raise "Either api_key or access_token is required"
    end

  super(api_base: api_base, api_version: api_version, header: header)
end