Class: Repull::ConversationsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/repull/api/conversations_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ConversationsApi

Returns a new instance of ConversationsApi.



19
20
21
# File 'lib/repull/api/conversations_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/repull/api/conversations_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#get_conversation(id, opts = {}) ⇒ ConversationDetail

Get conversation detail Returns one thread (the same shape as the list-row ‘Conversation`) plus expanded `host` (from `airbnb_hosts` for the thread’s ‘host_id`) and `guest` (resolved via the thread’s ‘reservation_id`, with up to 50 contacts) blocks.

Parameters:

  • id (Integer)

    Internal Repull thread id.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_schema (String)

    Apply a custom or built-in schema to transform the response. Built-in: `native` (default), `calry`, `calry-v1`. Custom: any schema name created via `POST /v1/schema/custom`. Unknown / inactive schema names fall back to `native`.

Returns:



28
29
30
31
# File 'lib/repull/api/conversations_api.rb', line 28

def get_conversation(id, opts = {})
  data, _status_code, _headers = get_conversation_with_http_info(id, opts)
  data
end

#get_conversation_with_http_info(id, opts = {}) ⇒ Array<(ConversationDetail, Integer, Hash)>

Get conversation detail Returns one thread (the same shape as the list-row &#x60;Conversation&#x60;) plus expanded &#x60;host&#x60; (from &#x60;airbnb_hosts&#x60; for the thread&#39;s &#x60;host_id&#x60;) and &#x60;guest&#x60; (resolved via the thread&#39;s &#x60;reservation_id&#x60;, with up to 50 contacts) blocks.

Parameters:

  • id (Integer)

    Internal Repull thread id.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_schema (String)

    Apply a custom or built-in schema to transform the response. Built-in: &#x60;native&#x60; (default), &#x60;calry&#x60;, &#x60;calry-v1&#x60;. Custom: any schema name created via &#x60;POST /v1/schema/custom&#x60;. Unknown / inactive schema names fall back to &#x60;native&#x60;.

Returns:

  • (Array<(ConversationDetail, Integer, Hash)>)

    ConversationDetail data, response status code and response headers



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/repull/api/conversations_api.rb', line 39

def get_conversation_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ConversationsApi.get_conversation ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling ConversationsApi.get_conversation"
  end
  # resource path
  local_var_path = '/v1/conversations/{id}'.sub('{id}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  header_params[:'X-Schema'] = opts[:'x_schema'] if !opts[:'x_schema'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ConversationDetail'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"ConversationsApi.get_conversation",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ConversationsApi#get_conversation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_conversation_messages(id, opts = {}) ⇒ MessageListResponse

List messages in a conversation Cursor-paginated messages within one thread. Defaults to newest-first (‘?order=desc`); pass `?order=asc` for chronological replay. Use `pagination.nextCursor` from one response as the `cursor` query param of the next request.

Parameters:

  • id (Integer)

    Internal Repull thread id.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_schema (String)

    Apply a custom or built-in schema to transform the response. Built-in: &#x60;native&#x60; (default), &#x60;calry&#x60;, &#x60;calry-v1&#x60;. Custom: any schema name created via &#x60;POST /v1/schema/custom&#x60;. Unknown / inactive schema names fall back to &#x60;native&#x60;.

  • :cursor (String)

    Opaque cursor returned in the previous response&#39;s &#x60;pagination.nextCursor&#x60;.

  • :limit (Integer) — default: default to 20
  • :order (String)

    &#x60;desc&#x60; (default) returns newest first. &#x60;asc&#x60; returns chronological replay. (default to ‘desc’)

Returns:



97
98
99
100
# File 'lib/repull/api/conversations_api.rb', line 97

def list_conversation_messages(id, opts = {})
  data, _status_code, _headers = list_conversation_messages_with_http_info(id, opts)
  data
end

#list_conversation_messages_with_http_info(id, opts = {}) ⇒ Array<(MessageListResponse, Integer, Hash)>

