diff --git a/lib/trmnl/api/models/current_screen.rb b/lib/trmnl/api/models/current_screen.rb new file mode 100644 index 0000000..c5b35c8 --- /dev/null +++ b/lib/trmnl/api/models/current_screen.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module TRMNL + module API + module Models + # Models API response. + CurrentScreen = Data.define :refresh_rate, :image_url, :filename do + def self.for(attributes) = new(**attributes) + end + end + end +end diff --git a/spec/lib/trmnl/api/models/current_screen_spec.rb b/spec/lib/trmnl/api/models/current_screen_spec.rb new file mode 100644 index 0000000..6312cf4 --- /dev/null +++ b/spec/lib/trmnl/api/models/current_screen_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require "spec_helper" + +RSpec.describe TRMNL::API::Models::CurrentScreen do + describe ".for" do + it "answers record for attributes" do + attributes = {refresh_rate: 1, image_url: "https://test.io", filename: "test"} + + expect(described_class.for(attributes)).to eq(described_class[**attributes]) + end + end +end