Class: Moceansdk::Modules::Message::VerifyRequest

Inherits:
AbstractClient show all
Defined in:
lib/moceansdk/modules/message/verify_request.rb

Instance Attribute Summary collapse

Attributes inherited from AbstractClient

#params

Instance Method Summary collapse

Methods inherited from AbstractClient

#create, #create_final_params, #param_prefix_set?, #required_field_set?

Constructor Details

#initialize(obj_auth, transmitter) ⇒ VerifyRequest

Returns a new instance of VerifyRequest.



8
9
10
11
12
13
# File 'lib/moceansdk/modules/message/verify_request.rb', line 8

def initialize(obj_auth, transmitter)
  super(obj_auth, transmitter)
  @required_fields = ['mocean-api-key', 'mocean-api-secret', 'mocean-to', 'mocean-brand']
  @channel = Channel::AUTO
  @is_resend = false
end

Instance Attribute Details

#channelObject (readonly)

Returns the value of attribute channel.



6
7
8
# File 'lib/moceansdk/modules/message/verify_request.rb', line 6

def channel
  @channel
end

#is_resendObject (readonly)

Returns the value of attribute is_resend.



6
7
8
# File 'lib/moceansdk/modules/message/verify_request.rb', line 6

def is_resend
  @is_resend
end

Instance Method Details

#brand=(param) ⇒ Object



19
20
21
# File 'lib/moceansdk/modules/message/verify_request.rb', line 19

def brand=(param)
  @params['mocean-brand'] = param
end

#code_length=(param) ⇒ Object



27
28
29
# File 'lib/moceansdk/modules/message/verify_request.rb', line 27

def code_length=(param)
  @params['mocean-code-length'] = param
end

#from=(param) ⇒ Object



23
24
25
# File 'lib/moceansdk/modules/message/verify_request.rb', line 23

def from=(param)
  @params['mocean-from'] = param
end

#next_event_wait=(param) ⇒ Object



39
40
41
# File 'lib/moceansdk/modules/message/verify_request.rb', line 39

def next_event_wait=(param)
  @params['mocean-next-event-wait'] = param
end

#pin_validity=(param) ⇒ Object



35
36
37
# File 'lib/moceansdk/modules/message/verify_request.rb', line 35

def pin_validity=(param)
  @params['mocean-pin-validity'] = param
end

#resend(params = {}) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/moceansdk/modules/message/verify_request.rb', line 73

def resend(params = {})
  send_as Channel::SMS
  @is_resend = true
  @required_fields = ['mocean-api-key', 'mocean-api-secret', 'mocean-reqid']

  send(params)
end

#resp_format=(param) ⇒ Object



43
44
45
# File 'lib/moceansdk/modules/message/verify_request.rb', line 43

def resp_format=(param)
  @params['mocean-resp-format'] = param
end

#send(params = {}) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/moceansdk/modules/message/verify_request.rb', line 52

def send(params = {})
  create(params)
  create_final_params
  required_field_set?

  verify_request_url = '/verify'
  verify_request_url += if @is_resend
                          '/resend'
                        else
                          '/req'
                        end

  if @channel == Channel::SMS
    verify_request_url += '/sms'
  elsif @channel == Channel::TELEGRAM
    verify_request_url += '/telegram'
  end

  @transmitter.post(verify_request_url, @params)
end

#send_as(channel) ⇒ Object



47
48
49
50
# File 'lib/moceansdk/modules/message/verify_request.rb', line 47

def send_as(channel)
  @channel = channel
  self
end

#template=(param) ⇒ Object



31
32
33
# File 'lib/moceansdk/modules/message/verify_request.rb', line 31

def template=(param)
  @params['mocean-template'] = param
end

#to=(param) ⇒ Object



15
16
17
# File 'lib/moceansdk/modules/message/verify_request.rb', line 15

def to=(param)
  @params['mocean-to'] = param
end