List messages in a conversation Cursor-paginated messages within one thread. Defaults to newest-first (&#x60;?order&#x3D;desc&#x60;); pass &#x60;?order&#x3D;asc&#x60; for chronological replay. Use &#x60;pagination.nextCursor&#x60; from one response as the &#x60;cursor&#x60; query param of the next request.

Parameters:

  • id (Integer)

    Internal Repull thread id.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_schema (String)

    Apply a custom or built-in schema to transform the response. Built-in: &#x60;native&#x60; (default), &#x60;calry&#x60;, &#x60;calry-v1&#x60;. Custom: any schema name created via &#x60;POST /v1/schema/custom&#x60;. Unknown / inactive schema names fall back to &#x60;native&#x60;.

  • :cursor (String)

    Opaque cursor returned in the previous response&#39;s &#x60;pagination.nextCursor&#x60;.

  • :limit (Integer) — default: default to 20
  • :order (String)

    &#x60;desc&#x60; (default) returns newest first. &#x60;asc&#x60; returns chronological replay. (default to ‘desc’)

Returns:

  • (Array<(MessageListResponse, Integer, Hash)>)

    MessageListResponse data, response status code and response headers



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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
167
168
169
170
171
172
173
# File 'lib/repull/api/conversations_api.rb', line 111

def list_conversation_messages_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ConversationsApi.list_conversation_messages ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling ConversationsApi.list_conversation_messages"
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ConversationsApi.list_conversation_messages, must be smaller than or equal to 100.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ConversationsApi.list_conversation_messages, must be greater than or equal to 1.'
  end

  allowable_values = ["asc", "desc"]
  if @api_client.config.client_side_validation && opts[:'order'] && !allowable_values.include?(opts[:'order'])
    fail ArgumentError, "invalid value for \"order\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/v1/conversations/{id}/messages'.sub('{id}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  header_params[:'X-Schema'] = opts[:'x_schema'] if !opts[:'x_schema'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'MessageListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"ConversationsApi.list_conversation_messages",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ConversationsApi#list_conversation_messages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_conversations(opts = {}) ⇒ ConversationListResponse

List conversations Cursor-paginated list of message threads owned by the workspace. Backed by main vanio’s ‘/api/threads/list` which keyset-paginates against `(last_message_at, id)` for constant per-page cost. Use `pagination.nextCursor` from one response as the `cursor` query param of the next request. Filters: `platform` (`airbnb`|`booking`|`vrbo`|`website`|`email`), `status` (`open`|`archived` — `archived` is a stable no-op until the bit lands on `message_threads`).

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_schema (String)

    Apply a custom or built-in schema to transform the response. Built-in: &#x60;native&#x60; (default), &#x60;calry&#x60;, &#x60;calry-v1&#x60;. Custom: any schema name created via &#x60;POST /v1/schema/custom&#x60;. Unknown / inactive schema names fall back to &#x60;native&#x60;.

  • :cursor (String)

    Opaque cursor returned in the previous response&#39;s &#x60;pagination.nextCursor&#x60;. Omit to fetch the first page.

  • :limit (Integer)

    Max items per page. Hard cap is 100. (default to 20)

  • :platform (String)

    Restrict to threads on a single channel.

  • :status (String)

    Filter by archive status. &#x60;archived&#x60; currently always returns an empty page — kept for forward-compat.

Returns:



184
185
186
187
# File 'lib/repull/api/conversations_api.rb', line 184

def list_conversations(opts = {})
  data, _status_code, _headers = list_conversations_with_http_info(opts)
  data
end

#list_conversations_with_http_info(opts = {}) ⇒ Array<(ConversationListResponse, Integer, Hash)>

List conversations Cursor-paginated list of message threads owned by the workspace. Backed by main vanio&#39;s &#x60;/api/threads/list&#x60; which keyset-paginates against &#x60;(last_message_at, id)&#x60; for constant per-page cost. Use &#x60;pagination.nextCursor&#x60; from one response as the &#x60;cursor&#x60; query param of the next request. Filters: &#x60;platform&#x60; (&#x60;airbnb&#x60;|&#x60;booking&#x60;|&#x60;vrbo&#x60;|&#x60;website&#x60;|&#x60;email&#x60;), &#x60;status&#x60; (&#x60;open&#x60;|&#x60;archived&#x60; — &#x60;archived&#x60; is a stable no-op until the bit lands on &#x60;message_threads&#x60;).

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_schema (String)

    Apply a custom or built-in schema to transform the response. Built-in: &#x60;native&#x60; (default), &#x60;calry&#x60;, &#x60;calry-v1&#x60;. Custom: any schema name created via &#x60;POST /v1/schema/custom&#x60;. Unknown / inactive schema names fall back to &#x60;native&#x60;.

  • :cursor (String)

    Opaque cursor returned in the previous response&#39;s &#x60;pagination.nextCursor&#x60;. Omit to fetch the first page.

  • :limit (Integer)

    Max items per page. Hard cap is 100. (default to 20)

  • :platform (String)

    Restrict to threads on a single channel.

  • :status (String)

    Filter by archive status. &#x60;archived&#x60; currently always returns an empty page — kept for forward-compat.

Returns:

  • (Array<(ConversationListResponse, Integer, Hash)>)

    ConversationListResponse data, response status code and response headers



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/repull/api/conversations_api.rb', line 198

def list_conversations_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ConversationsApi.list_conversations ...'
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ConversationsApi.list_conversations, must be smaller than or equal to 100.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ConversationsApi.list_conversations, must be greater than or equal to 1.'
  end

  allowable_values = ["airbnb", "booking", "vrbo", "website", "email"]
  if @api_client.config.client_side_validation && opts[:'platform'] && !allowable_values.include?(opts[:'platform'])
    fail ArgumentError, "invalid value for \"platform\", must be one of #{allowable_values}"
  end
  allowable_values = ["open", "archived"]
  if @api_client.config.client_side_validation && opts[:'status'] && !allowable_values.include?(opts[:'status'])
    fail ArgumentError, "invalid value for \"status\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/v1/conversations'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'platform'] = opts[:'platform'] if !opts[:'platform'].nil?
  query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  header_params[:'X-Schema'] = opts[:'x_schema'] if !opts[:'x_schema'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ConversationListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"ConversationsApi.list_conversations",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ConversationsApi#list_conversations\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end