Class: KaveRestApi::LatestOutBox

Inherits:
RequestBase show all
Includes:
Validatable
Defined in:
lib/kavenegar-ruby/requests/latestoutbox.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ LatestOutBox

Returns a new instance of LatestOutBox.



9
10
11
12
13
14
15
# File 'lib/kavenegar-ruby/requests/latestoutbox.rb', line 9

def initialize(args = {})
  super
  @ACTION_NAME = [:latestoutbox,@FORMAT].join('.').freeze
  @pagesize    = args.fetch(:pagesize,3000).ctsd 
  @sender      = args.fetch(:sender,nil)
  @response    = ResponseLatestOutBox.new
end

Instance Attribute Details

#pagesizeObject

Returns the value of attribute pagesize.



4
5
6
# File 'lib/kavenegar-ruby/requests/latestoutbox.rb', line 4

def pagesize
  @pagesize
end

#responseObject (readonly)

Returns the value of attribute response.



5
6
7
# File 'lib/kavenegar-ruby/requests/latestoutbox.rb', line 5

def response
  @response
end

#senderObject

Returns the value of attribute sender.



4
5
6
# File 'lib/kavenegar-ruby/requests/latestoutbox.rb', line 4

def sender
  @sender
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
# File 'lib/kavenegar-ruby/requests/latestoutbox.rb', line 17

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, sender: @sender,pagesize: @pagesize)
     @response.validate(response.body)
end