Sha256: d1c46d5f3011272f76264bb00acf874ab0015ebedc871b4b9d446cbd025dd54d
Contents?: true
Size: 909 Bytes
Versions: 3
Compression:
Stored size: 909 Bytes
Contents
module Zenvia class Request BASE_URL = "http://www.zenvia360.com.br" POST_PATH = "/GatewayIntegration/msgSms.do" attr_reader :params, :response def initialize session.base_url = BASE_URL session.timeout = Zenvia.config.timeout end def post(params) @params = params @response = session.post POST_PATH, parse_params parse_response end private def parse_response code, message = response.body.split " - " raise Error, message if code != "000" {code: code, message: message} end def parse_params { account: Zenvia.config.account, code: Zenvia.config.code, dispatch: params[:dispatch], to: params[:to], msg: params[:message], id: params[:id] } end def session @session ||= Patron::Session.new end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
zenvia-0.0.3 | lib/zenvia/request.rb |
zenvia-0.0.2 | lib/zenvia/request.rb |
zenvia-0.0.1 | lib/zenvia/request.rb |