Class: NeverBounce::API::Request::JobsCreate
- Inherits:
-
Base
- Object
- Base
- NeverBounce::API::Request::JobsCreate
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
#auto_parse ⇒ Boolean
7
8
9
|
# File 'lib/never_bounce/api/request/jobs_create.rb', line 7
def auto_parse
@auto_parse
end
|
#auto_start ⇒ Boolean
10
11
12
|
# File 'lib/never_bounce/api/request/jobs_create.rb', line 10
def auto_start
@auto_start
end
|
#filename ⇒ String
13
14
15
|
# File 'lib/never_bounce/api/request/jobs_create.rb', line 13
def filename
@filename
end
|
#historical ⇒ Boolean
27
28
29
|
# File 'lib/never_bounce/api/request/jobs_create.rb', line 27
def historical
@historical
end
|
18
19
20
|
# File 'lib/never_bounce/api/request/jobs_create.rb', line 18
def input
@input
end
|
21
22
23
|
# File 'lib/never_bounce/api/request/jobs_create.rb', line 21
def input_location
@input_location
end
|
#run_sample ⇒ 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_method ⇒ Symbol
34
35
36
|
# File 'lib/never_bounce/api/request/jobs_create.rb', line 34
def self.http_method
:post
end
|
.path ⇒ String
39
40
41
|
# File 'lib/never_bounce/api/request/jobs_create.rb', line 39
def self.path
"jobs/create"
end
|
44
45
46
|
# File 'lib/never_bounce/api/request/jobs_create.rb', line 44
def self.response_klass
Response::JobsCreate
end
|
Instance Method Details
#leverage_historical ⇒ Object
29
30
31
|
# File 'lib/never_bounce/api/request/jobs_create.rb', line 29
def leverage_historical
defined?(@historical) ? @historical : true
end
|
#mode_h ⇒ Hash
Return a ready-to-merge mode attributes hash.
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/never_bounce/api/request/jobs_create.rb', line 50
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 historical.nil?
_[:request_meta_data] = {leverage_historical_data: leverage_historical}
end
end
end
|
#to_h ⇒ Hash
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/never_bounce/api/request/jobs_create.rb', line 71
def to_h
input = require_attr(:input)
input_location = require_attr(:input_location)
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
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
{
input: input,
input_location: input_location,
filename: require_attr(:filename),
key: require_attr(:api_key),
}.merge(mode_h)
end
|