Skip to content

Commit

Permalink
Skip unsupported types - fixes #82
Browse files Browse the repository at this point in the history
  • Loading branch information
forsbergplustwo committed Oct 19, 2023
1 parent 87f4c42 commit e0c3602
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/models/import/adaptor/shopify_payments_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ class Import::Adaptor::ShopifyPaymentsApi
]
}.freeze

UNSUPPORTED_TRANSACTION_TYPES = [
"TaxTransaction",
"LegacyTransaction"
].freeze

def initialize(import:, import_payments_after_date:)
@import = import
@import_payments_after_date = import_payments_after_date.strftime("%Y-%m-%dT%H:%M:%S.%L%z")
Expand Down Expand Up @@ -70,6 +75,8 @@ def stream_payments(main_enum)
@cursor = results.data.transactions.edges.last.cursor

transactions.each do |transaction|
next if unsupported?(transaction.node)

main_enum.yield parse(transaction.node)
end
end
Expand Down Expand Up @@ -98,6 +105,10 @@ def parse(node)
}
end

def unsupported?(node)
UNSUPPORTED_TRANSACTION_TYPES.find { |type| node&.id&.include?(type) }.present?
end

def charge_type(node)
API_REVENUE_TYPES.find { |_key, value| value.include?(node.__typename) }&.first
end
Expand Down

0 comments on commit e0c3602

Please sign in to comment.