Sha256: 5e93ea9158f93041febdedfbbdf3255a61e95d7ff8ab8c6f5cc708f4a549d80c
Contents?: true
Size: 782 Bytes
Versions: 1
Compression:
Stored size: 782 Bytes
Contents
# frozen_string_literal: true require 'httparty' module CSVPP class FormatsClient include HTTParty DEFAULT_HOST = 'http://formats.iapps.swissdrg.local' def initialize(host: DEFAULT_HOST) self.class.base_uri ENV['FORMATS_HOST'] || host end # @return [String] e.g. "http://formats.iapps.swissdrg.local" def base_uri self.class.base_uri end # @return [Array<Format>] def formats self.class.get('/api/formats').map { |hash| Format.new(hash) } end # @param name [String] # @return [Format] def format(name) response = self.class.get("/api/formats/#{name}") if (error = response['error']) raise ArgumentError, %{#{error} "#{name}"} end Format.new(response) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
csvpp-0.4.0 | lib/csvpp/formats_client.rb |