Class: Vonage::ProactiveConnect::Items

Inherits:
Namespace
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/vonage/proactive_connect/items.rb

Defined Under Namespace

Classes: FileResponse, ListResponse

Instance Method Summary collapse

Instance Method Details

#download_csv(list_id:, order: 'asc', **params) ⇒ Object

Deprecated.

Download list items as a CSV file format

Examples:

response = proactive_connect.items.download_csv(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865')

See Also:



71
72
73
74
75
76
77
78
79
# File 'lib/vonage/proactive_connect/items.rb', line 71

def download_csv(list_id:, order: 'asc', **params)
  logger.info('This method is deprecated and will be removed in a future release.')
  response = request("/v0.1/bulk/lists/#{list_id}/items/download?order=#{order}", response_class: FileResponse)

  response.filename = params[:filename] if params[:filename]
  response.save(filepath: params[:filepath]) if params[:filepath]

  response
end

#list(list_id:, **params) ⇒ Object

Deprecated.

Find all list items

Examples:

response = proactive_connect.items.list(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865')

See Also:



33
34
35
36
37
38
39
# File 'lib/vonage/proactive_connect/items.rb', line 33

def list(list_id:, **params)
  logger.info('This method is deprecated and will be removed in a future release.')
  path = "/v0.1/bulk/lists/#{list_id}/items"
  path += "?#{Params.encode(params)}" unless params.empty?

  request(path, response_class: ListResponse)
end

#upload_csv(list_id:, filepath:) ⇒ Object

Deprecated.

Import list items from a CSV file

Examples:

response = proactive_connect.items.upload_csv(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865', filepath: '/files/import.csv')

Raises:

  • (ArgumentError)

See Also:



106
107
108
109
110
111
112
113
114
# File 'lib/vonage/proactive_connect/items.rb', line 106

def upload_csv(list_id:, filepath:)
  logger.info('This method is deprecated and will be removed in a future release.')
  pn = Pathname.new(filepath)
  raise ArgumentError, ':filepath not for a file' unless pn.file?
  raise ArgumentError, 'file at :filepath not readable' unless pn.readable?
  raise ArgumentError, 'file at :filepath not csv' unless pn.extname == '.csv'

  multipart_post_request("/v0.1/bulk/lists/#{list_id}/items/import", filepath: filepath, file_name: pn.basename, mime_type: 'text/csv')
end