Method: NeverBounce::API::Client#jobs_create

Defined in:
lib/never_bounce/api/client.rb

#jobs_create(auto_parse: false, auto_start: false, filename: nil, remote_input: nil, run_sample: false, supplied_input: nil) ⇒ Response::JobsCreate, Response::ErrorMessage

Make a jobs/create request.

Parameters:

  • auto_parse (Boolean) (defaults to: false)
  • auto_start (Boolean) (defaults to: false)
  • filename (Boolean) (defaults to: nil)

    Default is "YYYYMMDD-HHMMSS.csv" based on current time.

  • remote_input (String) (defaults to: nil)

    E.g. "http://isp.com/emails.csv".

  • run_sample (Boolean) (defaults to: false)
  • supplied_input (Array<Array<email, name>>) (defaults to: nil)

    E.g. [["[email protected]", "Alice Roberts"], ["[email protected]", "Bob Smith"]].

Returns:

Raises:

See Also:



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/never_bounce/api/client.rb', line 86

def jobs_create(auto_parse: false, auto_start: false, filename: nil, remote_input: nil, run_sample: false, supplied_input: nil)
  raise ArgumentError, "`remote_input` and `supplied_input` can't both be given" if remote_input && supplied_input

  input_location = if (v = remote_input)
    # NOTE: Logical order: type, then value.
    input = v
    "remote_url"
  elsif (v = supplied_input)
    input = v
    "supplied"
  else
    # NOTE: Not exactly sure what to raise here. From procedure standpoint missing argument is an `ArgumentError`.
    raise ArgumentError, "Input not given, use `remote_input` or `supplied_input`"
  end

  filename ||= Time.now.strftime("%Y%m%d-%H%M%S.csv")

  response_to(API::Request::JobsCreate.new({
    api_key: api_key,
    auto_parse: auto_parse,
    auto_start: auto_start,
    filename: filename,
    input: input,
    input_location: input_location,
    run_sample: run_sample,
  }))
end