Sha256: 8305a9e85aa2d28541182f7f42daf8f02728fdcb2d96f514e05cd41020cdd35d
Contents?: true
Size: 716 Bytes
Versions: 3
Compression:
Stored size: 716 Bytes
Contents
# frozen_string_literal: true module AppleMusic # https://developer.apple.com/documentation/applemusicapi/responseroot class Response attr_reader :data, :errors, :href, :meta, :next, :results def initialize(props = {}) props ||= {} @data = Array(props['data']).map { |attrs| Resource.build(attrs) } @errors = Array(props['errors']).map { |attrs| Error.new(attrs) } @href = props['href'] @meta = props['meta'] @next = props['next'] @results = props['results'] raise_api_error unless success? end private def raise_api_error raise ApiError, errors.map(&:title).join(', ') end def success? errors.empty? end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
apple_music-0.3.1 | lib/apple_music/response.rb |
apple_music-0.3.0 | lib/apple_music/response.rb |
apple_music-0.2.0 | lib/apple_music/response.rb |