Class: SoapyCake::Request
- Inherits:
-
Object
- Object
- SoapyCake::Request
- Defined in:
- lib/soapy_cake/request.rb
Constant Summary collapse
- DATE_CLASSES =
[Date, Time, DateTime, ActiveSupport::TimeWithZone].freeze
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#time_converter ⇒ Object
Returns the value of attribute time_converter.
Instance Method Summary collapse
-
#initialize(role, service, method, opts = {}) ⇒ Request
constructor
A new instance of Request.
- #path ⇒ Object
- #read_only? ⇒ Boolean
- #short_response? ⇒ Boolean
- #to_s ⇒ Object
- #xml ⇒ Object
Constructor Details
#initialize(role, service, method, opts = {}) ⇒ Request
Returns a new instance of Request.
10 11 12 13 14 15 |
# File 'lib/soapy_cake/request.rb', line 10 def initialize(role, service, method, opts = {}) @role = role.to_s @service = service.to_s @method = method.to_s @opts = opts end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/soapy_cake/request.rb', line 7 def api_key @api_key end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
8 9 10 |
# File 'lib/soapy_cake/request.rb', line 8 def method @method end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
8 9 10 |
# File 'lib/soapy_cake/request.rb', line 8 def opts @opts end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
8 9 10 |
# File 'lib/soapy_cake/request.rb', line 8 def role @role end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
8 9 10 |
# File 'lib/soapy_cake/request.rb', line 8 def service @service end |
#time_converter ⇒ Object
Returns the value of attribute time_converter.
7 8 9 |
# File 'lib/soapy_cake/request.rb', line 7 def time_converter @time_converter end |
Instance Method Details
#path ⇒ Object
17 18 19 |
# File 'lib/soapy_cake/request.rb', line 17 def path "#{api_path}/#{service}.asmx" end |
#read_only? ⇒ Boolean
42 43 44 |
# File 'lib/soapy_cake/request.rb', line 42 def read_only? (API_CONFIG.dig('read_only', role, service) || []).include?(method) end |
#short_response? ⇒ Boolean
34 35 36 |
# File 'lib/soapy_cake/request.rb', line 34 def short_response? %w[addedit track signup].include?(service) end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/soapy_cake/request.rb', line 38 def to_s "#{role}:#{service}:#{method}:#{version} #{opts.to_json}" end |
#xml ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/soapy_cake/request.rb', line 21 def xml Nokogiri::XML::Builder.new do |xml| xml['env'].Envelope(xml_namespaces) do xml.Header xml.Body do xml['cake'].public_send(method.camelize.to_sym) do xml_params(xml) end end end end.to_xml end |