Class: CmSms::Request
- Inherits:
-
Object
- Object
- CmSms::Request
- Defined in:
- lib/cm_sms/request.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(body) ⇒ Request
constructor
A new instance of Request.
- #perform ⇒ Object
Constructor Details
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
5 6 7 |
# File 'lib/cm_sms/request.rb', line 5 def body @body end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
7 8 9 |
# File 'lib/cm_sms/request.rb', line 7 def response @response end |
Instance Method Details
#perform ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cm_sms/request.rb', line 15 def perform raise CmSms::Configuration::EndpointMissing.new("Please provide an valid api endpoint.\nIf you leave this config blank, the default will be set to https://sgw01.cm.nl.") if @endpoint.nil? || @endpoint.empty? raise CmSms::Configuration::PathMissing.new("Please provide an valid api path.\nIf you leave this config blank, the default will be set to /gateway.ashx.") if @path.nil? || @path.empty? uri = URI.parse(@endpoint) Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http| @response = Response.new(http.post(@path, body, initheader = { 'Content-Type' => 'application/xml' })) end response end |