Sha256: 19a27fbc3e5198115adff5582cd57ad9768381e178c85584873c8c0270d9d9b8
Contents?: true
Size: 659 Bytes
Versions: 5
Compression:
Stored size: 659 Bytes
Contents
# frozen_string_literal: true require 'truelayer/base_model' module Truelayer class Response < BaseModel attributes :results_uri, :status, :task_id attr_accessor :results def self.build_with_results(json:, results_class:) build(json: json).tap do |response| if response.success? response.results = json.fetch(:results, []).map do |result| results_class.build(json: result) end end end end def initialize(*args) @results = [] super end def async? task_id && !task_id.empty? end def success? status == 'Succeeded' end end end
Version data entries
5 entries across 5 versions & 1 rubygems