module Markety::Command::ListOperation

ListOperation commands return Response::ListOperationResponse objects.

In all these functions:

All ListOp failures look similar, and all successes look similar.

Public Instance Methods

add_to_list(list_name, lead_or_idnum, options={}) click to toggle source

note: If you add something that's already in the list, ListOperationResponse::list_operation_success? will be true

# File lib/markety/command/list_operation.rb, line 14
def add_to_list(list_name, lead_or_idnum, options={})
  list_operation(list_name, "ADDTOLIST", lead_or_idnum, options)
end
is_member_of_list(list_name, lead_or_idnum, options={}) click to toggle source

ListOperationResponse::list_operation_success? is the result of this query

# File lib/markety/command/list_operation.rb, line 24
def is_member_of_list(list_name, lead_or_idnum, options={})
  list_operation(list_name, "ISMEMBEROFLIST", lead_or_idnum, options)
end
remove_from_list(list_name, lead_or_idnum, options={}) click to toggle source

note: If you remove something that's not in the list, ListOperationResponse::list_operation_success? will be false

# File lib/markety/command/list_operation.rb, line 19
def remove_from_list(list_name, lead_or_idnum, options={})
  list_operation(list_name, "REMOVEFROMLIST", lead_or_idnum, options)
end

Private Instance Methods

list_operation(list_name, list_operation_type, lead_or_idnum, options) click to toggle source
# File lib/markety/command/list_operation.rb, line 40
def list_operation(list_name, list_operation_type, lead_or_idnum, options)
  raise "Unknown list operation type" unless ALLOWED_OPS.include?(list_operation_type)
  idnum = lead_or_idnum
  if lead_or_idnum.is_a? Markety::Lead
    raise "Lead has no idnum, which this command needs" unless lead_or_idnum.idnum
    idnum = lead_or_idnum.idnum
  end

  strict = options.has_key?(:strict) ? !!options[:strict] : true

  strict = !!options[:strict]
  send_request(:list_operation, {
    list_operation: list_operation_type,
    strict: strict,
    list_key: {
      key_type: 'MKTOLISTNAME',
      key_value: list_name
    },
    list_member_list: {
      lead_key: [{
        key_type: 'IDNUM',
        key_value: idnum
      }]
    }
  })
end