Sha256: a66a3406f5b6806559a9f17dd735bdabf9b0575a0fd46f016aa5007547b06091

Contents?: true

Size: 496 Bytes

Versions: 4

Compression:

Stored size: 496 Bytes

Contents

# frozen_string_literal: true

module Talkbird
  # Encapsulation of the SendBird API responses.
  module Result

    # Select the right result type based on the response.
    def self.create(response)
      status_code = response.code

      if 200 <= status_code && status_code < 400
        PaginatedSuccess.new(response).reduce
      else
        Result::Failure.new(response)
      end
    rescue StandardError => exception
      Result::Exception.new(response, exception)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
talkbird-0.0.5 lib/talkbird/result.rb
talkbird-0.0.4 lib/talkbird/result.rb
talkbird-0.0.3 lib/talkbird/result.rb
talkbird-0.0.2 lib/talkbird/result.rb