Sha256: d689ba92b0e2514feaa422d96ce3572de72d26df3b9cf2865f5ca5cb8fa6e052
Contents?: true
Size: 1.3 KB
Versions: 3
Compression:
Stored size: 1.3 KB
Contents
module Sendle module Api module Actions module Base def request(params) RestClient::Request.execute(params) rescue RestClient::PreconditionFailed, RestClient::Unauthorized, RestClient::PaymentRequired, RestClient::UnprocessableEntity => e raise Sendle::Api::Factories::Errors.new_error(e) end protected def rest_client_params include_credentials? ? common_params_with_credentials : common_params end def common_params { headers: json_headers } end def common_params_with_credentials common_params.merge(credential_params) end def check_for_missing_credentials return unless self.include_credentials? raise Sendle::Api::Errors::MissingSendleId if Sendle::Api.sendle_id.nil? raise Sendle::Api::Errors::MissingApiKey if Sendle::Api.api_key.nil? end def json_headers { accept: :json, content_type: :json } end def credential_params { user: Sendle::Api.sendle_id, password: Sendle::Api.api_key } end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sendle-api-0.0.13 | lib/sendle/api/actions/base.rb |
sendle-api-0.0.12 | lib/sendle/api/actions/base.rb |
sendle-api-0.0.11 | lib/sendle/api/actions/base.rb |