Class: ComteleSdk::ContactService
- Inherits:
-
Object
- Object
- ComteleSdk::ContactService
- Defined in:
- lib/comtele_sdk.rb
Instance Method Summary collapse
- #add_contact_to_group(group_name, contact_phone, contact_name) ⇒ Object
- #create_group(group_name, group_description) ⇒ Object
- #get_all_groups ⇒ Object
- #get_group_by_name(group_name) ⇒ Object
-
#initialize(api_key) ⇒ ContactService
constructor
A new instance of ContactService.
- #remove_contact_from_group(group_name, contact_phone) ⇒ Object
- #remove_group(group_name) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ ContactService
Returns a new instance of ContactService.
249 250 251 252 253 254 255 256 257 |
# File 'lib/comtele_sdk.rb', line 249 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
#add_contact_to_group(group_name, contact_phone, contact_name) ⇒ Object
291 292 293 294 295 296 297 298 |
# File 'lib/comtele_sdk.rb', line 291 def add_contact_to_group(group_name, contact_phone, contact_name) url = @base_address + 'contactgroup' payload = JSON.generate({'groupName': group_name, 'contactPhone': contact_phone, 'contactName': contact_name, 'action': 'add_number'}) response = RestClient.put(url, payload, @headers) return JSON.parse(response) end |
#create_group(group_name, group_description) ⇒ Object
259 260 261 262 263 264 265 266 |
# File 'lib/comtele_sdk.rb', line 259 def create_group(group_name, group_description) url = @base_address + 'contactgroup' payload = JSON.generate({'name': group_name, 'description': group_description}) response = RestClient.post(url, payload, @headers) return JSON.parse(response) end |
#get_all_groups ⇒ Object
275 276 277 278 279 280 281 |
# File 'lib/comtele_sdk.rb', line 275 def get_all_groups() url = @base_address + 'contactgroup' response = RestClient.get(url, @headers) return JSON.parse(response) end |
#get_group_by_name(group_name) ⇒ Object
283 284 285 286 287 288 289 |
# File 'lib/comtele_sdk.rb', line 283 def get_group_by_name(group_name) url = @base_address + 'contactgroup?id=' + group_name response = RestClient.get(url, @headers) return JSON.parse(response) end |
#remove_contact_from_group(group_name, contact_phone) ⇒ Object
300 301 302 303 304 305 306 |
# File 'lib/comtele_sdk.rb', line 300 def remove_contact_from_group(group_name, contact_phone) url = @base_address + 'contactgroup' payload = JSON.generate({'groupName': group_name, 'contactPhone': contact_phone, 'action': 'remove_number'}) response = RestClient.put(url, payload, @headers) return JSON.parse(response) end |
#remove_group(group_name) ⇒ Object
268 269 270 271 272 273 |
# File 'lib/comtele_sdk.rb', line 268 def remove_group(group_name) url = @base_address + 'contactgroup?id=' + group_name response = RestClient.delete(url, {}, @headers) return JSON.parse(response) end |