Sha256: 05b016e60cd63c9b26a2405e154310705f4f4604f8b3b070738048ec78752c5b
Contents?: true
Size: 1 KB
Versions: 12
Compression:
Stored size: 1 KB
Contents
module SoapyCake class Client attr_reader :domain, :api_key, :time_offset def initialize(opts = {}) @domain = opts.fetch(:domain, ENV['CAKE_DOMAIN']) || fail(Error, 'Cake domain missing') @api_key = opts.fetch(:api_key, ENV['CAKE_API_KEY']) || fail(Error, 'Cake API key missing') @time_offset = opts.fetch(:time_offset, ENV['CAKE_TIME_OFFSET']) || fail(Error, 'Cake time offset missing') @opts = opts end protected attr_reader :opts def run(request) request.api_key = api_key request.time_offset = time_offset response = Response.new(http_response(request), request.short_response?) response.time_offset = time_offset response.collection end private def http_response(request) url = "https://#{domain}#{request.path}" HTTParty.post(url, headers: headers, body: request.xml, timeout: NET_TIMEOUT).body end def headers { 'Content-Type' => 'application/soap+xml;charset=UTF-8' } end end end
Version data entries
12 entries across 12 versions & 1 rubygems