class GoodData::LCM2::PurgeClients

Constants

DESCRIPTION
PARAMS
RESULT_HEADER

Public Class Methods

call(params) click to toggle source
# File lib/gooddata/lcm/actions/purge_clients.rb, line 26
def call(params)
  client_projects = params.client_projects

  results = client_projects.pmap do |_, info|
    client = info[:segment_client]
    project = info[:project]

    res = {
      client_id: client.client_id,
      project: project && project.pid
    }

    if project.nil? || project.deleted?
      client.delete
      res[:status] = 'purged'
    else
      res[:status] = 'ok - not purged'
    end

    res
  end

  results.pselect { |res| res[:status] == 'purged' }.pmap { |res| res[:client_id] }.each { |id| client_projects.delete(id) }

  {
    results: results,
    params: {
      client_projects: client_projects
    }
  }
end