Module: Qismo::Api
Overview
API wrappers
Instance Method Summary collapse
-
#add_room_tag(room_id:, tag:) ⇒ Qismo::Objects::Tag
Add room tag.
-
#allocate_agent(source:, channel_id:, ignore_availability: false) ⇒ Qismo::Objects::User
Get agent that can be assigned to room.
-
#allocate_and_assign_agent(room_id:, ignore_availability: false) ⇒ Qismo::Objects::User
Get agent that can be allocated to room and automatically assign them.
-
#assign_agent(room_id:, agent_id:, replace_latest_agent: false, max_agent: nil) ⇒ Qismo::Objects::User
Assign an agent to a room.
-
#create_auth_webhook(url:, enabled: true) ⇒ Qismo::Objects::Webhook
Set auth webhook.
-
#create_new_session_webhook(url:, enabled: true) ⇒ Qismo::Objects::Webhook
Set new session webhook.
-
#create_resolve_webhook(url:, enabled: true) ⇒ Qismo::Objects::Webhook
Set resolve webhook.
-
#create_room_info(room_id:, info:) ⇒ Array<Qismo::Objects::RoomAdditionalInfo>
Set room additional info.
-
#delete_room_tag(room_id:, tag_id:) ⇒ TrueClass
Delete room tag.
-
#disable_bot_in_room(room_id:) ⇒ TrueClass
Disable chatbot in room.
-
#enable_bot_in_room(room_id:) ⇒ TrueClass
Enable chabot in room.
-
#get_agent(agent_id:) ⇒ Qismo::Objects::User
Get agent by id.
-
#get_auth_webhook ⇒ Qismo::Objects::Webhook
Get auth webhook config.
-
#get_new_session_webhook ⇒ Qismo::Objects::Webhook
Get new session webhook config.
-
#get_office_hours ⇒ Qismo::Objects::OfficeHour
Get office hour config.
- #get_profile ⇒ Object
-
#get_resolve_webhook ⇒ Qismo::Objects::Webhook
Get resolve webhook config.
-
#get_room(room_id:) ⇒ Qismo::Objects::CustomerRoom
Get room by id.
-
#get_wa_broadcast_job(broadcast_job_id:) ⇒ Qismo::Objects::BroadcastJob
Get wa broadcast job by id.
-
#get_wa_credit ⇒ Qismo::Objects::WaCreditInfo
Get Whatsapp channel credit info.
-
#handover_room_from_bot(room_id:) ⇒ TrueClass
Handover room from chatbot to human agent.
-
#handover_room_from_bot_to_division(room_id:, roles:, find_online_agent: true) ⇒ TrueClass, FalseClass
Handover room from chatbot to human agent in specific divisions.
-
#initiate_widget_chat(user_id:, name:, nonce: nil, channel_id: nil, extras: nil, reset_extras: false, room_badge: nil, avatar: nil, allocate_agent: nil, user_properties: nil, sdk_user_extras: nil, timezone_offset: nil, notes: nil, phone_number: nil, email: nil) ⇒ Qismo::Objects::CustomerRoom
Initiate chat using Qiscus widget channel.
-
#list_agents(page: 1, limit: 10, search: nil, scope: nil) ⇒ Qismo::Collection<Qismo::Objects::User>
List agents.
-
#list_agents_by_divisions(division_ids, page: 1, limit: 10, is_available: nil, sort: "asc") ⇒ Qismo::Collection<Qismo::Objects::User>
List agents by divisions.
-
#list_agents_by_ids(agent_ids:) ⇒ Qismo::Collection<Qismo::Objects::User>
List agents by ids.
-
#list_available_agents(room_id:, is_available_in_room: true, search: nil, limit: 15, cursor_after: nil, cursor_before: nil) ⇒ Qismo::Collection<Qismo::Objects::User>
List available agents in room.
-
#list_channels ⇒ Qismo::Objects::ListChannelsResponse
List integrated channels.
-
#list_other_agents(room_id:, search: nil, limit: 15, cursor_after: nil, cursor_before: nil) ⇒ Qismo::Collection<Qismo::Objects::User>
List agents that are not in room and can be assigned to room.
-
#list_room_broadcasts(room_id:, page: 1, limit: 25) ⇒ Qismo::Collection<Qismo::Objects::BroadcastLog>
List broadcast history inside room.
-
#list_room_info(room_id:) ⇒ Array<Qismo::Objects::RoomAdditionalInfo>
List room additional info.
-
#list_room_tags(room_id:) ⇒ Qismo::Collection<Qismo::Objects::Tag>
List tags inside room.
-
#list_rooms(channels: nil, status: nil, serve_status: nil, name: nil, limit: 50, tag_ids: nil, user_ids: nil, order: "desc", cursor_after: nil, cursor_before: nil, is_handled_by_bot: nil) ⇒ Qismo::Collection<Qismo::CustomerRoom>
List customer rooms.
-
#list_wa_broadcast_jobs(limit: 10, cursor_after: nil, cursor_before: nil, name: nil) ⇒ Qismo::Collection<Qismo::Objects::BroadcastJob>
List WA broadcast jobs.
-
#list_wa_broadcast_logs(broadcast_job_id:, page: 1, limit: 10) ⇒ Qismo::Collection<Qismo::Objects::BroadcastLog>
List wa broadcast logs.
-
#list_wa_broadcast_templates(page: 1, limit: 10, approved: nil) ⇒ Qismo::Collection<Qismo::Objects::HsmTemplate>
List WA broadcast templates.
-
#remove_agent(room_id:, agent_id:) ⇒ TrueClass
Remove agent from room.
-
#resolve_room(room_id:, last_comment_id: Time.now.to_i, notes: nil, is_send_email: false, extras: nil) ⇒ Qismo::Objects::AgentService
Resolve room.
-
#send_bot_message(room_id:, message:, type: "text", payload: {}, extras: {}) ⇒ TrueClass
Send message as bot.
-
#send_message_to_custom_channel(identifier_key:, user_id:, name:, message:, avatar: nil, type: "text", payload: {}, extras: {}) ⇒ Qismo::Objects::CustomChannelMessageResponse
Send messsage to custom channel.
-
#send_wa_broadcast(file:, template_detail_id:, name: nil, separator: ",", started_at: nil) ⇒ Qismo::Objects::BroadcastJob
Send WA broadcast.
-
#send_wa_outbound(phone_number:, template_detail_id: nil, channel_id: nil, template_name: nil, namespace: nil, language: nil, variables: [], button_params: nil, header_value: nil) ⇒ Qismo::Objects::BroadcastJob
Send WA outbound message.
-
#update_room_info(room_id:, info:) ⇒ Array<Qismo::Objects::RoomAdditionalInfo>
Update room additional info.
-
#upload_wa_broadcast_csv(file:, template_detail_id:, separator: ",") ⇒ Integer
Upload wa broadcast file that want to be sent in broadcast.
Instance Method Details
#add_room_tag(room_id:, tag:) ⇒ Qismo::Objects::Tag
Add room tag
95 96 97 98 99 |
# File 'lib/qismo/api.rb', line 95 def add_room_tag(room_id:, tag:) Qismo::Objects::Tag.new( post("/api/v2/room_tags/#{room_id}", tag: tag).data ) end |
#allocate_agent(source:, channel_id:, ignore_availability: false) ⇒ Qismo::Objects::User
Get agent that can be assigned to room
256 257 258 259 260 261 262 263 264 |
# File 'lib/qismo/api.rb', line 256 def allocate_agent(source:, channel_id:, ignore_availability: false) Qismo::Objects::User.new( post("/api/v1/admin/service/allocate_agent", { source: source, channel_id: channel_id, ignore_availability: ignore_availability }).data.agent ) end |
#allocate_and_assign_agent(room_id:, ignore_availability: false) ⇒ Qismo::Objects::User
Get agent that can be allocated to room and automatically assign them
274 275 276 277 278 279 280 281 |
# File 'lib/qismo/api.rb', line 274 def allocate_and_assign_agent(room_id:, ignore_availability: false) Qismo::Objects::User.new( post("/api/v1/admin/service/allocate_assign_agent", { room_id: room_id.to_s, ignore_availability: ignore_availability }).data.agent ) end |
#assign_agent(room_id:, agent_id:, replace_latest_agent: false, max_agent: nil) ⇒ Qismo::Objects::User
Assign an agent to a room
187 188 189 190 191 192 193 194 195 196 |
# File 'lib/qismo/api.rb', line 187 def assign_agent(room_id:, agent_id:, replace_latest_agent: false, max_agent: nil) Qismo::Objects::User.new( post("/api/v1/admin/service/assign_agent", { room_id: room_id.to_s, agent_id: agent_id, replace_latest_agent: replace_latest_agent, max_agent: (replace_latest_agent == true) ? nil : max_agent }).data.assign_agent ) end |
#create_auth_webhook(url:, enabled: true) ⇒ Qismo::Objects::Webhook
Set auth webhook
375 376 377 378 379 380 381 |
# File 'lib/qismo/api.rb', line 375 def create_auth_webhook(url:, enabled: true) config = post("/api/v2/app/config/auth_webhook", url: url, enabled: enabled).data.configs Qismo::Objects::Webhook.new( enabled: config.is_auth_webhook_enabled, url: config.auth_webhook_url ) end |
#create_new_session_webhook(url:, enabled: true) ⇒ Qismo::Objects::Webhook
Set new session webhook
351 352 353 354 355 356 357 |
# File 'lib/qismo/api.rb', line 351 def create_new_session_webhook(url:, enabled: true) config = post("/api/v2/app/config/new_session_webhook", url: url, enabled: enabled).data.configs Qismo::Objects::Webhook.new( enabled: config.is_new_session_webhook_enabled, url: config.new_session_webhook_url ) end |
#create_resolve_webhook(url:, enabled: true) ⇒ Qismo::Objects::Webhook
Set resolve webhook
399 400 401 402 403 404 405 |
# File 'lib/qismo/api.rb', line 399 def create_resolve_webhook(url:, enabled: true) config = post("/api/v1/app/webhook/mark_as_resolved", webhook_url: url, is_webhook_enabled: enabled).data Qismo::Objects::Webhook.new( enabled: config.is_mark_as_resolved_webhook_enabled, url: config.mark_as_resolved_webhook_url ) end |
#create_room_info(room_id:, info:) ⇒ Array<Qismo::Objects::RoomAdditionalInfo>
This will replace your current room additional info
Set room additional info
133 134 135 136 137 138 139 140 |
# File 'lib/qismo/api.rb', line 133 def create_room_info(room_id:, info:) Qismo::Objects::RoomAdditionalInfo.from_array( post( "/api/v1/qiscus/room/#{room_id}/user_info", user_properties: info ).data.extras.user_properties ) end |
#delete_room_tag(room_id:, tag_id:) ⇒ TrueClass
Delete room tag
107 108 109 110 |
# File 'lib/qismo/api.rb', line 107 def delete_room_tag(room_id:, tag_id:) delete("/api/v2/room_tags/#{room_id}/#{tag_id}") true end |
#disable_bot_in_room(room_id:) ⇒ TrueClass
Disable chatbot in room
724 725 726 727 |
# File 'lib/qismo/api.rb', line 724 def disable_bot_in_room(room_id:) post("/bot/#{room_id}/activate", is_active: false) true end |
#enable_bot_in_room(room_id:) ⇒ TrueClass
Enable chabot in room
714 715 716 717 |
# File 'lib/qismo/api.rb', line 714 def enable_bot_in_room(room_id:) post("/bot/#{room_id}/activate", is_active: true) true end |
#get_agent(agent_id:) ⇒ Qismo::Objects::User
Get agent by id
474 475 476 |
# File 'lib/qismo/api.rb', line 474 def get_agent(agent_id:) Qismo::Objects::User.new(get("/api/v2/admin/agent/#{agent_id}").data.agent) end |
#get_auth_webhook ⇒ Qismo::Objects::Webhook
Get auth webhook config
362 363 364 365 366 367 368 |
# File 'lib/qismo/api.rb', line 362 def get_auth_webhook config = get("/api/v2/app/config/auth_webhook").data.configs Qismo::Objects::Webhook.new( enabled: config.is_auth_webhook_enabled, url: config.auth_webhook_url ) end |
#get_new_session_webhook ⇒ Qismo::Objects::Webhook
Get new session webhook config
338 339 340 341 342 343 344 |
# File 'lib/qismo/api.rb', line 338 def get_new_session_webhook config = get("/api/v2/app/config/new_session_webhook").data.configs Qismo::Objects::Webhook.new( enabled: config.is_new_session_webhook_enabled, url: config.new_session_webhook_url ) end |
#get_office_hours ⇒ Qismo::Objects::OfficeHour
Get office hour config
482 483 484 485 486 |
# File 'lib/qismo/api.rb', line 482 def get_office_hours Qismo::Objects::OfficeHour.new( get("/api/v1/admin/office_hours").data ) end |
#get_profile ⇒ Object
9 10 11 12 |
# File 'lib/qismo/api.rb', line 9 def get_profile body = get("/api/v1/admin/get_profile") Qismo::Objects::AdminProfile.new(body.data) end |
#get_resolve_webhook ⇒ Qismo::Objects::Webhook
Get resolve webhook config
386 387 388 389 390 391 392 |
# File 'lib/qismo/api.rb', line 386 def get_resolve_webhook config = get("/api/v1/app/webhook/mark_as_resolved").data Qismo::Objects::Webhook.new( enabled: config.is_mark_as_resolved_webhook_enabled, url: config.mark_as_resolved_webhook_url ) end |
#get_room(room_id:) ⇒ Qismo::Objects::CustomerRoom
Get room by id
66 67 68 69 70 71 72 73 |
# File 'lib/qismo/api.rb', line 66 def get_room(room_id:) body = get("/api/v2/customer_rooms/#{room_id}") if body.data.customer_room.nil? raise Qismo::NotFoundError.new("Room not found", status_code: 404, response_body: body.to_json) end Qismo::Objects::CustomerRoom.new(body.data.customer_room) end |
#get_wa_broadcast_job(broadcast_job_id:) ⇒ Qismo::Objects::BroadcastJob
Get wa broadcast job by id
655 656 657 658 659 |
# File 'lib/qismo/api.rb', line 655 def get_wa_broadcast_job(broadcast_job_id:) Qismo::Objects::BroadcastJob.new( get("/api/v2/admin/broadcast_jobs/#{broadcast_job_id}").data.broadcast_job ) end |
#get_wa_credit ⇒ Qismo::Objects::WaCreditInfo
Get Whatsapp channel credit info
515 516 517 518 519 |
# File 'lib/qismo/api.rb', line 515 def get_wa_credit Qismo::Objects::WaCreditInfo.new( get("/api/v2/admin/wa_pricing/balance").data ) end |
#handover_room_from_bot(room_id:) ⇒ TrueClass
Handover room from chatbot to human agent
734 735 736 737 738 739 740 |
# File 'lib/qismo/api.rb', line 734 def handover_room_from_bot(room_id:) request(:post, "/#{app_id}/bot/#{room_id}/hand_over", headers: { Authorization: secret_key }) true end |
#handover_room_from_bot_to_division(room_id:, roles:, find_online_agent: true) ⇒ TrueClass, FalseClass
Handover room from chatbot to human agent in specific divisions
750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 |
# File 'lib/qismo/api.rb', line 750 def handover_room_from_bot_to_division(room_id:, roles:, find_online_agent: true) = {} [:room_id] = room_id.to_s [:find_online_agent] = find_online_agent if roles.is_a?(Array) [:roles] = roles else [:role] = roles end request( :post, "/#{app_id}/bot/#{room_id}/hand_over_to_role", headers: {Authorization: secret_key}, json: ) true end |
#initiate_widget_chat(user_id:, name:, nonce: nil, channel_id: nil, extras: nil, reset_extras: false, room_badge: nil, avatar: nil, allocate_agent: nil, user_properties: nil, sdk_user_extras: nil, timezone_offset: nil, notes: nil, phone_number: nil, email: nil) ⇒ Qismo::Objects::CustomerRoom
Initiate chat using Qiscus widget channel
790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 |
# File 'lib/qismo/api.rb', line 790 def (user_id:, name:, nonce: nil, channel_id: nil, extras: nil, reset_extras: false, room_badge: nil, avatar: nil, allocate_agent: nil, user_properties: nil, sdk_user_extras: nil, timezone_offset: nil, notes: nil, phone_number: nil, email: nil) = { user_id: user_id, name: name, nonce: nonce, channel_id: channel_id, extras: extras, reset_extras: reset_extras, room_badge: room_badge, avatar: avatar, allocate_agent: allocate_agent, user_properties: user_properties, sdk_user_extras: sdk_user_extras, timezone_offset: timezone_offset, notes: notes, phone_number: phone_number, email: email }.compact [:app_id] = app_id Qismo::Objects::CustomerRoom.new(post("/api/v2/qiscus/initiate_chat", ).data.customer_room) end |
#list_agents(page: 1, limit: 10, search: nil, scope: nil) ⇒ Qismo::Collection<Qismo::Objects::User>
List agents
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
# File 'lib/qismo/api.rb', line 412 def list_agents(page: 1, limit: 10, search: nil, scope: nil) body = get("/api/v2/admin/agents", { page: page, limit: limit, search: search, scope: scope }) total_page = (body..total_count.to_f / body..per_page.to_f).ceil Qismo::Collection.new( Qismo::Objects::User.from_array(body.data.agents), next_page: ((page < total_page) ? (page + 1) : nil), prev_page: ((page > 1) ? (page - 1) : nil) ) end |
#list_agents_by_divisions(division_ids, page: 1, limit: 10, is_available: nil, sort: "asc") ⇒ Qismo::Collection<Qismo::Objects::User>
List agents by divisions
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 |
# File 'lib/qismo/api.rb', line 453 def list_agents_by_divisions(division_ids, page: 1, limit: 10, is_available: nil, sort: "asc") body = get("/api/v2/admin/agents/by_division", { "division_ids[]": division_ids, page: page, limit: limit, is_available: is_available, sort: sort }) Qismo::Collection.new( Qismo::Objects::User.from_array(body.data), next_page: ((body..page < body..total_page) ? (body..page + 1) : nil), prev_page: ((body..page > 1) ? (body..page - 1) : nil) ) end |
#list_agents_by_ids(agent_ids:) ⇒ Qismo::Collection<Qismo::Objects::User>
List agents by ids
434 435 436 437 438 |
# File 'lib/qismo/api.rb', line 434 def list_agents_by_ids(agent_ids:) Qismo::Collection.new( Qismo::Objects::User.from_array(get("/api/v1/admin/agents/get_by_ids", {"ids[]": agent_ids}).data) ) end |
#list_available_agents(room_id:, is_available_in_room: true, search: nil, limit: 15, cursor_after: nil, cursor_before: nil) ⇒ Qismo::Collection<Qismo::Objects::User>
List available agents in room
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'lib/qismo/api.rb', line 318 def list_available_agents(room_id:, is_available_in_room: true, search: nil, limit: 15, cursor_after: nil, cursor_before: nil) body = get("/api/v2/admin/service/available_agents", { room_id: room_id.to_s, is_available_in_room: is_available_in_room, search: search, limit: limit, cursor_after: cursor_after, cursor_before: cursor_before }) Collection.new( Qismo::Objects::User.from_array(body.data.agents), next_page: body..cursor_after, prev_page: body..cursor_before ) end |
#list_channels ⇒ Qismo::Objects::ListChannelsResponse
List integrated channels
854 855 856 857 858 |
# File 'lib/qismo/api.rb', line 854 def list_channels Qismo::Objects::ListChannelsResponse.new( get("/api/v2/channels").data ) end |
#list_other_agents(room_id:, search: nil, limit: 15, cursor_after: nil, cursor_before: nil) ⇒ Qismo::Collection<Qismo::Objects::User>
List agents that are not in room and can be assigned to room
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/qismo/api.rb', line 292 def list_other_agents(room_id:, search: nil, limit: 15, cursor_after: nil, cursor_before: nil) body = get("/api/v2/admin/service/other_agents", { room_id: room_id.to_s, search: search, limit: limit, cursor_after: cursor_after, cursor_before: cursor_before }) Collection.new( Qismo::Objects::User.from_array(body.data.agents), next_page: body..cursor_after, prev_page: body..cursor_before ) end |
#list_room_broadcasts(room_id:, page: 1, limit: 25) ⇒ Qismo::Collection<Qismo::Objects::BroadcastLog>
List broadcast history inside room
160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/qismo/api.rb', line 160 def list_room_broadcasts(room_id:, page: 1, limit: 25) body = get("/api/v2/customer_rooms/#{room_id}/broadcast_history", { page: page, limit: limit }) Qismo::Collection.new( Qismo::Objects::BroadcastLog.from_array(body.data.broadcast_logs), next_page: ((body..page < body.dig("meta", "total_page")) ? (body..page + 1) : nil), prev_page: ((body..page > 1) ? (body..page - 1) : nil) ) end |
#list_room_info(room_id:) ⇒ Array<Qismo::Objects::RoomAdditionalInfo>
List room additional info
117 118 119 120 121 122 123 |
# File 'lib/qismo/api.rb', line 117 def list_room_info(room_id:) Qismo::Objects::RoomAdditionalInfo.from_array( get("/api/v1/qiscus/room/#{room_id}/user_info").data.extras.user_properties ) rescue NoMethodError Qismo::Objects::RoomAdditionalInfo.from_array([]) end |
#list_room_tags(room_id:) ⇒ Qismo::Collection<Qismo::Objects::Tag>
List tags inside room
80 81 82 83 84 85 86 |
# File 'lib/qismo/api.rb', line 80 def (room_id:) Qismo::Collection.new( Qismo::Objects::Tag.from_array( get("/api/v2/room_tags/#{room_id}").data ) ) end |
#list_rooms(channels: nil, status: nil, serve_status: nil, name: nil, limit: 50, tag_ids: nil, user_ids: nil, order: "desc", cursor_after: nil, cursor_before: nil, is_handled_by_bot: nil) ⇒ Qismo::Collection<Qismo::CustomerRoom>
List customer rooms
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/qismo/api.rb', line 40 def list_rooms(channels: nil, status: nil, serve_status: nil, name: nil, limit: 50, tag_ids: nil, user_ids: nil, order: "desc", cursor_after: nil, cursor_before: nil, is_handled_by_bot: nil) body = post("/api/v2/customer_rooms", { channels: channels, status: status, serve_status: serve_status, name: name, limit: limit, tag_ids: tag_ids, user_ids: user_ids, order: order, cursor_after: cursor_after, cursor_before: cursor_before, is_handled_by_bot: is_handled_by_bot }) Collection.new( Qismo::Objects::CustomerRoom.from_array(body.data.customer_rooms), next_page: body..cursor_after, prev_page: body..cursor_before ) end |
#list_wa_broadcast_jobs(limit: 10, cursor_after: nil, cursor_before: nil, name: nil) ⇒ Qismo::Collection<Qismo::Objects::BroadcastJob>
List WA broadcast jobs
635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
# File 'lib/qismo/api.rb', line 635 def list_wa_broadcast_jobs(limit: 10, cursor_after: nil, cursor_before: nil, name: nil) body = get("/api/v2/admin/broadcast_jobs", { limit: limit, cursor_after: cursor_after, cursor_before: cursor_before, name: name }) Qismo::Collection.new( Qismo::Objects::BroadcastJob.from_array(body.data.broadcast_jobs), next_page: body..cursor_after, prev_page: body..cursor_before ) end |
#list_wa_broadcast_logs(broadcast_job_id:, page: 1, limit: 10) ⇒ Qismo::Collection<Qismo::Objects::BroadcastLog>
List wa broadcast logs
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 |
# File 'lib/qismo/api.rb', line 667 def list_wa_broadcast_logs(broadcast_job_id:, page: 1, limit: 10) body = get("/api/v2/admin/broadcast_logs/#{broadcast_job_id}", { page: page, limit: limit }) prev_page = (body..page > 1) ? (body.. - 1) : nil next_page = (body..page < body..total_page) ? (body..page + 1) : nil Qismo::Collection.new( Qismo::Objects::BroadcastLog.from_array(body.data.broadcast_logs), next_page: next_page, prev_page: prev_page ) end |
#list_wa_broadcast_templates(page: 1, limit: 10, approved: nil) ⇒ Qismo::Collection<Qismo::Objects::HsmTemplate>
List WA broadcast templates
498 499 500 501 502 503 504 505 506 507 508 509 510 |
# File 'lib/qismo/api.rb', line 498 def list_wa_broadcast_templates(page: 1, limit: 10, approved: nil) body = get("/api/v3/admin/hsm", { page: page, limit: limit, approved: approved }) Qismo::Collection.new( Qismo::Objects::HsmTemplate.from_array(body.data.hsm_templates), next_page: ((body..page < body..total_page) ? (body..page + 1) : nil), prev_page: ((body..page > 1) ? (body..page - 1) : nil) ) end |
#remove_agent(room_id:, agent_id:) ⇒ TrueClass
Remove agent from room
204 205 206 207 208 209 210 211 212 213 |
# File 'lib/qismo/api.rb', line 204 def remove_agent(room_id:, agent_id:) post( "/api/v1/admin/service/remove_agent", { room_id: room_id.to_s, agent_id: agent_id } ) true end |
#resolve_room(room_id:, last_comment_id: Time.now.to_i, notes: nil, is_send_email: false, extras: nil) ⇒ Qismo::Objects::AgentService
Resolve room
231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/qismo/api.rb', line 231 def resolve_room(room_id:, last_comment_id: Time.now.to_i, notes: nil, is_send_email: false, extras: nil) Qismo::Objects::AgentService.new( post("/api/v1/admin/service/mark_as_resolved", { room_id: room_id.to_s, last_comment_id: last_comment_id, notes: notes, is_send_email: is_send_email, extras: extras }).data.service ) end |
#send_bot_message(room_id:, message:, type: "text", payload: {}, extras: {}) ⇒ TrueClass
Send message as bot
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 |
# File 'lib/qismo/api.rb', line 692 def (room_id:, message:, type: "text", payload: {}, extras: {}) body = post("/#{app_id}/bot", { sender_email: admin_email, room_id: room_id.to_s, message: , type: type, payload: payload, extras: extras }) if body != "ok" raise Qismo::BadRequestError.new(body.to_s, status_code: 400, response_body: body.to_s) end true end |
#send_message_to_custom_channel(identifier_key:, user_id:, name:, message:, avatar: nil, type: "text", payload: {}, extras: {}) ⇒ Qismo::Objects::CustomChannelMessageResponse
Send messsage to custom channel
826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 |
# File 'lib/qismo/api.rb', line 826 def ( identifier_key:, user_id:, name:, message:, avatar: nil, type: "text", payload: {}, extras: {} ) Qismo::Objects::CustomChannelMessageResponse.new( post("/#{app_id}/api/v2/custom_channel/send", { identifier_key: identifier_key, user_id: user_id, name: name, message: , avatar: avatar, type: type, payload: payload, extras: extras }).data ) end |
#send_wa_broadcast(file:, template_detail_id:, name: nil, separator: ",", started_at: nil) ⇒ Qismo::Objects::BroadcastJob
Send WA broadcast
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 |
# File 'lib/qismo/api.rb', line 595 def send_wa_broadcast(file:, template_detail_id:, name: nil, separator: ",", started_at: nil) if name.blank? name = default_broadcast_name end if started_at.present? && !started_at.is_a?(Time) unless started_at.is_a?(Time) raise ArgumentError, "You must past :Time class for this parameter" end unless started_at.utc_offset == 0 raise ArgumentError, "You must set your timezone to UTC" end end file_id = if file.is_a?(HTTP::FormData::File) upload_wa_broadcast_csv(file, template_detail_id, separator: separator) else file.to_i end Qismo::Objects::BroadcastJob.new( post("/api/v3/admin/broadcast/send_broadcast", { broadcast_file_id: file_id, name: name, separator: separator, started_at: started_at, template_detail_id: template_detail_id }).data.broadcast_job ) end |
#send_wa_outbound(phone_number:, template_detail_id: nil, channel_id: nil, template_name: nil, namespace: nil, language: nil, variables: [], button_params: nil, header_value: nil) ⇒ Qismo::Objects::BroadcastJob
Send WA outbound message
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
# File 'lib/qismo/api.rb', line 534 def send_wa_outbound( phone_number:, template_detail_id: nil, channel_id: nil, template_name: nil, namespace: nil, language: nil, variables: [], button_params: nil, header_value: nil ) if template_detail_id.nil? raise ArgumentError, ":channel_id is required if you dont use :template_detail_id" if channel_id.nil? raise ArgumentError, ":template_name is required if you dont use :template_detail_id" if template_name.nil? raise ArgumentError, ":namespace is required if you dont use :template_detail_id" if namespace.nil? raise ArgumentError, ":language is required if you dont use :template_detail_id" if language.nil? end body = post("/api/v3/admin/broadcast/client", { phone_number: phone_number, template_detail_id: template_detail_id, channel_id: channel_id, template_name: template_name, namespace: namespace, language: language, variables: variables, button_params: , header_value: header_value }) Qismo::Objects::BroadcastJob.new(body.data) end |
#update_room_info(room_id:, info:) ⇒ Array<Qismo::Objects::RoomAdditionalInfo>
Update room additional info
148 149 150 151 152 |
# File 'lib/qismo/api.rb', line 148 def update_room_info(room_id:, info:) old_info = room_additional_info(room_id).as_json new_info = (info.as_json + old_info).uniq { |h| h.values_at("key") } set_room_additional_info(room_id: room_id, info: new_info) end |
#upload_wa_broadcast_csv(file:, template_detail_id:, separator: ",") ⇒ Integer
Upload wa broadcast file that want to be sent in broadcast
574 575 576 577 578 579 580 581 582 583 584 |
# File 'lib/qismo/api.rb', line 574 def upload_wa_broadcast_csv(file:, template_detail_id:, separator: ",") raise ArgumentError, "Invalid file" unless file.is_a?(HTTP::FormData::File) body = post_upload("/api/v3/admin/broadcast/upload_csv", { file: file, template_detail_id: template_detail_id, separator: separator }) body.broadcast_file_id end |