Class: Setsuzoku::Service::WebService::ApiStrategy
- Inherits:
-
Object
- Object
- Setsuzoku::Service::WebService::ApiStrategy
- Extended by:
- T::Helpers, T::Sig
- Includes:
- ApiStrategy
- Defined in:
- lib/setsuzoku/service/web_service/api_strategy.rb
Direct Known Subclasses
Defined Under Namespace
Modules: InterfaceMethods
Instance Attribute Summary
Attributes included from ApiStrategy
Attributes included from HasConfigContext
Instance Method Summary collapse
-
#api_headers ⇒ Hash
Specific API headers an API strategy must have when making requests.
- #parse_response(response:, **options) ⇒ Object
- #perform_external_call(request:, action_details:, **options) ⇒ Object
Methods included from ApiStrategy
#call_external_api, #final, #initialize
Methods included from HasConfigContext
Instance Method Details
#api_headers ⇒ Hash
Specific API headers an API strategy must have when making requests.
52 53 54 |
# File 'lib/setsuzoku/service/web_service/api_strategy.rb', line 52 def api_headers {} end |
#parse_response(response:, **options) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/setsuzoku/service/web_service/api_strategy.rb', line 81 def parse_response(response:, **) case [:response_type] when :json resp = JSON.parse(response.body) resp.is_a?(Hash) ? resp.deep_symbolize_keys : resp when :xml convert_xml_to_hash(response.body) when :html response.body when :txt, :png, :jpg, :gif # for now just return the file response.body # for now just put in tmp # tmp_dir = "#{Dir.tmpdir}/setsuzoku/#{self.plugin.class.system_name.underscore}/#{self.plugin.name.underscore}" # file_name = "#{self.plugin.class.system_name.underscore}_#{self.plugin.name.underscore}_#{Time.now.strftime("%Y_%m_%d_%T")}" # t = Tempfile.new([file_name, ".#{options[:response_type]}"], encoding: 'ascii-8bit') # t.write(response.body) # t.rewind # t else resp = JSON.parse(response.body) resp.is_a?(Hash) ? resp.deep_symbolize_keys : resp end end |
#perform_external_call(request:, action_details:, **options) ⇒ Object
71 |
# File 'lib/setsuzoku/service/web_service/api_strategy.rb', line 71 def perform_external_call(request:, action_details:, **); end |