Sha256: 91e7fa0d5f79d028ac827ce382e144edd06ece83e6ca5618d648f9a62a7ae0fe

Contents?: true

Size: 810 Bytes

Versions: 1

Compression:

Stored size: 810 Bytes

Contents

# frozen_string_literal: true

require 'oauth2'

module LedgerSync
  module Stripe
    class Client
      include Ledgers::Client::Mixin

      attr_reader :api_key

      def initialize(
        api_key:
      )
        @api_key = api_key

        super()
      end

      def url_for(resource:)
        DashboardURLHelper.new(
          resource: resource,
          base_url: 'https://dashboard.stripe.com'
        ).url
      end

      def wrap_perform
        ::Stripe.api_key = api_key
        yield
      ensure
        ::Stripe.api_key = nil
      end

      def self.ledger_attributes_to_save
        []
      end

      def self.new_from_env(**override)
        new(
          {
            api_key: ENV.fetch('STRIPE_API_KEY', nil)
          }.merge(override)
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ledger_sync-stripe-0.1.0 lib/ledger_sync/stripe/client.rb