mirror of
https://github.com/usetrmnl/trmnl-api.git
synced 2026-04-29 13:35:13 -07:00
Added setup model
Necessary to model the API response.
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module TRMNL
|
||||||
|
module API
|
||||||
|
module Models
|
||||||
|
# Models API response.
|
||||||
|
Setup = Data.define :api_key, :friendly_id, :image_url, :message do
|
||||||
|
def self.for(attributes) = new(**attributes)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "spec_helper"
|
||||||
|
|
||||||
|
RSpec.describe TRMNL::API::Models::Setup do
|
||||||
|
describe ".for" do
|
||||||
|
it "answers record for attributes" do
|
||||||
|
attributes = {
|
||||||
|
api_key: "abc",
|
||||||
|
friendly_id: "10CBAF",
|
||||||
|
image_url: "https://usetrmnl.com/images/logo.bmp",
|
||||||
|
message: "Welcome!"
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(described_class.for(attributes)).to eq(described_class[**attributes])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user