Class: MobilySender

Inherits:
Object
  • Object
show all
Defined in:
lib/mobily/mobily_sender.rb

Instance Method Summary collapse

Constructor Details

#initialize(auth) ⇒ MobilySender



6
7
8
# File 'lib/mobily/mobily_sender.rb', line 6

def initialize(auth)
  @auth = auth
end

Instance Method Details

#activate_mobile_number_license(sender_id, activation_code) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/mobily/mobily_sender.rb', line 18

def activate_mobile_number_license(sender_id, activation_code)
  request_handler = MobilyApiJsonRequestHandler.new(@auth)
  request_handler.set_api_method('activeSender')
  request_handler.add_parameter('senderId', sender_id.tr('#', ''))
  request_handler.add_parameter('activeKey', activation_code)
  request_handler.handle
end

#get_activation_status_for_all_sendersObject



46
47
48
49
50
# File 'lib/mobily/mobily_sender.rb', line 46

def get_activation_status_for_all_senders
  request_handler = MobilyApiJsonRequestHandler.new(@auth)
  request_handler.set_api_method('checkAlphasSender')
  request_handler.handle.data
end

#is_mobile_number_license_active?(sender_id) ⇒ Boolean



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/mobily/mobily_sender.rb', line 26

def is_mobile_number_license_active?(sender_id)
  request_handler = MobilyApiJsonRequestHandler.new(@auth)
  request_handler.set_api_method('checkSender')
  request_handler.add_parameter('senderId', sender_id.tr('#', ''))
  begin
    response = request_handler.handle
  rescue MobilyApiError
    false
  else
    response.get('result') == '1'
  end
end

#request_alphabetical_license(sender) ⇒ Object



39
40
41
42
43
44
# File 'lib/mobily/mobily_sender.rb', line 39

def request_alphabetical_license(sender)
  request_handler = MobilyApiJsonRequestHandler.new(@auth)
  request_handler.set_api_method('addAlphaSender')
  request_handler.add_parameter('sender', sender)
  request_handler.handle
end

#request_mobile_number_license(mobile_number) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/mobily/mobily_sender.rb', line 10

def request_mobile_number_license(mobile_number)
  request_handler = MobilyApiJsonRequestHandler.new(@auth)
  request_handler.set_api_method('addSender')
  request_handler.add_parameter('sender', mobile_number)
  response = request_handler.handle
  response.get('senderId')
end