Sha256: 873cab9995999da21022bdc104c83b2d90e38bb9e5a028909188b721f5581a21
Contents?: true
Size: 1016 Bytes
Versions: 2
Compression:
Stored size: 1016 Bytes
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) rescue Oj::ParseError => e raise "Error parsing response: #{e.message}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby_api_pack_cloudways-0.2.0 | lib/ruby_api_pack_cloudways/connection/cw_token.rb |
ruby_api_pack_cloudways-0.1.0 | lib/ruby_api_pack_cloudways/connection/cw_token.rb |