Class: ComteleSdk::BlacklistService
- Inherits:
-
Object
- Object
- ComteleSdk::BlacklistService
- Defined in:
- lib/comtele_sdk.rb
Instance Method Summary collapse
- #get_blacklist ⇒ Object
- #get_by_phone_number(phone_number) ⇒ Object
-
#initialize(api_key) ⇒ BlacklistService
constructor
A new instance of BlacklistService.
- #insert(phone_number) ⇒ Object
- #remove(phone_number) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ BlacklistService
Returns a new instance of BlacklistService.
207 208 209 210 211 212 213 214 215 |
# File 'lib/comtele_sdk.rb', line 207 def initialize(api_key) @api_key = api_key @base_address = 'https://sms.comtele.com.br/api/v2' @headers = { 'Accept': 'application/json', 'Content-type': 'application/json', 'auth-key': @api_key } end |
Instance Method Details
#get_blacklist ⇒ Object
217 218 219 220 221 222 |
# File 'lib/comtele_sdk.rb', line 217 def get_blacklist() url = @base_address + '/blacklist' response = RestClient.get(url, @headers) return JSON.parse(response) end |
#get_by_phone_number(phone_number) ⇒ Object
224 225 226 227 228 229 |
# File 'lib/comtele_sdk.rb', line 224 def get_by_phone_number(phone_number) url = @base_address + '/blacklist?id=' + phone_number response = RestClient.get(url, @headers) return JSON.parse(response) end |
#insert(phone_number) ⇒ Object
231 232 233 234 235 236 237 238 |
# File 'lib/comtele_sdk.rb', line 231 def insert(phone_number) url = @base_address + '/blacklist' payload = JSON.generate({ 'phoneNumber': phone_number }) response = RestClient.post(url, payload, @headers) return JSON.parse(response) end |
#remove(phone_number) ⇒ Object
240 241 242 243 244 245 |
# File 'lib/comtele_sdk.rb', line 240 def remove(phone_number) url = @base_address + '/blacklist?id=' + phone_number response = RestClient.delete(url, {}, @headers) return JSON.parse(response) end |