mirror of
https://github.com/usetrmnl/trmnl-api.git
synced 2026-04-29 13:35:13 -07:00
Added IP address contract
Necessary to validate `ips` endpoint payloads. RuboCop has been updated to ignore the use of `ipv4` and `ipv6` since this is a design flaw of the original API design since `version_4` or `version_6` would have been better. This'll soon be corrected (transformed) when the corresponding model is added. Milestone: minor
This commit is contained in:
@@ -4,6 +4,9 @@ inherit_gem:
|
||||
Metrics/ParameterLists:
|
||||
Exclude:
|
||||
- lib/trmnl/api/requester.rb
|
||||
Naming/VariableNumber:
|
||||
Exclude:
|
||||
- lib/trmnl/api/contracts/ip_address.rb
|
||||
Style/IpAddresses:
|
||||
Exclude:
|
||||
- spec/lib/trmnl/api/types_spec.rb
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ require "zeitwerk"
|
||||
Dry::Schema.load_extensions :monads
|
||||
|
||||
Zeitwerk::Loader.new.then do |loader|
|
||||
loader.inflector.inflect "api" => "API", "trmnl" => "TRMNL"
|
||||
loader.inflector.inflect "api" => "API", "ip_address" => "IPAddress", "trmnl" => "TRMNL"
|
||||
loader.tag = "trmnl-api"
|
||||
loader.push_dir "#{__dir__}/.."
|
||||
loader.setup
|
||||
|
||||
@@ -24,6 +24,7 @@ module TRMNL
|
||||
register :current_screen, Contracts::CurrentScreen
|
||||
register :display, Contracts::Display
|
||||
register :firmware, Contracts::Firmware
|
||||
register :ip_address, Contracts::IPAddress
|
||||
register :model, Contracts::Model
|
||||
register :setup, Contracts::Setup
|
||||
end
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "dry/schema"
|
||||
|
||||
module TRMNL
|
||||
module API
|
||||
module Contracts
|
||||
# Validates API response.
|
||||
IPAddress = Dry::Schema.JSON do
|
||||
required(:data).hash do
|
||||
required(:ipv4).array(Types::IPAddress)
|
||||
required(:ipv6).array(Types::IPAddress)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user