Module: SimpleConnect::Api::ResponseAttachment
- Included in:
- Events, Integrations
- Defined in:
- lib/simple_connect/api/response_attachment.rb
Overview
Shared private helper for Api::Events and Api::Integrations. Parses the response body and returns a new Result with ‘.data` populated:
2xx + valid JSON → the caller-supplied success class
4xx/5xx + valid JSON → Responses::ErrorResponse
nil / empty body → returned unchanged (data stays nil)
4xx/5xx + non-JSON → returned unchanged (data stays nil)
2xx + unparseable JSON → raises MalformedResponseError (server bug)
Result is immutable (Data.define); this helper builds a new Result via ‘#with_data` rather than mutating the original.