Sha256: 6734b600b43bf9c42e247880427a7c26c4f36774322c41a26dd2a3046fc170ce
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module RubyApiPackCloudways module Connection class CwToken attr_reader :cw_api_url_base, :cw_url_path_auth, :cw_user_email, :cw_user_key def initialize @cw_api_url_base = RubyApiPackCloudways.configuration.api_url @cw_url_path_auth = RubyApiPackCloudways.configuration.api_path_token @cw_user_email = RubyApiPackCloudways.configuration.api_email @cw_user_key = RubyApiPackCloudways.configuration.api_key end def cw_api_token response = HTTParty.post( "#{@cw_api_url_base}#{@cw_url_path_auth}", headers: { 'Content-Type' => 'application/x-www-form-urlencoded' }, body: { email: @cw_user_email, api_key: @cw_user_key } ) parse_response(response)['access_token'] end private def parse_response(response) Oj.load(response.body, mode: :strict) rescue Oj::ParseError => e raise "Error parsing response: #{e.message}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby_api_pack_cloudways-0.3.0 | lib/ruby_api_pack_cloudways/connection/cw_token.rb |