Class: SunshineConversationsClient::AttachmentsApi
- Inherits:
-
Object
- Object
- SunshineConversationsClient::AttachmentsApi
- Defined in:
- lib/sunshine-conversations-client/api/attachments_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#delete_attachment(app_id, attachment_delete_body, opts = {}) ⇒ Object
Delete Attachment Remove an attachment uploaded to Sunshine Conversations through the Upload attachment API.
-
#delete_attachment_with_http_info(app_id, attachment_delete_body, opts = {}) ⇒ Array<(Object, Integer, Hash)>
Delete Attachment Remove an attachment uploaded to Sunshine Conversations through the Upload attachment API.
-
#generate_media_json_web_token(app_id, attachment_media_token_body, opts = {}) ⇒ AttachmentMediaTokenResponse
Generate Media Token Generates a media JWT for a list of attachment paths.
-
#generate_media_json_web_token_with_http_info(app_id, attachment_media_token_body, opts = {}) ⇒ Array<(AttachmentMediaTokenResponse, Integer, Hash)>
Generate Media Token Generates a media JWT for a list of attachment paths.
-
#initialize(api_client = ApiClient.default) ⇒ AttachmentsApi
constructor
A new instance of AttachmentsApi.
-
#set_cookie(app_id, opts = {}) ⇒ Object
Set Cookie With the media JWT retrieved, pass it in the header of the below request as it’s authorization in order to set a cookie in the user’s browser corresponding to the path within the media JWT.
-
#set_cookie_with_http_info(app_id, opts = {}) ⇒ Array<(Object, Integer, Hash)>
Set Cookie With the media JWT retrieved, pass it in the header of the below request as it’s authorization in order to set a cookie in the user’s browser corresponding to the path within the media JWT.
-
#upload_attachment(app_id, access, source, opts = {}) ⇒ AttachmentResponse
Upload Attachment Upload an attachment to Sunshine Conversations to use in future messages.
-
#upload_attachment_with_http_info(app_id, access, source, opts = {}) ⇒ Array<(AttachmentResponse, Integer, Hash)>
Upload Attachment Upload an attachment to Sunshine Conversations to use in future messages.
Constructor Details
#initialize(api_client = ApiClient.default) ⇒ AttachmentsApi
Returns a new instance of AttachmentsApi.
16 17 18 |
# File 'lib/sunshine-conversations-client/api/attachments_api.rb', line 16 def initialize(api_client = ApiClient.default) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
14 15 16 |
# File 'lib/sunshine-conversations-client/api/attachments_api.rb', line 14 def api_client @api_client end |
Instance Method Details
#delete_attachment(app_id, attachment_delete_body, opts = {}) ⇒ Object
Delete Attachment Remove an attachment uploaded to Sunshine Conversations through the Upload attachment API. See [Attachments for Messages](#section/Attachments-for-Messages) to have attachments automatically deleted when deleting messages, conversations or users. <aside class="notice">Note that deleted attachments can remain available on our CDN’s cache up to 15 minutes after the delete call.</aside>
25 26 27 28 |
# File 'lib/sunshine-conversations-client/api/attachments_api.rb', line 25 def (app_id, , opts = {}) data, _status_code, _headers = (app_id, , opts) data end |
#delete_attachment_with_http_info(app_id, attachment_delete_body, opts = {}) ⇒ Array<(Object, Integer, Hash)>
Delete Attachment Remove an attachment uploaded to Sunshine Conversations through the Upload attachment API. See [Attachments for Messages](#section/Attachments-for-Messages) to have attachments automatically deleted when deleting messages, conversations or users. <aside class="notice">Note that deleted attachments can remain available on our CDN’s cache up to 15 minutes after the delete call.</aside>
36 37 38 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 87 |
# File 'lib/sunshine-conversations-client/api/attachments_api.rb', line 36 def (app_id, , opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AttachmentsApi.delete_attachment ...' end # verify the required parameter 'app_id' is set if @api_client.config.client_side_validation && app_id.nil? fail ArgumentError, "Missing the required parameter 'app_id' when calling AttachmentsApi.delete_attachment" end # verify the required parameter 'attachment_delete_body' is set if @api_client.config.client_side_validation && .nil? fail ArgumentError, "Missing the required parameter 'attachment_delete_body' when calling AttachmentsApi.delete_attachment" end # resource path local_var_path = '/v2/apps/{appId}/attachments/remove'.sub('{' + 'appId' + '}', CGI.escape(app_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']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body() # return_type return_type = opts[:return_type] || 'Object' # auth_names auth_names = opts[:auth_names] || ['basicAuth', 'bearerAuth'] = opts.merge( :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(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: AttachmentsApi#delete_attachment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#generate_media_json_web_token(app_id, attachment_media_token_body, opts = {}) ⇒ AttachmentMediaTokenResponse
Generate Media Token Generates a media JWT for a list of attachment paths. This media token is a prerequisite for setting the cookie needed to visualize a private attachment. <aside class="notice">Note you have the ability to allow files using different rules, see <a href="docs.smooch.io/guide/private-attachments">Private Attachments</a> for more details.</aside>
95 96 97 98 |
# File 'lib/sunshine-conversations-client/api/attachments_api.rb', line 95 def generate_media_json_web_token(app_id, , opts = {}) data, _status_code, _headers = generate_media_json_web_token_with_http_info(app_id, , opts) data end |
#generate_media_json_web_token_with_http_info(app_id, attachment_media_token_body, opts = {}) ⇒ Array<(AttachmentMediaTokenResponse, Integer, Hash)>
Generate Media Token Generates a media JWT for a list of attachment paths. This media token is a prerequisite for setting the cookie needed to visualize a private attachment. <aside class="notice">Note you have the ability to allow files using different rules, see <a href="docs.smooch.io/guide/private-attachments">Private Attachments</a> for more details.</aside>
106 107 108 109 110 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 |
# File 'lib/sunshine-conversations-client/api/attachments_api.rb', line 106 def generate_media_json_web_token_with_http_info(app_id, , opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AttachmentsApi.generate_media_json_web_token ...' end # verify the required parameter 'app_id' is set if @api_client.config.client_side_validation && app_id.nil? fail ArgumentError, "Missing the required parameter 'app_id' when calling AttachmentsApi.generate_media_json_web_token" end # verify the required parameter 'attachment_media_token_body' is set if @api_client.config.client_side_validation && .nil? fail ArgumentError, "Missing the required parameter 'attachment_media_token_body' when calling AttachmentsApi.generate_media_json_web_token" end # resource path local_var_path = '/v2/apps/{appId}/attachments/token'.sub('{' + 'appId' + '}', CGI.escape(app_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']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body() # return_type return_type = opts[:return_type] || 'AttachmentMediaTokenResponse' # auth_names auth_names = opts[:auth_names] || ['basicAuth', 'bearerAuth'] = opts.merge( :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(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: AttachmentsApi#generate_media_json_web_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#set_cookie(app_id, opts = {}) ⇒ Object
Set Cookie With the media JWT retrieved, pass it in the header of the below request as it’s authorization in order to set a cookie in the user’s browser corresponding to the path within the media JWT. The expiration date of this cookie will match the expiration date of the media JWT. This cookie will be needed to visualize a private attachment.
164 165 166 167 |
# File 'lib/sunshine-conversations-client/api/attachments_api.rb', line 164 def (app_id, opts = {}) data, _status_code, _headers = (app_id, opts) data end |
#set_cookie_with_http_info(app_id, opts = {}) ⇒ Array<(Object, Integer, Hash)>
Set Cookie With the media JWT retrieved, pass it in the header of the below request as it’s authorization in order to set a cookie in the user’s browser corresponding to the path within the media JWT. The expiration date of this cookie will match the expiration date of the media JWT. This cookie will be needed to visualize a private attachment.
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/sunshine-conversations-client/api/attachments_api.rb', line 174 def (app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AttachmentsApi.set_cookie ...' end # verify the required parameter 'app_id' is set if @api_client.config.client_side_validation && app_id.nil? fail ArgumentError, "Missing the required parameter 'app_id' when calling AttachmentsApi.set_cookie" end # resource path local_var_path = '/v2/apps/{appId}/attachments/cookie'.sub('{' + 'appId' + '}', CGI.escape(app_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']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'Object' # auth_names auth_names = opts[:auth_names] || ['bearerAuth'] = opts.merge( :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, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: AttachmentsApi#set_cookie\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#upload_attachment(app_id, access, source, opts = {}) ⇒ AttachmentResponse
Upload Attachment Upload an attachment to Sunshine Conversations to use in future messages. Files are uploaded using the multipart/form-data content type. Use the returned mediaUrl to send a file, image or carousel message. <aside class="notice">Note that Sunshine Conversations limits the size and type of file you can upload to the platform. See the <a href="docs.smooch.io/guide/validating-files">file validation</a> guide for more details.</aside>
230 231 232 233 |
# File 'lib/sunshine-conversations-client/api/attachments_api.rb', line 230 def (app_id, access, source, opts = {}) data, _status_code, _headers = (app_id, access, source, opts) data end |
#upload_attachment_with_http_info(app_id, access, source, opts = {}) ⇒ Array<(AttachmentResponse, Integer, Hash)>
Upload Attachment Upload an attachment to Sunshine Conversations to use in future messages. Files are uploaded using the multipart/form-data content type. Use the returned mediaUrl to send a file, image or carousel message. <aside class="notice">Note that Sunshine Conversations limits the size and type of file you can upload to the platform. See the <a href="docs.smooch.io/guide/validating-files">file validation</a> guide for more details.</aside>
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/sunshine-conversations-client/api/attachments_api.rb', line 244 def (app_id, access, source, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AttachmentsApi.upload_attachment ...' end # verify the required parameter 'app_id' is set if @api_client.config.client_side_validation && app_id.nil? fail ArgumentError, "Missing the required parameter 'app_id' when calling AttachmentsApi.upload_attachment" end # verify the required parameter 'access' is set if @api_client.config.client_side_validation && access.nil? fail ArgumentError, "Missing the required parameter 'access' when calling AttachmentsApi.upload_attachment" end # verify the required parameter 'source' is set if @api_client.config.client_side_validation && source.nil? fail ArgumentError, "Missing the required parameter 'source' when calling AttachmentsApi.upload_attachment" end # resource path local_var_path = '/v2/apps/{appId}/attachments'.sub('{' + 'appId' + '}', CGI.escape(app_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'access'] = access query_params[:'for'] = opts[:'_for'] if !opts[:'_for'].nil? query_params[:'conversationId'] = opts[:'conversation_id'] if !opts[:'conversation_id'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) # form parameters form_params = opts[:form_params] || {} form_params['source'] = source # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'AttachmentResponse' # auth_names auth_names = opts[:auth_names] || ['basicAuth', 'bearerAuth'] = opts.merge( :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(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: AttachmentsApi#upload_attachment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |