Class: Urbanairship::Devices::Sms
- Inherits:
-
Object
- Object
- Urbanairship::Devices::Sms
- Defined in:
- lib/urbanairship/devices/sms.rb
Constant Summary
Constants included from Common
Instance Attribute Summary collapse
-
#channel_id ⇒ Object
Returns the value of attribute channel_id.
-
#locale_country ⇒ Object
Returns the value of attribute locale_country.
-
#locale_language ⇒ Object
Returns the value of attribute locale_language.
-
#msisdn ⇒ Object
Returns the value of attribute msisdn.
-
#opted_in ⇒ Object
Returns the value of attribute opted_in.
-
#sender ⇒ Object
Returns the value of attribute sender.
-
#timezone ⇒ Object
Returns the value of attribute timezone.
Instance Method Summary collapse
-
#initialize(client: required('client')) ⇒ Sms
constructor
A new instance of Sms.
- #lookup ⇒ Object
- #opt_out ⇒ Object
- #register ⇒ Object
- #uninstall ⇒ Object
- #update ⇒ Object
Methods included from Loggable
create_logger, logger, #logger
Methods included from Common
#apid_path, #channel_path, #compact_helper, #create_and_send_path, #custom_events_path, #device_token_path, #experiments_path, #lists_path, #named_users_path, #open_channel_path, #pipelines_path, #push_path, #reports_path, #required, #schedules_path, #segments_path, #tag_lists_path, #try_helper
Constructor Details
#initialize(client: required('client')) ⇒ Sms
Returns a new instance of Sms.
17 18 19 |
# File 'lib/urbanairship/devices/sms.rb', line 17 def initialize(client: required('client')) @client = client end |
Instance Attribute Details
#channel_id ⇒ Object
Returns the value of attribute channel_id.
8 9 10 |
# File 'lib/urbanairship/devices/sms.rb', line 8 def channel_id @channel_id end |
#locale_country ⇒ Object
Returns the value of attribute locale_country.
8 9 10 |
# File 'lib/urbanairship/devices/sms.rb', line 8 def locale_country @locale_country end |
#locale_language ⇒ Object
Returns the value of attribute locale_language.
8 9 10 |
# File 'lib/urbanairship/devices/sms.rb', line 8 def locale_language @locale_language end |
#msisdn ⇒ Object
Returns the value of attribute msisdn.
8 9 10 |
# File 'lib/urbanairship/devices/sms.rb', line 8 def msisdn @msisdn end |
#opted_in ⇒ Object
Returns the value of attribute opted_in.
8 9 10 |
# File 'lib/urbanairship/devices/sms.rb', line 8 def opted_in @opted_in end |
#sender ⇒ Object
Returns the value of attribute sender.
8 9 10 |
# File 'lib/urbanairship/devices/sms.rb', line 8 def sender @sender end |
#timezone ⇒ Object
Returns the value of attribute timezone.
8 9 10 |
# File 'lib/urbanairship/devices/sms.rb', line 8 def timezone @timezone end |
Instance Method Details
#lookup ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/urbanairship/devices/sms.rb', line 103 def lookup fail ArgumentError,'msisdn is required for lookup' if msisdn.nil? fail ArgumentError,'sender is required for lookup' if sender.nil? response = @client.send_request( method: 'GET', path: channel_path('sms/' + @msisdn + '/' + @sender) ) logger.info { "Retrieved information for msisdn #{@msisdn}" } response end |
#opt_out ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/urbanairship/devices/sms.rb', line 65 def opt_out fail ArgumentError, 'sender must be set to opt out sms channel' if sender.nil? fail ArgumentError, 'msisdn must be set to opt out sms channel' if msisdn.nil? payload = { 'msisdn': msisdn, 'sender': sender, } response = @client.send_request( method: 'POST', body: JSON.dump(payload), path: channel_path('sms/opt-out'), content_type: 'application/json' ) logger.info("Opting Out of SMS messages for #{@msisdn}") response end |
#register ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/urbanairship/devices/sms.rb', line 21 def register fail ArgumentError, 'sender must be set to register sms channel' if sender.nil? fail ArgumentError, 'msisdn must be set to register sms channel' if msisdn.nil? payload = { 'msisdn': msisdn, 'sender': sender, 'opted_in': opted_in } response = @client.send_request( method: 'POST', body: JSON.dump(payload), path: channel_path('sms'), content_type: 'application/json' ) logger.info("Registering SMS channel with msisdn #{@msisdn}") response end |
#uninstall ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/urbanairship/devices/sms.rb', line 84 def uninstall fail ArgumentError, 'sender must be set to uninstall sms channel' if sender.nil? fail ArgumentError, 'msisdn must be set to uninstall sms channel' if msisdn.nil? payload = { 'msisdn': msisdn, 'sender': sender, } response = @client.send_request( method: 'POST', body: JSON.dump(payload), path: channel_path('sms/uninstall'), content_type: 'application/json' ) logger.info("Uninstalling SMS channel for #{@msisdn}") response end |
#update ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/urbanairship/devices/sms.rb', line 41 def update fail ArgumentError, 'sender must be set to update sms channel' if sender.nil? fail ArgumentError, 'msisdn must be set to update sms channel' if msisdn.nil? fail ArgumentError, 'channel_id must be set to update sms channel' if channel_id.nil? payload = { 'msisdn': msisdn, 'sender': sender, 'opted_in': opted_in, 'locale_country': locale_country, 'locale_language': locale_language, 'timezone': timezone }.delete_if {|key, value| value.nil?} #this removes the nil key value pairs response = @client.send_request( method: 'PUT', body: JSON.dump(payload), path: channel_path('sms/' + channel_id), content_type: 'application/json' ) logger.info("Updating SMS channel with msisdn #{@channel_id}") response end |