Class: Pinnacle::Conversations::Client
- Inherits:
-
Object
- Object
- Pinnacle::Conversations::Client
- Defined in:
- lib/pinnacle/conversations/client.rb
Instance Method Summary collapse
-
#get(request_options: {}, **params) ⇒ Pinnacle::Types::Conversation?
Fetch a specific conversation using either its unique identifier or by matching sender and recipient details.
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Pinnacle::Types::ConversationList
Retrieves conversations by page with optional filtering based off provided parameters.
-
#list_messages(request_options: {}, **params) ⇒ Pinnacle::Types::MessageList
Retrieve a paginated and filtered list of messages for a specific conversation.
-
#update(request_options: {}, **params) ⇒ Pinnacle::Types::SuccessfulConversationUpdate
Update the notes associated with a specific conversation.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/pinnacle/conversations/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#get(request_options: {}, **params) ⇒ Pinnacle::Types::Conversation?
Fetch a specific conversation using either its unique identifier or by matching sender and recipient details.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/pinnacle/conversations/client.rb', line 24 def get(request_options: {}, **params) params = Pinnacle::Internal::Types::Utils.normalize_keys(params) request = Pinnacle::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "conversations/get", body: Pinnacle::Types::GetConversationParams.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Pinnacle::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Pinnacle::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#list(request_options: {}, **params) ⇒ Pinnacle::Types::ConversationList
Retrieves conversations by page with optional filtering based off provided parameters.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/pinnacle/conversations/client.rb', line 56 def list(request_options: {}, **params) params = Pinnacle::Internal::Types::Utils.normalize_keys(params) request = Pinnacle::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "conversations/list", body: Pinnacle::Conversations::Types::ListConversationsParams.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Pinnacle::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Pinnacle::Types::ConversationList.load(response.body) else error_class = Pinnacle::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list_messages(request_options: {}, **params) ⇒ Pinnacle::Types::MessageList
Retrieve a paginated and filtered list of messages for a specific conversation.
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/pinnacle/conversations/client.rb', line 133 def (request_options: {}, **params) params = Pinnacle::Internal::Types::Utils.normalize_keys(params) query_param_names = i[page_index page_size sort_order direction status type date_from date_to] query_params = {} query_params["pageIndex"] = params[:page_index] if params.key?(:page_index) query_params["pageSize"] = params[:page_size] if params.key?(:page_size) query_params["sortOrder"] = params[:sort_order] if params.key?(:sort_order) query_params["direction"] = params[:direction] if params.key?(:direction) query_params["status"] = params[:status] if params.key?(:status) query_params["type"] = params[:type] if params.key?(:type) query_params["dateFrom"] = params[:date_from] if params.key?(:date_from) query_params["dateTo"] = params[:date_to] if params.key?(:date_to) params = params.except(*query_param_names) request = Pinnacle::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "conversations/#{params[:id]}/messages", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Pinnacle::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Pinnacle::Types::MessageList.load(response.body) else error_class = Pinnacle::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update(request_options: {}, **params) ⇒ Pinnacle::Types::SuccessfulConversationUpdate
Update the notes associated with a specific conversation.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/pinnacle/conversations/client.rb', line 90 def update(request_options: {}, **params) params = Pinnacle::Internal::Types::Utils.normalize_keys(params) request = Pinnacle::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "conversations/update", body: Pinnacle::Conversations::Types::UpdateConversationParams.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Pinnacle::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Pinnacle::Types::SuccessfulConversationUpdate.load(response.body) else error_class = Pinnacle::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |