|
| 1 | +# typed: strict |
| 2 | +# frozen_string_literal: true |
| 3 | + |
| 4 | +module Vonage |
| 5 | + class Conversation < Namespace |
| 6 | + extend T::Sig |
| 7 | + |
| 8 | + self.authentication = BearerToken |
| 9 | + |
| 10 | + self.request_body = JSON |
| 11 | + |
| 12 | + # List conversations associated with a Vonage application. |
| 13 | + # |
| 14 | + # @example |
| 15 | + # response = client.conversation.list |
| 16 | + # |
| 17 | + # @param [String] :date_start |
| 18 | + # Return the records that occurred after this point in time. |
| 19 | + # |
| 20 | + # @param [String] :date_end |
| 21 | + # Return the records that occurred before this point in time. |
| 22 | + # |
| 23 | + # @param [Integer] :page_size |
| 24 | + # Return this amount of records in the response. |
| 25 | + # |
| 26 | + # @param ['asc', 'desc'] :order |
| 27 | + # Return the records in ascending or descending order. |
| 28 | + # |
| 29 | + # @param [String] :cursor |
| 30 | + # The cursor to start returning results from. |
| 31 | + # |
| 32 | + # @return [Conversation::ListResponse] |
| 33 | + # |
| 34 | + # @see https://developer.vonage.com/en/api/conversation#listConversations |
| 35 | + # |
| 36 | + def list(**params) |
| 37 | + request('/v1/conversations', params: params, response_class: ListResponse) |
| 38 | + end |
| 39 | + |
| 40 | + # Create a conversation. |
| 41 | + # |
| 42 | + # @example |
| 43 | + # response = client.conversation.create(name: 'Example Conversation', display_name: 'Example Display Name') |
| 44 | + # |
| 45 | + # @param [String] :name |
| 46 | + # Your internal conversation name. Must be unique. |
| 47 | + # |
| 48 | + # @param [String] :display_name |
| 49 | + # The public facing name of the conversation. |
| 50 | + # |
| 51 | + # @param [String] :image_url |
| 52 | + # An image URL that you associate with the conversation |
| 53 | + # |
| 54 | + # @param [Hash] :properties |
| 55 | + # - :ttl (Integer) After how many seconds an empty conversation is deleted |
| 56 | + # - :type (String) |
| 57 | + # - :custom_sort_key (String) |
| 58 | + # - :custom_data (Hash) Custom key/value pairs to be included with conversation data |
| 59 | + # |
| 60 | + # @option params [Array] :numbers An array of Hashes containing number information for different channels. |
| 61 | + # |
| 62 | + # @option params [Hash] :callback |
| 63 | + # - @option callback :url (String) |
| 64 | + # - @option callback :event_mask (String) |
| 65 | + # - @option callback :params (Hash) |
| 66 | + # - @option params :applicationId (String) |
| 67 | + # - @option params :ncco_url (String) |
| 68 | + # - @option callback :method (String) Must be one of ['POST', 'GET'] |
| 69 | + # |
| 70 | + # @return [Response] |
| 71 | + # |
| 72 | + # @see https://developer.vonage.com/en/api/conversation#createConversation |
| 73 | + # |
| 74 | + def create(**params) |
| 75 | + request('/v1/conversations', params: params, type: Post) |
| 76 | + end |
| 77 | + |
| 78 | + # Retrieve a conversation. |
| 79 | + # |
| 80 | + # @example |
| 81 | + # response = client.conversation.find(conversation_id: 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a') |
| 82 | + # |
| 83 | + # @param [String] :conversation_id |
| 84 | + # |
| 85 | + # @return [Response] |
| 86 | + # |
| 87 | + # @see https://developer.vonage.com/en/api/conversation#retrieveConversation |
| 88 | + # |
| 89 | + def find(conversation_id:) |
| 90 | + request("/v1/conversations/#{conversation_id}") |
| 91 | + end |
| 92 | + |
| 93 | + # Update a conversation. |
| 94 | + # |
| 95 | + # @example |
| 96 | + # response = client.conversation.update(conversation_id: 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a', display_name: 'Updated conversation') |
| 97 | + # |
| 98 | + # @param [String] :name |
| 99 | + # Your internal conversation name. Must be unique. |
| 100 | + # |
| 101 | + # @param [String] :display_name |
| 102 | + # The public facing name of the conversation. |
| 103 | + # |
| 104 | + # @param [String] :image_url |
| 105 | + # An image URL that you associate with the conversation |
| 106 | + # |
| 107 | + # @param [Hash] :properties |
| 108 | + # - @option properties :ttl (Integer) After how many seconds an empty conversation is deleted |
| 109 | + # - @option properties :type (String) |
| 110 | + # - @option properties :custom_sort_key (String) |
| 111 | + # - @option properties :custom_data (Hash) Custom key/value pairs to be included with conversation data |
| 112 | + # |
| 113 | + # @param [Array] :numbers An array of Hashes containing number information for different channels. |
| 114 | + # |
| 115 | + # @option params [Hash] :callback |
| 116 | + # - @option callback :url (String) |
| 117 | + # - @option callback :event_mask (String) |
| 118 | + # - @option callback :params (Hash) |
| 119 | + # - @option params :applicationId (String) |
| 120 | + # - @option params :ncco_url (String) |
| 121 | + # - @option callback :method (String) Must be one of ['POST', 'GET'] |
| 122 | + # |
| 123 | + # @return [Response] |
| 124 | + # |
| 125 | + # @see https://developer.vonage.com/en/api/conversation#replaceConversation |
| 126 | + # |
| 127 | + def update(conversation_id:, **params) |
| 128 | + request("/v1/conversations/#{conversation_id}", params: params, type: Put) |
| 129 | + end |
| 130 | + |
| 131 | + # Delete a conversation. |
| 132 | + # |
| 133 | + # @example |
| 134 | + # response = client.conversation.delete(conversation_id: 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a') |
| 135 | + # |
| 136 | + # @param [String] :conversation_id |
| 137 | + # |
| 138 | + # @return [Response] |
| 139 | + # |
| 140 | + # @see https://developer.vonage.com/en/api/conversation#deleteConversation |
| 141 | + # |
| 142 | + def delete(conversation_id:) |
| 143 | + request("/v1/conversations/#{conversation_id}", type: Delete) |
| 144 | + end |
| 145 | + |
| 146 | + # @return [Conversation::User] |
| 147 | + sig { returns(T.nilable(Vonage::Conversation::User)) } |
| 148 | + def user |
| 149 | + @user ||= User.new(@config) |
| 150 | + end |
| 151 | + |
| 152 | + # @return [Conversation::Member] |
| 153 | + sig { returns(T.nilable(Vonage::Conversation::Member)) } |
| 154 | + def member |
| 155 | + @member ||= Member.new(@config) |
| 156 | + end |
| 157 | + |
| 158 | + # @return [Conversation::Event] |
| 159 | + sig { returns(T.nilable(Vonage::Conversation::Event)) } |
| 160 | + def event |
| 161 | + @event ||= Event.new(@config) |
| 162 | + end |
| 163 | + end |
| 164 | +end |
0 commit comments