Class: ComteleSdk::TextMessageService

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

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ TextMessageService

Returns a new instance of TextMessageService.



152
153
154
155
156
157
158
159
160
# File 'lib/comtele_sdk.rb', line 152

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_consolidated_report(start_date, end_date, group_type) ⇒ Object



198
199
200
201
202
203
# File 'lib/comtele_sdk.rb', line 198

def get_consolidated_report(start_date, end_date, group_type)
    url = @base_address + '/consolidatedreporting?startDate=' + start_date + '&endDate=' + end_date + '&group=' + group_type
    response = RestClient.get(url, @headers)
    
    return JSON.parse(response)    
end

#get_detailed_report(start_date, end_date, delivery_status) ⇒ Object



191
192
193
194
195
196
# File 'lib/comtele_sdk.rb', line 191

def get_detailed_report(start_date, end_date, delivery_status)
    url = @base_address + '/detailedreporting?startDate=' + start_date + '&endDate=' + end_date + '&delivered=' + delivery_status
    response = RestClient.get(url, @headers)
    
    return JSON.parse(response)
end

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



176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/comtele_sdk.rb', line 176

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

#send(sender, content, receivers) ⇒ Object



162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/comtele_sdk.rb', line 162

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