Class: KaveRestApi::Deliver

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Deliver

Returns a new instance of Deliver.



10
11
12
13
14
15
16
17
18
19
# File 'lib/kavenegar-ruby/requests/deliver.rb', line 10

def initialize(args = {})
  @ACTION_NAME    = [:status,@FORMAT].join('.').freeze
  @messageid    = args.fetch(:messageid)
  if @messageid.kind_of?(Array)
    raise(ArgumentError,'Message Id Arrays: Buffer Overflow: Max length 3000 of array') if @messageid.length > 3000
    @messageid    = @messageid.join(',') 
  end
  @messageid    = @messageid.ctsd
  @response     = ResponseDeliver.new
end

Instance Attribute Details

#messageidObject

Returns the value of attribute messageid.



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

def messageid
  @messageid
end

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#callObject



21
22
23
24
25
26
27
28
# File 'lib/kavenegar-ruby/requests/deliver.rb', line 21

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