Module: ZQuickblox::Dialog
- Defined in:
- lib/zquickblox/dialog.rb,
lib/zquickblox/dialog/get_dialogs_request.rb,
lib/zquickblox/dialog/create_dialog_request.rb,
lib/zquickblox/dialog/update_dialog_request.rb
Defined Under Namespace
Classes: CreateDialogRequest, Dialog, GetDialogsRequest, UpdateDialogRequest
Class Method Summary collapse
- .create(login, password, params) ⇒ Object
- .get(login, password, params = nil) ⇒ Object
- .run_request(login, password, request) ⇒ Object
- .update(login, password, id, params) ⇒ Object
Class Method Details
.create(login, password, params) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/zquickblox/dialog.rb', line 19 def create(login, password, params) dialog = Dialog.new(params) params = dialog.build_params request = ZQuickblox::Dialog::CreateDialogRequest.new(params) run_request(login, password, request) dialog = Dialog.new(ZQuickblox::Util.symbolize_keys(request.response_body)) return dialog end |
.get(login, password, params = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/zquickblox/dialog.rb', line 8 def get(login, password, params=nil) request = ZQuickblox::Dialog::GetDialogsRequest.new(params) run_request(login, password, request) response = ZQuickblox::Util.symbolize_keys(request.response_body) dialogs = [] response[:items].each do |item| dialogs << (Dialog.new(ZQuickblox::Util.symbolize_keys(item))) end return dialogs end |
.run_request(login, password, request) ⇒ Object
37 38 39 40 41 |
# File 'lib/zquickblox/dialog.rb', line 37 def run_request(login, password, request) session = ZQuickblox::Session.create(login, password) request.header("QB-Token", session.token) request.execute end |
.update(login, password, id, params) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/zquickblox/dialog.rb', line 28 def update(login, password, id, params) dialog = Dialog.new(params) params = dialog.build_update_params request = ZQuickblox::Dialog::UpdateDialogRequest.new(id, params) run_request(login, password, request) dialog = Dialog.new(ZQuickblox::Util.symbolize_keys(request.response_body)) return dialog end |