Class: SmsRu::Stoplist
- Inherits:
-
Object
- Object
- SmsRu::Stoplist
- Defined in:
- lib/sms_ru/stoplist.rb
Overview
Manages the account stoplist (numbers that never receive messages and are never charged). Reached via SmsRu#stoplist, e.g. ‘client.stoplist.add(…)`.
Instance Method Summary collapse
-
#add(phone, note: nil) ⇒ Boolean
Adds a number to the stoplist.
-
#initialize(request) ⇒ Stoplist
constructor
private
A new instance of Stoplist.
-
#list ⇒ Array<SmsRu::StoplistEntry>
Returns every stoplisted number as an Array of SmsRu::StoplistEntry.
-
#remove(phone) ⇒ Boolean
Removes a number from the stoplist.
Constructor Details
#initialize(request) ⇒ Stoplist
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Stoplist.
9 10 11 |
# File 'lib/sms_ru/stoplist.rb', line 9 def initialize(request) @request = request end |
Instance Method Details
#add(phone, note: nil) ⇒ Boolean
Adds a number to the stoplist. ‘note` is visible only to you.
19 20 21 22 |
# File 'lib/sms_ru/stoplist.rb', line 19 def add(phone, note: nil) @request.call("/stoplist/add", stoplist_phone: phone.to_s, stoplist_text: note.to_s) true end |
#list ⇒ Array<SmsRu::StoplistEntry>
Returns every stoplisted number as an Array of SmsRu::StoplistEntry.
38 39 40 41 |
# File 'lib/sms_ru/stoplist.rb', line 38 def list data = @request.call("/stoplist/get") Coerce.records(data["stoplist"]).map { |phone, note| StoplistEntry.new(phone: String(phone), note: String(note)) } end |
#remove(phone) ⇒ Boolean
Removes a number from the stoplist.
29 30 31 32 |
# File 'lib/sms_ru/stoplist.rb', line 29 def remove(phone) @request.call("/stoplist/del", stoplist_phone: phone.to_s) true end |