Sha256: 2132f0707e5cb601e2ad6e6dc23bdbb38eb1d5287d43ef47f9cf7ca8b34a5248

Contents?: true

Size: 1.23 KB

Versions: 8

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

module LedgerSync
  module Ledgers
    module Stripe
      class Customer
        module Operations
          class Find < Stripe::Operation::Find
            class Contract < LedgerSync::Ledgers::Contract
              params do
                required(:external_id).maybe(:string)
                required(:ledger_id).filled(:string)
                optional(:email).maybe(:string)
                optional(:name).maybe(:string)
                optional(:phone_number).maybe(:string)
                optional(:subsidiary).maybe(:hash, Types::Reference)
              end
            end

            private

            def operate
              stripe_customer = ::Stripe::Customer.retrieve(
                resource.ledger_id
              )

              resource.external_id = stripe_customer.metadata['external_id']
              resource.email = stripe_customer.email
              resource.name = stripe_customer.name
              resource.phone_number = stripe_customer.phone

              resource.ledger_id = stripe_customer.id

              success(
                resource: resource,
                response: stripe_customer
              )
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ledger_sync-1.6.0 lib/ledger_sync/ledgers/stripe/customer/operations/find.rb
ledger_sync-1.5.2 lib/ledger_sync/ledgers/stripe/customer/operations/find.rb
ledger_sync-1.5.1 lib/ledger_sync/ledgers/stripe/customer/operations/find.rb
ledger_sync-1.5.0 lib/ledger_sync/ledgers/stripe/customer/operations/find.rb
ledger_sync-1.4.4 lib/ledger_sync/ledgers/stripe/customer/operations/find.rb
ledger_sync-1.4.2 lib/ledger_sync/ledgers/stripe/customer/operations/find.rb
ledger_sync-1.4.1 lib/ledger_sync/ledgers/stripe/customer/operations/find.rb
ledger_sync-1.4.0 lib/ledger_sync/ledgers/stripe/customer/operations/find.rb