class Emarsys::Request
Attributes
account[RW]
http_verb[RW]
params[RW]
path[RW]
Public Class Methods
new(account, http_verb, path, params = {})
click to toggle source
# File lib/emarsys/request.rb, line 7 def initialize(account, http_verb, path, params = {}) self.path = path self.http_verb = http_verb.to_sym self.params = params self.account = account end
Public Instance Methods
client()
click to toggle source
# File lib/emarsys/request.rb, line 38 def client Emarsys::Client.new(account) end
converted_params()
click to toggle source
# File lib/emarsys/request.rb, line 46 def converted_params Emarsys::ParamsConverter.new(params).convert_to_ids end
emarsys_uri()
click to toggle source
# File lib/emarsys/request.rb, line 42 def emarsys_uri [client.endpoint, @path].join('/') end
send_request()
click to toggle source
# File lib/emarsys/request.rb, line 14 def send_request args = { method: http_verb, url: emarsys_uri, headers: { content_type: :json, x_wsse: client.x_wsse_string } } if client.open_timeout args.merge!(open_timeout: client.open_timeout) end if client.read_timeout args.merge!(read_timeout: client.read_timeout) end if [:post, :put].include?(http_verb) args.merge!(payload: converted_params.to_json) end RestClient::Request.execute(args) do |response, request, result, &block| Emarsys::Response.new(response) end end