Class: SmoochApi::AttachmentsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/smooch-api/api/attachments_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ AttachmentsApi



19
20
21
# File 'lib/smooch-api/api/attachments_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/smooch-api/api/attachments_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#remove_attachment(appId, attachmentRemoveBody, opts = {}) ⇒ nil

Remove an attachment uploaded to Smooch.



29
30
31
32
# File 'lib/smooch-api/api/attachments_api.rb', line 29

def remove_attachment(appId, attachmentRemoveBody, opts = {})
  remove_attachment_with_http_info(appId, attachmentRemoveBody, opts)
  return nil
end

#remove_attachment_with_http_info(appId, attachmentRemoveBody, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Remove an attachment uploaded to Smooch.



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
# File 'lib/smooch-api/api/attachments_api.rb', line 40

def remove_attachment_with_http_info(appId, attachmentRemoveBody, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: AttachmentsApi.remove_attachment ..."
  end
  # verify the required parameter 'appId' is set
  if @api_client.config.client_side_validation && appId.nil?
    fail ArgumentError, "Missing the required parameter 'appId' when calling AttachmentsApi.remove_attachment"
  end
  # verify the required parameter 'attachmentRemoveBody' is set
  if @api_client.config.client_side_validation && attachmentRemoveBody.nil?
    fail ArgumentError, "Missing the required parameter 'attachmentRemoveBody' when calling AttachmentsApi.remove_attachment"
  end
  # resource path
  local_var_path = "/v1.1/apps/{appId}/attachments/remove".sub('{' + 'appId' + '}', appId.to_s)

  # query parameters
  query_params = {}

  # header parameters
  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 = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(attachmentRemoveBody)
  auth_names = ['basicAuth', 'jwt']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AttachmentsApi#remove_attachment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#upload_attachment(appId, source, access, opts = {}) ⇒ AttachmentResponse

Upload an attachment to Smooch to use in future messages.

Options Hash (opts):

  • :_for (String)

    The intended container for the attachment

  • :appUserId (String)

    The appUserId of the user that will receive the attachment Used in attachments for messages

  • :userId (String)

    The userId of the user that will receive the attachment Used in attachments for messages



93
94
95
96
# File 'lib/smooch-api/api/attachments_api.rb', line 93

def upload_attachment(appId, source, access, opts = {})
  data, _status_code, _headers = upload_attachment_with_http_info(appId, source, access, opts)
  return data
end

#upload_attachment_with_http_info(appId, source, access, opts = {}) ⇒ Array<(AttachmentResponse, Fixnum, Hash)>

Upload an attachment to Smooch to use in future messages.

Options Hash (opts):

  • :_for (String)

    The intended container for the attachment

  • :appUserId (String)

    The appUserId of the user that will receive the attachment Used in attachments for messages

  • :userId (String)

    The userId of the user that will receive the attachment Used in attachments for messages



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
158
159
# File 'lib/smooch-api/api/attachments_api.rb', line 108

def upload_attachment_with_http_info(appId, source, access, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: AttachmentsApi.upload_attachment ..."
  end
  # verify the required parameter 'appId' is set
  if @api_client.config.client_side_validation && appId.nil?
    fail ArgumentError, "Missing the required parameter 'appId' 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
  # 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
  # resource path
  local_var_path = "/v1.1/apps/{appId}/attachments".sub('{' + 'appId' + '}', appId.to_s)

  # query parameters
  query_params = {}
  query_params[:'access'] = access
  query_params[:'for'] = opts[:'_for'] if !opts[:'_for'].nil?
  query_params[:'appUserId'] = opts[:'appUserId'] if !opts[:'appUserId'].nil?
  query_params[:'userId'] = opts[:'userId'] if !opts[:'userId'].nil?

  # header parameters
  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 = {}
  form_params["source"] = source

  # http body (model)
  post_body = nil
  auth_names = ['basicAuth', 'jwt']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'AttachmentResponse')
  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