Class: KaveRestApi::Cancel

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Cancel

Returns a new instance of Cancel.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kavenegar-ruby/requests/cancel.rb', line 12

def initialize(args = {})
  super
  @ACTION_NAME    = [:countinbox,@FORMAT].join('.').freeze
  @messageid      = args.fetch(:messageid)
  if @messageid.kind_of?(Array)
    @valid= false if @messageid.length > 200
    @messageid    = @messageid.join(',') 
  end
  @messageid      = @messageid.ctsd
  
  @response       = ResponseCancel.new
end

Instance Attribute Details

#messageidObject

Returns the value of attribute messageid.



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

def messageid
  @messageid
end

#responseObject (readonly)

Returns the value of attribute response.



6
7
8
# File 'lib/kavenegar-ruby/requests/cancel.rb', line 6

def response
  @response
end

Instance Method Details

#callObject



29
30
31
32
33
34
35
36
# File 'lib/kavenegar-ruby/requests/cancel.rb', line 29

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,isread: @isread, linenumber: @linenumber,startdate: @startdate,enddate: @enddate)
     @response.validate(response.body)
end

#valid?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/kavenegar-ruby/requests/cancel.rb', line 25

def valid?
  @valid ||= true
end