Sha256: a7d7333530446f0bf504c13982e4d5f0664276a568a84ac5f0a86d2201348c2d
Contents?: true
Size: 862 Bytes
Versions: 1
Compression:
Stored size: 862 Bytes
Contents
# typed: strict # frozen_string_literal: true module Etwin module Client # HTTP Etwin client interface class HttpEtwinClient extend T::Helpers extend T::Sig include EtwinClient final! sig(:final) { params(base_uri: URI::HTTP).void } def initialize(base_uri) @base_uri = T.let(base_uri.freeze, URI::HTTP) freeze end sig(:final) { override.params(auth: Auth, user_id: Etwin::User::UserId).returns(Etwin::User::User) } def get_user(auth, user_id) uri = resolve(['users', user_id.to_s]) res = Faraday.get uri Etwin::User::User.from_json res.body end private sig(:final) { params(segments: T::Array[String]).returns(URI::HTTP) } def resolve(segments) @base_uri.merge("api/v1/#{ segments * '/'}") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
etwin-0.0.2 | lib/etwin/client/http_etwin_client.rb |