Class: ComteleSdk::ContactMessageService

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

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ ContactMessageService

Returns a new instance of ContactMessageService.



349
350
351
352
353
354
355
356
357
# File 'lib/comtele_sdk.rb', line 349

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

#schedule(sender, content, group_name, schedule_date) ⇒ Object



373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'lib/comtele_sdk.rb', line 373

def schedule(sender, content, group_name, schedule_date)
    url = @base_address + '/schedulecontactmessage'   
    
    payload = JSON.generate({
        'sender': sender,
        'content': content,
        'scheduleDate': schedule_date,
        'groupName': group_name
    })
    
    response = RestClient.post(url, payload, @headers)
    
    return JSON.parse(response)
end

#send(sender, content, group_name) ⇒ Object



359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/comtele_sdk.rb', line 359

def send(sender, content, group_name)
    url = @base_address + '/sendcontactmessage'   
    
    payload = JSON.generate({
        'sender': sender,
        'content': content,
        'groupName': group_name
    })
    
    response = RestClient.post(url, payload, @headers)
    
    return JSON.parse(response)
end