Class: ChatworkTo::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/chatwork_to/client.rb

Constant Summary collapse

CHATWORK_URL =
'https://www.chatwork.com'
CHATWORK_ALL_JA =
'chatwork_all_ja.min.js'
CONSTANTS_REGEXP =
{
  myid: /var myid( *)=( *)'(.*)'/,
  ln:   /var LANGUAGE( *)=( *)'(.*)'/,
  _t:   /var ACCESS_TOKEN( *)=( *)'(.*)'/,
  _v:   /var client_ver( *)=( *)'(.*)'/,
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(email, pass) ⇒ Client

Returns a new instance of Client.



12
13
14
15
16
17
18
# File 'lib/chatwork_to/client.rb', line 12

def initialize(email, pass)
  @config = {}
  @chatwork_email = email
  @chatwork_pass  = pass
  @mechanize     = ::Mechanize.new
  prepare
end

Instance Method Details

#init_loadObject



20
21
22
# File 'lib/chatwork_to/client.rb', line 20

def init_load
  JSON.parse(@mechanize.get(build_init_load_url).body)
end

#load_chat(room_id, last_chat_id) ⇒ Object



24
25
26
# File 'lib/chatwork_to/client.rb', line 24

def load_chat(room_id, last_chat_id)
  JSON.parse(@mechanize.get(build_load_chat_url(room_id, last_chat_id)).body)
end