Class: KaveRestApi::CountPostalCode

Inherits:
RequestBase show all
Includes:
Validatable
Defined in:
lib/kave_rest_api/requests/countpostalcode.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ CountPostalCode

Returns a new instance of CountPostalCode.



12
13
14
15
16
17
18
19
# File 'lib/kave_rest_api/requests/countpostalcode.rb', line 12

def initialize(args = {})
  super
  @ACTION_NAME    = [:countpostalcode,@FORMAT].join('.').freeze
  @postalcode     = args.fetch(:postalcode)
  @postalcode     = @postalcode.ctsd
  
  @response       = ResponseCountPostalCode.new
end

Instance Attribute Details

#postalcodeObject

Returns the value of attribute postalcode.



5
6
7
# File 'lib/kave_rest_api/requests/countpostalcode.rb', line 5

def postalcode
  @postalcode
end

#responseObject (readonly)

Returns the value of attribute response.



6
7
8
# File 'lib/kave_rest_api/requests/countpostalcode.rb', line 6

def response
  @response
end

Instance Method Details

#callObject



23
24
25
26
27
28
29
30
# File 'lib/kave_rest_api/requests/countpostalcode.rb', line 23

def call
    connection = Faraday.new(url: "#{API_URL}/sms/") do |faraday|
      faraday.adapter Faraday.default_adapter
      faraday.response FORMAT.to_sym
    end
     response = connection.get(ACTION_NAME,countpostalcode: @countpostalcode)
     @response.validate(response.body)
end