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')

Parameters:

  • :list_id (required, String)

    ID for the list to download

  • order (optional, String) (defaults to: 'asc')

    Sort in either ascending (asc, the default) or descending (desc) order

  • :filename (optional, String)

    A name to set for the returned File object. If not set, the File object will use the actual filename (if available)

    or a default of `download.csv` if the actual filename is not available.
    
  • :filepath (optional, String)

    A filepath to a directory where the file should be written. If not set, the file is not written, though the the file can be written at any time by calling ‘save` on the returned

    object and passing in `:filepath` as an argument to the `save` method, for example:
      response = proactive_connect.items.download_csv(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865')
      response.save('/files/downloads/')
    

    If set, the filepath must be:

    - An absolute path
    - For a valid directory
    - The directory must be writable
    

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')

Parameters:

  • :list_id (required, String)

    Unique identifier for the list

  • :page (optional, String)

    Page of results to jump to

  • :page_size (optional, String)

    Number of results per page

  • order (optional, String)

    Sort in either ascending (asc, the default) or descending (desc) order

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')

Parameters:

  • :list_id (required, String)

    ID for the list to download

  • order (optional, String)

    Sort in either ascending (asc, the default) or descending (desc) order

  • :filename (optional, String)

    A name to set for the returned File object. If not set, the File object will use the actual filename (if available)

    or a default of `download.csv` if the actual filename is not available.
    
  • :filepath (required, String)

    A filepath for the file to import. The file must be:

    - A valid file
    - Readable
    - Must have a `.csv` extension
    

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