Sha256: 0f4c6138b8d4d278b97011e107efbeee941c2300cb463521efb8bd5885280c5a
Contents?: true
Size: 947 Bytes
Versions: 3
Compression:
Stored size: 947 Bytes
Contents
module Lifen class AppAuthenticatedClient < Client def post(url, params = {}) response = faraday_client.post do |req| req.url url req.headers['secret_key'] = secret_key req.headers['Content-Type'] = "application/json" req.body = JSON.generate(params) end if response.status == 500 json = JSON.parse response.body trace_id = json.fetch("X-B3-TraceId", "unknown") raise Error, "Error 500, Internal server error (trace ID: #{trace_id})" end raise Error, "Error 400" if response.status == 400 raise Error, "Error 404, Page not found" if response.status == 404 raise InvalidSecretTokenError if response.status == 401 raise UserAlreadyExistingError if response.status == 403 json = JSON.parse response.body json end private def secret_key Lifen.configuration.secret_key end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lifen-0.2.1 | lib/lifen/app_authenticated_client.rb |
lifen-0.2.0 | lib/lifen/app_authenticated_client.rb |
lifen-0.1.5 | lib/lifen/app_authenticated_client.rb |