Class: ElephantInTheRoom::TheOneApiSdk::Pipeline::Json
- Inherits:
-
Object
- Object
- ElephantInTheRoom::TheOneApiSdk::Pipeline::Json
- Defined in:
- lib/elephant_in_the_room/the_one_api_sdk/pipeline/json.rb
Overview
Pipeline stage to transform an HTTP body to JSON
Instance Method Summary collapse
- #execute_http_request(request_details) ⇒ Object
-
#initialize(next_pipeline_stage) ⇒ Json
constructor
A new instance of Json.
- #result_hash ⇒ Object
Constructor Details
#initialize(next_pipeline_stage) ⇒ Json
Returns a new instance of Json.
9 10 11 |
# File 'lib/elephant_in_the_room/the_one_api_sdk/pipeline/json.rb', line 9 def initialize(next_pipeline_stage) @next_pipeline_stage = next_pipeline_stage end |
Instance Method Details
#execute_http_request(request_details) ⇒ Object
13 14 15 |
# File 'lib/elephant_in_the_room/the_one_api_sdk/pipeline/json.rb', line 13 def execute_http_request(request_details) @result = @next_pipeline_stage.execute_http_request(request_details) end |
#result_hash ⇒ Object
17 18 19 20 21 |
# File 'lib/elephant_in_the_room/the_one_api_sdk/pipeline/json.rb', line 17 def result_hash JSON.parse(@next_pipeline_stage.http_body, symbolize_names: true) rescue JSON::ParserError => e raise ElephantInTheRoom::TheOneApiSdk::Errors::JsonParseError, "JSON response could not be parsed: #{e.message}" end |