Class: Zerobounce::Request
- Inherits:
-
Object
- Object
- Zerobounce::Request
- Defined in:
- lib/zerobounce/request.rb,
lib/zerobounce/request/v1_request.rb,
lib/zerobounce/request/v2_request.rb
Overview
Sends the HTTP request.
Defined Under Namespace
Instance Attribute Summary collapse
-
#api_version ⇒ Object
readonly
Returns the value of attribute api_version.
-
#headers ⇒ Hash
readonly
The headers used for the request.
-
#host ⇒ String
readonly
The host to send the request to.
-
#middleware ⇒ Proc
readonly
Faraday middleware used for the request.
Instance Method Summary collapse
-
#credits(params = {}) ⇒ Integer
Get the number of remaining credits on the account.
-
#initialize(params = {}) ⇒ Request
constructor
Set instance variables and extends the correct Zerobounce::Request.
Constructor Details
#initialize(params = {}) ⇒ Request
Set instance variables and extends the correct Zerobounce::Request
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/zerobounce/request.rb', line 33 def initialize(params={}) @middleware = params[:middleware] || Zerobounce.config.middleware @headers = params[:headers] || Zerobounce.config.headers @host = params[:host] || Zerobounce.config.host @api_version = params[:api_version] || Zerobounce.config.api_version case api_version when 'v2' extend(V2Request) else extend(V1Request) end end |
Instance Attribute Details
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
24 25 26 |
# File 'lib/zerobounce/request.rb', line 24 def api_version @api_version end |
#headers ⇒ Hash (readonly)
The headers used for the request.
20 21 22 |
# File 'lib/zerobounce/request.rb', line 20 def headers @headers end |
#host ⇒ String (readonly)
The host to send the request to.
20 21 22 |
# File 'lib/zerobounce/request.rb', line 20 def host @host end |
#middleware ⇒ Proc (readonly)
Faraday middleware used for the request.
20 21 22 |
# File 'lib/zerobounce/request.rb', line 20 def middleware @middleware end |
Instance Method Details
#credits(params = {}) ⇒ Integer
Get the number of remaining credits on the account.
52 53 54 |
# File 'lib/zerobounce/request.rb', line 52 def credits(params={}) get('getcredits', params).body[:Credits].to_i end |