Sha256: e330141f4d1ec7c75eedd61ede7b9d412adbfd547e6b15e57be3fa46cc41b52d
Contents?: true
Size: 994 Bytes
Versions: 3
Compression:
Stored size: 994 Bytes
Contents
# frozen_string_literal: true module SolidusBolt class BaseService def initialize(*) @config = SolidusBolt::BoltConfiguration.fetch end def call raise NotImplementedError end def self.call(*args, **kwargs, &block) new(*args, **kwargs, &block).call end private def handle_result(result) return result.parsed_response if result.success? raise ServerError, error_message(result) end def error_message(result) return result['errors'].map { |e| e['message'] }.join(', ') if result['errors'] "#{result['error']}: #{result['error_description']}" end def api_base_url @config.environment_url end def api_version 'v1' end def generate_nonce SecureRandom.hex end def authentication_header { 'X-API-KEY' => @config.api_key } end def publishable_key @config.publishable_key end def api_key @config.api_key end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
solidus_bolt-0.7.2 | app/services/solidus_bolt/base_service.rb |
solidus_bolt-0.7.1 | app/services/solidus_bolt/base_service.rb |
solidus_bolt-0.7.0 | app/services/solidus_bolt/base_service.rb |