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, #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
|
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
27
28
29
|
# File 'lib/never_bounce/api/request/jobs_create.rb', line 27
def self.http_method
:post
end
|
.path ⇒ String
32
33
34
|
# File 'lib/never_bounce/api/request/jobs_create.rb', line 32
def self.path
"jobs/create"
end
|
37
38
39
|
# File 'lib/never_bounce/api/request/jobs_create.rb', line 37
def self.response_klass
Response::JobsCreate
end
|
Instance Method Details
#mode_h ⇒ Hash
Return a ready-to-merge mode attributes hash.
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/never_bounce/api/request/jobs_create.rb', line 43
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
end
end
|
#to_h ⇒ Hash
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
|
# File 'lib/never_bounce/api/request/jobs_create.rb', line 60
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
|