Class: KaveRestApi::Lookup

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Lookup

Returns a new instance of Lookup.



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

def initialize(args = {})
  super
  @ACTION_NAME    = [:lookup,@FORMAT].join('.').freeze
  @receptor    = args.fetch(:receptor)
  @receptor    = @receptor.ctsd
  @valid_receptor = @receptor.is_phone?
  @token       = args.fetch(:token)
  @token2      = args.fetch(:token2,nil)
  @token3      = args.fetch(:token3,nil)
  @template    = args.fetch(:template)
  @type        = args.fetch(:type,'sms')
  @response    = ResponseLookup.new
end

Instance Attribute Details

#dateObject

Returns the value of attribute date.



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

def date
  @date
end

#localidObject

Returns the value of attribute localid.



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

def localid
  @localid
end

#messageObject

Returns the value of attribute message.



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

def message
  @message
end

#message_sizeObject (readonly)

Returns the value of attribute message_size.



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

def message_size
  @message_size
end

#receptorObject

Returns the value of attribute receptor.



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

def receptor
  @receptor
end

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

#senderObject

Returns the value of attribute sender.



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

def sender
  @sender
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

#unixdateObject

Returns the value of attribute unixdate.



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

def unixdate
  @unixdate
end

Instance Method Details

#callObject



34
35
36
37
38
39
40
41
# File 'lib/kavenegar-ruby/requests/lookup.rb', line 34

def call
    connection = Faraday.new(url: "#{@API_URL}/verify/") do |faraday|
      faraday.adapter Faraday.default_adapter
      faraday.response @FORMAT.to_sym
    end
     response = connection.get(@ACTION_NAME, receptor: @receptor , token: @token , template: @template , type: @type , token2: @token2 , token3: @token3)
     @response.validate(response.body)
end

#valid_message?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/kavenegar-ruby/requests/lookup.rb', line 26

def valid_message?
  @valid_message ||= true
end

#valid_receptor?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/kavenegar-ruby/requests/lookup.rb', line 30

def valid_receptor?
  @valid_receptor
end