Sha256: b9e8a2ba4755f04a951a87b7794dc8112861aa53e95cb161bbb504730ba8086f

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

require './auth'

class DynamicListReplaceApi < DataSiftExample
  def initialize
    super
    run
  end

  def run
    begin

      puts "\nCreating a dynamic list: /list/create"
      list = @datasift.dynamic_list.create('text', 'My dynamic list')
      puts list

      id = list[:data][:id]

      puts "\nStart a new replace list: /list/replace/start"
      replace = @datasift.dynamic_list_replace.start id
      puts replace

      puts "\nAbort the list replace: /list/replace/abort"
      puts @datasift.dynamic_list_replace.abort replace[:data][:id]

      puts "\nStart a new replace list (again): /list/replace/start"
      replace = @datasift.dynamic_list_replace.start id
      puts replace

      items = ['keyword1', 'keyword2']
      puts "\nAdd items #{items} to replacement list: /list/replace/add"
      puts @datasift.dynamic_list_replace.add(replace[:data][:id], items)

      puts "\nCommit the replacement list: /list/replace/commit"
      puts @datasift.dynamic_list_replace.commit replace[:data][:id]

      puts "\nCleanup: Delete the list: /list/delete"
      puts @datasift.dynamic_list.delete id

    rescue DataSiftError => dse
      puts dse.message
    end
  end
end

DynamicListReplaceApi.new

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
datasift-3.1.5 examples/dynamic_list_replace_eg.rb
datasift-3.1.4 examples/dynamic_list_replace_eg.rb
datasift-3.1.3 examples/dynamic_list_replace_eg.rb
datasift-3.1.2 examples/dynamic_list_replace_eg.rb
datasift-3.1.1 examples/dynamic_list_replace_eg.rb
datasift-3.1.0 examples/dynamic_list_replace_eg.rb
datasift-3.0.1 examples/dynamic_list_replace_eg.rb
datasift-3.0.0 examples/dynamic_list_replace_eg.rb