Class: NeverBounce::API::Request::JobsCreate

Inherits:
Base
  • Object
show all
Defined in:
lib/never_bounce/api/request/jobs_create.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#api_key, #api_url, #api_version, #headers, #user_agent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#to_curl, #to_httparty

Instance Attribute Details

#allow_manual_reviewBoolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/never_bounce/api/request/jobs_create.rb', line 30

def allow_manual_review
  @allow_manual_review
end

#auto_parseBoolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/never_bounce/api/request/jobs_create.rb', line 7

def auto_parse
  @auto_parse
end

#auto_startBoolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/never_bounce/api/request/jobs_create.rb', line 10

def auto_start
  @auto_start
end

#callback_headersHash

Returns:

  • (Hash)


36
37
38
# File 'lib/never_bounce/api/request/jobs_create.rb', line 36

def callback_headers
  @callback_headers
end

#callback_urlString

Returns:

  • (String)


33
34
35
# File 'lib/never_bounce/api/request/jobs_create.rb', line 33

def callback_url
  @callback_url
end

#filenameString

Returns:

  • (String)


13
14
15
# File 'lib/never_bounce/api/request/jobs_create.rb', line 13

def filename
  @filename
end

#historicalBoolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/never_bounce/api/request/jobs_create.rb', line 27

def historical
  @historical
end

#inputString, Array<Array<email, name>>

Input specification.

Returns:

  • (String)

    URL if input_location is <tt>“remote”.

  • (Array<Array<email, name>>)

    Structure if input_location is “supplied”.



18
19
20
# File 'lib/never_bounce/api/request/jobs_create.rb', line 18

def input
  @input
end

#input_locationString

Returns:

  • (String)


21
22
23
# File 'lib/never_bounce/api/request/jobs_create.rb', line 21

def input_location
  @input_location
end

#run_sampleBoolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/never_bounce/api/request/jobs_create.rb', line 24

def run_sample
  @run_sample
end

Class Method Details

.http_methodSymbol

Returns:

  • (Symbol)


43
44
45
# File 'lib/never_bounce/api/request/jobs_create.rb', line 43

def self.http_method
  :post
end

.pathString

Returns:

  • (String)


48
49
50
# File 'lib/never_bounce/api/request/jobs_create.rb', line 48

def self.path
  "jobs/create"
end

.response_klassResponse::JobsCreate



53
54
55
# File 'lib/never_bounce/api/request/jobs_create.rb', line 53

def self.response_klass
  Response::JobsCreate
end

Instance Method Details

#leverage_historicalObject



38
39
40
# File 'lib/never_bounce/api/request/jobs_create.rb', line 38

def leverage_historical
  defined?(@historical) ? @historical : true
end

#mode_hHash

Return a ready-to-merge mode attributes hash.

Returns:

  • (Hash)


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/never_bounce/api/request/jobs_create.rb', line 59

def mode_h
  @mode_h ||= {}.tap do |_|
    unless (v = auto_start).nil?
      _[:auto_start] = v
    end

    unless (v = auto_parse).nil?
      _[:auto_parse] = v
    end

    unless (v = run_sample).nil?
      _[:run_sample] = v
    end

    unless (v = allow_manual_review).nil?
      _[:allow_manual_review] = v
    end

    unless (v = callback_url).nil?
      _[:callback_url] = v
    end

    unless (v = callback_headers).nil?
      _[:callback_headers] = v
    end

    unless historical.nil?
      _[:request_meta_data] = {leverage_historical_data: leverage_historical}
    end
  end
end

#to_hHash

Returns:

  • (Hash)


92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/never_bounce/api/request/jobs_create.rb', line 92

def to_h
  input = require_attr(:input)
  input_location = require_attr(:input_location)

  # Validate `input_location` and `input`.

  if not ["remote_url", "supplied"].include? input_location
    raise AttributeError, "Unknown `input_location`: #{input_location.inspect}"
  end

  if input_location == "supplied"
    raise AttributeError, "Invalid `input` for `input_location` == #{input_location.inspect}: #{input.inspect}" if not input.is_a? Array

    # Skim through elements of `input`, raise if invalid structure detected, with details.
    input.each do |elem|
      em = [AttributeError, "Invalid `input` element: #{elem.inspect}"]
      raise(*em) unless elem.is_a? Array
      raise(*em) unless elem.map(&:class) == [String, String]
    end
  end

  # Result.
  {
    input: input,
    input_location: input_location,
    filename: require_attr(:filename),
    key: require_attr(:api_key),
  }.merge(mode_h)
end