source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/dispute_evidence/generate_receipt_image_service.rb
Ruby
mit
8,966
main
2,879
# frozen_string_literal: true class DisputeEvidence::GenerateReceiptImageService def self.perform(purchase) new(purchase).perform end def initialize(purchase) @purchase = purchase end def perform binary_data = generate_screenshot unless binary_data ErrorNotifier.notify("DisputeEviden...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/dispute_evidence/create_from_dispute_service.rb
Ruby
mit
8,966
main
5,780
# frozen_string_literal: true # Create a dispute_evidence record that will be submitted to Stripe # Note that all files associated must not exceed 5MB # https://support.stripe.com/questions/evidence-submission-troubleshooting-faq # class DisputeEvidence::CreateFromDisputeService include ProductsHelper def initial...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/product/skus_updater_service.rb
Ruby
mit
8,966
main
2,109
# frozen_string_literal: true class Product::SkusUpdaterService include CurrencyHelper attr_reader :product, :skus_params delegate :skus, :variant_categories, :price_currency_type, to: :product def initialize(product:, skus_params: []) @product = product @skus_params = skus_params end def perfo...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/product/save_post_purchase_custom_fields_service.rb
Ruby
mit
8,966
main
1,324
# frozen_string_literal: true class Product::SavePostPurchaseCustomFieldsService NODE_TYPE_TO_FIELD_TYPE_MAPPING = CustomField::FIELD_TYPE_TO_NODE_TYPE_MAPPING.invert def initialize(product) @product = product end def perform if @product.alive_variants.exists? && @product.not_has_same_rich_content_fo...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/product/save_integrations_service.rb
Ruby
mit
8,966
main
2,425
# frozen_string_literal: true class Product::SaveIntegrationsService attr_reader :product, :integration_params def self.perform(*args) new(*args).perform end def initialize(product, integration_params = {}) @product = product @integration_params = integration_params end def perform enabl...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/product/compute_call_availabilities_service.rb
Ruby
mit
8,966
main
4,268
# frozen_string_literal: true class Product::ComputeCallAvailabilitiesService def initialize(product) @product = product end def perform return [] unless product.native_type == Link::NATIVE_TYPE_CALL Time.use_zone(product.user.timezone) do untaken_availabilities.map do |interval| inte...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/product/bulk_update_support_email_service.rb
Ruby
mit
8,966
main
1,709
# frozen_string_literal: true class Product::BulkUpdateSupportEmailService # @param entries [Array<Hash>] # @option entries [String] :email # @option entries [Array<String>] :product_ids def initialize(user, entries) @user = user @entries = reject_blank_entries(entries) end def perform return ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/product/save_cancellation_discount_service.rb
Ruby
mit
8,966
main
1,212
# frozen_string_literal: true class Product::SaveCancellationDiscountService attr_reader :product, :cancellation_discount_params def initialize(product, cancellation_discount_params) @product = product @cancellation_discount_params = cancellation_discount_params end def perform if cancellation_di...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/product/variants_updater_service.rb
Ruby
mit
8,966
main
3,510
# frozen_string_literal: true class Product::VariantsUpdaterService attr_reader :product, :skus_params attr_accessor :variants_params delegate :price_currency_type, :skus_enabled, :variant_categories_alive, :skus, to: :product def initialize(product:, variants_params:, skus_p...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/product/variant_category_updater_service.rb
Ruby
mit
8,966
main
10,046
# frozen_string_literal: true class Product::VariantCategoryUpdaterService include CurrencyHelper attr_reader :product, :category_params attr_accessor :variant_category delegate :price_currency_type, :is_tiered_membership, :product_files, :errors, :variant_categori...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/subscription/restart_at_checkout_service.rb
Ruby
mit
8,966
main
3,374
# frozen_string_literal: true class Subscription::RestartAtCheckoutService attr_reader :subscription, :product, :params, :buyer def initialize(subscription:, product:, params:, buyer: nil) @subscription = subscription @product = product @params = normalize_params(params) @buyer = buyer end de...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/subscription/updater_service.rb
Ruby
mit
8,966
main
19,102
# frozen_string_literal: true class Subscription::UpdaterService include CurrencyHelper attr_reader :subscription, :gumroad_guid, :params, :logged_in_user, :remote_ip attr_accessor :original_purchase, :original_price, :new_purchase, :upgrade_purchase, :overdue_for_charge, :is_resubscribing, :is_...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/recommended_products/checkout_service.rb
Ruby
mit
8,966
main
3,983
# frozen_string_literal: true class RecommendedProducts::CheckoutService < RecommendedProducts::BaseService def self.fetch_for_cart(purchaser:, cart_product_ids:, recommender_model_name:, limit:, recommendation_type: nil) new( purchaser:, cart_product_ids:, recommender_model_name:, recomm...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/recommended_products/base_service.rb
Ruby
mit
8,966
main
2,200
# frozen_string_literal: true class RecommendedProducts::BaseService NUMBER_OF_RESULTS = 40 def initialize(purchaser:, cart_product_ids:, recommender_model_name:, recommended_by:, target:, limit:, recommendation_type: nil) @purchaser = purchaser @cart_product_ids = cart_product_ids @recommender_model_...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/recommended_products/discover_service.rb
Ruby
mit
8,966
main
797
# frozen_string_literal: true class RecommendedProducts::DiscoverService < RecommendedProducts::BaseService def self.fetch(purchaser:, cart_product_ids:, recommender_model_name:) new( purchaser:, cart_product_ids:, recommender_model_name:, recommended_by: RecommendationType::GUMROAD_PRODU...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/recommended_products/product_info.rb
Ruby
mit
8,966
main
286
# frozen_string_literal: true class RecommendedProducts::ProductInfo attr_accessor :recommended_by, :recommender_model_name, :target attr_reader :product, :affiliate_id def initialize(product, affiliate_id: nil) @product = product @affiliate_id = affiliate_id end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/exports/audience_export_service.rb
Ruby
mit
8,966
main
1,344
# frozen_string_literal: true class Exports::AudienceExportService FIELDS = ["Subscriber Email", "Subscribed Time"].freeze def initialize(user, options = {}) @user = user @options = options.with_indifferent_access timestamp = Time.current.to_fs(:db).gsub(/ |:/, "-") @filename = "Subscribers-#{@use...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/exports/purchase_export_service.rb
Ruby
mit
8,966
main
11,701
# frozen_string_literal: true class Exports::PurchaseExportService PURCHASE_FIELDS = [ "Purchase ID", "Item Name", "Buyer Name", "Purchase Email", "Buyer Email", "Do not contact?", "Purchase Date", "Purchase Time (UTC timezone)", "Subtotal ($)", "Taxes ($)", "Tax Type", "Shipping ($)", "Sale Price ($)", ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/exports/affiliate_export_service.rb
Ruby
mit
8,966
main
2,404
# frozen_string_literal: true class Exports::AffiliateExportService AFFILIATE_FIELDS = [ "Affiliate ID", "Name", "Email", "Fee", "Products", "Sales ($)", "Referral URL", "Destination URL", "Created At", ].freeze TOTALS_FIELDS = ["Sales ($)"].freeze TOTALS_COLUMN_NAME = "Totals" SYNCHRONOUS_EXPORT_THR...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/exports/tax_summary/payable.rb
Ruby
mit
8,966
main
5,560
# frozen_string_literal: true class Exports::TaxSummary::Payable < Exports::TaxSummary::Base # When we want to use this to build the bigger report, # we pass as_csv: false to just fetch row to be added to bigger CSV # Otherwise the default behaviour to generate this report for single # user, when we want to fi...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/exports/tax_summary/annual.rb
Ruby
mit
8,966
main
1,222
# frozen_string_literal: true class Exports::TaxSummary::Annual def initialize(year:, start: nil, finish: nil) @year = year @start = start @finish = finish end def perform tempfile = Tempfile.new(File.join(Rails.root, "tmp", tempfile_name), encoding: "UTF-8") CsvS...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/exports/tax_summary/base.rb
Ruby
mit
8,966
main
1,529
# frozen_string_literal: true class Exports::TaxSummary::Base attr_reader :date_in_year def initialize(user:, year:) @user = user @date_in_year = Date.new(year) end def perform payouts_summary end private def payouts_summary return { transaction_cents_by_month: {}, t...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/exports/payouts/base.rb
Ruby
mit
8,966
main
15,463
# frozen_string_literal: true class Exports::Payouts::Base PAYPAL_PAYOUTS_HEADING = "PayPal Payouts" STRIPE_CONNECT_PAYOUTS_HEADING = "Stripe Connect Payouts" def initialize(payment) @payment = payment @running_total = 0 end private def payout_data payout = @payment @running_total =...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/exports/payouts/csv.rb
Ruby
mit
8,966
main
1,345
# frozen_string_literal: true class Exports::Payouts::Csv < Exports::Payouts::Base HEADERS = ["Type", "Date", "Purchase ID", "Item Name", "Buyer Name", "Buyer Email", "Taxes ($)", "Shipping ($)", "Sale Price ($)", "Gumroad Fees ($)", "Net Total ($)"] TOTALS_COLUMN_NAME = "Totals" TOTALS_FIELDS = ["Taxes ($)", "S...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/exports/payouts/api.rb
Ruby
mit
8,966
main
356
# frozen_string_literal: true class Exports::Payouts::Api < Exports::Payouts::Base include CurrencyHelper HEADERS = %w[type date purchase_id item_name buyer_name buyer_email taxes shipping sale_price gumroad_fees net_total] def initialize(payment) @payment = payment end def perform payout_data.map...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/exports/payouts/annual.rb
Ruby
mit
8,966
main
1,615
# frozen_string_literal: true class Exports::Payouts::Annual < Exports::Payouts::Csv include CurrencyHelper def initialize(user:, year:) @user = user @year = Date.new(year) end # Note: This returns a csv tempfile object. Please close and unlink the file after usage for better GC. def perform # F...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/purchase/associate_bundle_product_level_gift_service.rb
Ruby
mit
8,966
main
2,066
# frozen_string_literal: true class Purchase::AssociateBundleProductLevelGiftService def initialize(bundle_purchase:, bundle_product:) @bundle_purchase = bundle_purchase @bundle_product = bundle_product end def perform return unless bundle_product_belongs_to_bundle? return if bundle_level_gift.b...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/purchase/mark_failed_service.rb
Ruby
mit
8,966
main
358
# frozen_string_literal: true # Transitions the purchase to corresponding failed state and marks linked items (preorder, gift, giftee purchase) as failed, too. class Purchase::MarkFailedService < Purchase::BaseService def initialize(purchase) @purchase = purchase @preorder = purchase.preorder end def pe...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/purchase/base_service.rb
Ruby
mit
8,966
main
4,562
# frozen_string_literal: true class Purchase::BaseService include AfterCommitEverywhere attr_accessor :purchase, :preorder protected def handle_purchase_success if purchase.free_purchase? && purchase.is_preorder_authorization? mark_preorder_authorized return end giftee_pur...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/purchase/mark_successful_service.rb
Ruby
mit
8,966
main
375
# frozen_string_literal: true # Transitions the purchase to successful state and marks linked items (subscription, gift, giftee purchase, preorder) as successful too. class Purchase::MarkSuccessfulService < Purchase::BaseService def initialize(purchase) @purchase = purchase @preorder = purchase.preorder en...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/purchase/create_bundle_product_purchase_service.rb
Ruby
mit
8,966
main
1,948
# frozen_string_literal: true class Purchase::CreateBundleProductPurchaseService def initialize(purchase, bundle_product) @purchase = purchase @bundle_product = bundle_product end def perform product_purchase = Purchase.create!( link: @bundle_product.product, seller: @purchase.seller, ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/purchase/create_service.rb
Ruby
mit
8,966
main
21,672
# frozen_string_literal: true class Purchase::CreateService < Purchase::BaseService include CurrencyHelper RESERVED_URL_PARAMETERS = %w[code wanted referrer email as_modal as_embed debug affiliate_id].freeze INVENTORY_LOCK_ACQUISITION_TIMEOUT = 50.seconds attr_reader :product, :params, :purchase_params, :gif...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/purchase/update_bundle_purchase_content_service.rb
Ruby
mit
8,966
main
747
# frozen_string_literal: true class Purchase::UpdateBundlePurchaseContentService def initialize(purchase) @purchase = purchase end def perform existing_product_purchases = @purchase.product_purchases.pluck(:created_at, :link_id) content_needed_after = existing_product_purchases.map(&:first).max ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/purchase/confirm_service.rb
Ruby
mit
8,966
main
2,363
# frozen_string_literal: true # Finalizes the purchase once the charge has been confirmed by the user on the front-end. class Purchase::ConfirmService < Purchase::BaseService attr_reader :params def initialize(purchase:, params:) @purchase = purchase @preorder = purchase.preorder @params = params en...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/purchase/variant_updater_service.rb
Ruby
mit
8,966
main
2,597
# frozen_string_literal: true class Purchase::VariantUpdaterService attr_reader :purchase, :variant_id, :new_variant, :product, :new_quantity def initialize(purchase:, variant_id:, quantity:) @purchase = purchase @variant_id = variant_id @new_quantity = quantity end def perform @product = pur...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/purchase/sync_status_with_charge_processor_service.rb
Ruby
mit
8,966
main
2,203
# frozen_string_literal: true # Syncs the purchase status with Stripe/PayPal class Purchase::SyncStatusWithChargeProcessorService attr_accessor :purchase, :mark_as_failed def initialize(purchase, mark_as_failed: false) @purchase = purchase @mark_as_failed = mark_as_failed end def perform return f...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/push_notification_service/android.rb
Ruby
mit
8,966
main
1,550
# frozen_string_literal: true module PushNotificationService class Android attr_reader :device_token, :title, :body, :data def initialize(device_token:, title:, body:, data: {}, app_type:, sound: nil) @device_token = device_token @title = title @body = body @data = data @app_ty...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/push_notification_service/ios.rb
Ruby
mit
8,966
main
1,578
# frozen_string_literal: true module PushNotificationService class Ios attr_reader :device_token, :title, :body, :data def initialize(device_token:, title:, body:, data: {}, app_type:, sound: nil) @device_token = device_token @title = title @body = body @data = data @app_type =...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/bundle/update_products_service.rb
Ruby
mit
8,966
main
1,594
# frozen_string_literal: true class Bundle::UpdateProductsService def initialize(bundle:, products:) @bundle = bundle @products = products end def perform products_to_process = @products.dup bundle_products = @bundle.bundle_products.includes(:product) bundle_products.each do |bundle_product...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/bundle/update_share_service.rb
Ruby
mit
8,966
main
664
# frozen_string_literal: true class Bundle::UpdateShareService def initialize(bundle:, taxonomy_id: nil, tags: nil, section_ids: nil, display_product_reviews: nil, is_adult: nil) @bundle = bundle @taxonomy_id = taxonomy_id @tags = tags @section_ids = section_ids @display_product_reviews = display...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/handle_email_event_info/for_abandoned_cart_email.rb
Ruby
mit
8,966
main
4,127
# frozen_string_literal: true class HandleEmailEventInfo::ForAbandonedCartEmail attr_reader :email_event_info def self.perform(email_event_info) new(email_event_info).perform end def initialize(email_event_info) @email_event_info = email_event_info end def perform email_event_info.workflow_i...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/handle_email_event_info/for_receipt_email.rb
Ruby
mit
8,966
main
1,746
# frozen_string_literal: true class HandleEmailEventInfo::ForReceiptEmail attr_reader :email_event_info def self.perform(email_event_info) new(email_event_info).perform end def initialize(email_event_info) @email_event_info = email_event_info end def perform email_info = find_or_initialize_c...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/handle_email_event_info/for_installment_email.rb
Ruby
mit
8,966
main
7,675
# frozen_string_literal: true class HandleEmailEventInfo::ForInstallmentEmail attr_reader :email_event_info def self.perform(email_event_info) new(email_event_info).perform end def initialize(email_event_info) @email_event_info = email_event_info end def perform case email_event_info.type ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/content_moderation/content_extractor.rb
Ruby
mit
8,966
main
2,791
# frozen_string_literal: true class ContentModeration::ContentExtractor include SignedUrlHelper include Rails.application.routes.url_helpers PERMITTED_IMAGE_TYPES = ["image/png", "image/jpeg", "image/gif", "image/webp"] Result = Struct.new(:text, :image_urls, keyword_init: true) def extract_from_product(p...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/content_moderation/moderate_record_service.rb
Ruby
mit
8,966
main
3,356
# frozen_string_literal: true class ContentModeration::ModerateRecordService AUTHOR_NAME = "ContentModeration" ADMIN_COMMENT_DEDUP_WINDOW = 5.minutes CheckResult = Struct.new(:passed, :reasons, keyword_init: true) def self.check(record, entity_type) new(record, entity_type).check end def initialize(...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/content_moderation/strategies/classifier_strategy.rb
Ruby
mit
8,966
main
4,408
# frozen_string_literal: true class ContentModeration::Strategies::ClassifierStrategy Result = Struct.new(:status, :reasoning, keyword_init: true) OPENAI_REQUEST_TIMEOUT_IN_SECONDS = 10 MAX_MODERATION_ATTEMPTS = 3 MAX_IMAGES_TO_MODERATE = 5 UNAVAILABLE_REASON = "We cannot moderate the content at this time, p...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/content_moderation/strategies/blocklist_strategy.rb
Ruby
mit
8,966
main
1,173
# frozen_string_literal: true class ContentModeration::Strategies::BlocklistStrategy Result = Struct.new(:status, :reasoning, keyword_init: true) YAML_PATH = Rails.root.join("config/content_moderation_blocklist.yml") def initialize(text:, image_urls: []) @text = text.to_s.downcase end def perform ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/content_moderation/strategies/prompt_strategy.rb
Ruby
mit
8,966
main
7,466
# frozen_string_literal: true class ContentModeration::Strategies::PromptStrategy Result = Struct.new(:status, :reasoning, keyword_init: true) OPENAI_REQUEST_TIMEOUT_IN_SECONDS = 10 ADULT_CONTENT_RULES = <<~RULES You are a content moderator. Evaluate the following content for adult/sexual content policy vio...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/collaborator/update_service.rb
Ruby
mit
8,966
main
1,897
# frozen_string_literal: true class Collaborator::UpdateService def initialize(seller:, collaborator_id:, params:) @seller = seller @collaborator = seller.collaborators.find_by_external_id!(collaborator_id) @params = params end def process default_basis_points = params[:percent_commission].prese...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/collaborator/create_service.rb
Ruby
mit
8,966
main
2,642
# frozen_string_literal: true class Collaborator::CreateService def initialize(seller:, params:) @seller = seller @params = params end def process collaborating_user = User.find_by(email: params[:email]) collaborator = seller.collaborators.build( affiliate_user: collaborating_user, ) ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/charge/create_service.rb
Ruby
mit
8,966
main
7,035
# frozen_string_literal: true class Charge::CreateService attr_accessor :order, :seller, :merchant_account, :chargeable, :purchases, :amount_cents, :gumroad_amount_cents, :setup_future_charges, :off_session, :statement_description, :charge, :mandate_options def initialize(order:, seller:, merchant...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/order/charge_service.rb
Ruby
mit
8,966
main
15,370
# frozen_string_literal: true class Order::ChargeService include Events, Order::ResponseHelpers attr_accessor :order, :params, :charge_intent, :setup_intent, :charge_responses def initialize(order:, params:) @order = order @params = params @charge_responses = {} end def perform # We need t...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/order/response_helpers.rb
Ruby
mit
8,966
main
1,276
# frozen_string_literal: true module Order::ResponseHelpers include CurrencyHelper private def error_response(error_message, purchase: nil) card_country = purchase&.card_country card_country = "CN" if card_country == "C2" # PayPal (wrongly) returns CN2 for China users transacting with USD {...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/order/confirm_service.rb
Ruby
mit
8,966
main
1,543
# frozen_string_literal: true # Finalizes the order once the charge SCA has been confirmed by the user on the front-end. class Order::ConfirmService include Order::ResponseHelpers attr_reader :order, :params def initialize(order:, params:) @order = order @params = params end def perform purcha...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/order/create_service.rb
Ruby
mit
8,966
main
8,678
# frozen_string_literal: true class Order::CreateService include Order::ResponseHelpers attr_accessor :params, :buyer, :order PARAM_TO_ATTRIBUTE_MAPPINGS = { friend: :friend_actions, plugins: :purchaser_plugins, vat_id: :business_vat_id, is_preorder: :is_preorder_authorization, cc_zipcode: ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/workflow/save_installments_service.rb
Ruby
mit
8,966
main
4,719
# frozen_string_literal: true class Workflow::SaveInstallmentsService include InstallmentRuleHelper attr_reader :errors, :old_and_new_installment_id_mapping def initialize(seller:, params:, workflow:, preview_email_recipient:) @seller = seller @params = params @workflow = workflow @preview_emai...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/workflow/manage_service.rb
Ruby
mit
8,966
main
3,967
# frozen_string_literal: true class Workflow::ManageService include Rails.application.routes.url_helpers attr_reader :workflow, :error def initialize(seller:, params:, product:, workflow:) @seller = seller @params = params @product = product @workflow = workflow || build_workflow @error = n...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/ai/product_details_generator_service.rb
Ruby
mit
8,966
main
10,688
# frozen_string_literal: true class Ai::ProductDetailsGeneratorService class MaxRetriesExceededError < StandardError; end class InvalidPromptError < StandardError; end PRODUCT_DETAILS_GENERATION_TIMEOUT_IN_SECONDS = 30 RICH_CONTENT_PAGES_GENERATION_TIMEOUT_IN_SECONDS = 90 COVER_IMAGE_GENERATION_TIMEOUT_IN_S...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/admin/unreviewed_users_service.rb
Ruby
mit
8,966
main
1,625
# frozen_string_literal: true class Admin::UnreviewedUsersService MINIMUM_BALANCE_CENTS = 10_000 DEFAULT_CUTOFF_DATE = "2024-01-01" MAX_CACHED_USERS = 1000 def cutoff_date @cutoff_date ||= self.class.cutoff_date end def self.cutoff_date date_str = $redis.get(RedisKey.unreviewed_users_cutoff_date)...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/integrations/circle_integration_service.rb
Ruby
mit
8,966
main
515
# frozen_string_literal: true class Integrations::CircleIntegrationService < Integrations::BaseIntegrationService def initialize @integration_name = Integration::CIRCLE end def activate(purchase) super { |integration| CircleApi.new(integration.api_key).add_member(integration.community_id, integration.sp...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/integrations/base_integration_service.rb
Ruby
mit
8,966
main
1,463
# frozen_string_literal: true class Integrations::BaseIntegrationService include ActiveModel::Validations attr_accessor :integration_name validates :integration_name, presence: true def initialize raise "#{self.class.name} should not be instantiated. Instantiate child classes instead." end def activa...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/integrations/discord_integration_service.rb
Ruby
mit
8,966
main
2,663
# frozen_string_literal: true class Integrations::DiscordIntegrationService < Integrations::BaseIntegrationService def initialize @integration_name = Integration::DISCORD end def deactivate(purchase) super do |integration| discord_user_id = DiscordIntegration.discord_user_id_for(purchase) if...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/helper/client.rb
Ruby
mit
8,966
main
2,203
# frozen_string_literal: true ## # Collection of methods to use Helper API. ## class Helper::Client include HTTParty base_uri "https://api.helper.ai" HELPER_MAILBOX_SLUG = "gumroad" def create_hmac_digest(params: nil, json: nil) if (params.present? && json.present?) || (params.nil? && json.nil?) ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/helper/unblock_email_service.rb
Ruby
mit
8,966
main
4,737
# frozen_string_literal: true class Helper::UnblockEmailService include ActionView::Helpers::TextHelper attr_accessor :recent_blocked_purchase def initialize(conversation_id:, email_id:, email:) @conversation_id = conversation_id @email_id = email_id @email = email @recent_blocked_purchase = ni...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/onetime/backfill_license_uses_for_seller.rb
Ruby
mit
8,966
main
772
# frozen_string_literal: true class Onetime::BackfillLicenseUsesForSeller BATCH_SIZE = 1_000 attr_reader :seller def initialize(seller:) @seller = seller end def process License .joins(:purchase) .where(purchases: { seller_id: seller.id, purchase_state: Purchase::NON_GIFT_SUCCESS_STATE...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/onetime/backfill_inventory_counter_cache.rb
Ruby
mit
8,966
main
2,818
# frozen_string_literal: true module Onetime class BackfillInventoryCounterCache BATCH_SIZE = 500 def self.process(start_base_variant_id: 0, start_link_id: 0) new.process(start_base_variant_id:, start_link_id:) end def process(start_base_variant_id: 0, start_link_id: 0) backfill_base_va...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/creator_analytics/following.rb
Ruby
mit
8,966
main
3,945
# frozen_string_literal: true class CreatorAnalytics::Following include ConfirmedFollowerEvent::Events attr_reader :user def initialize(user) @user = user end def by_date(start_date:, end_date:) dates = (start_date .. end_date).to_a today_in_time_zone = Time.current.in_time_zone(user.timezone)...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/creator_analytics/churn.rb
Ruby
mit
8,966
main
3,987
# frozen_string_literal: true class CreatorAnalytics::Churn InvalidDateRange = Class.new(StandardError) attr_reader :seller def initialize(seller:) @seller = seller end # Coordinator for churn analytics: scopes to subscription products, fetches churn/new/active # series via Elasticsearch, builds dai...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/creator_analytics/product_page_views.rb
Ruby
mit
8,966
main
2,744
# frozen_string_literal: true class CreatorAnalytics::ProductPageViews def initialize(user:, products:, dates:) @user = user @products = products @dates = dates @query = { bool: { filter: [{ terms: { product_id: @products.map(&:id) } }], must: [CreatorAnalytics::DateQuery.day_ra...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/creator_analytics/caching_proxy.rb
Ruby
mit
8,966
main
6,513
# frozen_string_literal: true class CreatorAnalytics::CachingProxy include Formatters::Helpers include Formatters::ByDate include Formatters::ByState include Formatters::ByReferral def initialize(user) @user = user end # Proxy for cached values of CreatorAnalytics::Web#by_(date|state|referral) # ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/creator_analytics/sales.rb
Ruby
mit
8,966
main
3,982
# frozen_string_literal: true class CreatorAnalytics::Sales SEARCH_OPTIONS = Purchase::CHARGED_SALES_SEARCH_OPTIONS.merge( exclude_refunded: false, exclude_unreversed_chargedback: false, ) def initialize(user:, products:, dates:) @user = user @products = products @dates = dates @query = ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/creator_analytics/date_query.rb
Ruby
mit
8,966
main
619
# frozen_string_literal: true class CreatorAnalytics::DateQuery class << self def day_range(field:, start_date:, end_date:, timezone:) { range: { field => { gte: day_start(start_date, timezone:).iso8601, lt: day_start(end_date + 1.day, timezone:).iso8601, ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/creator_analytics/web.rb
Ruby
mit
8,966
main
5,343
# frozen_string_literal: true class CreatorAnalytics::Web def initialize(user:, dates:) @user = user @dates = dates end def by_date views_data = product_page_views.by_product_and_date sales_data = sales.by_product_and_date result = result_metadata result[:by_date] = { views: {}, sales: {...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/creator_analytics/churn/product_scope.rb
Ruby
mit
8,966
main
987
# frozen_string_literal: true class CreatorAnalytics::Churn::ProductScope attr_reader :seller def initialize(seller:) @seller = seller end def subscription_products @subscription_products ||= seller .products_for_creator_analytics .select { |product| product.is_recurring_billing? || produ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/creator_analytics/churn/elasticsearch_fetcher.rb
Ruby
mit
8,966
main
5,308
# frozen_string_literal: true # Runs the ES-facing layer for churn: builds scoped queries and pagination to fetch # cancellations (with recurring revenue), new subscriptions, and active baselines. # Assumes subscription activity lives in the purchases index; relies on # Purchase::CHARGED_SALES_SEARCH_OPTIONS and the o...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/creator_analytics/churn/dataset_builder.rb
Ruby
mit
8,966
main
8,350
# frozen_string_literal: true # Assembles churn metrics from raw ES buckets: daily buckets, derived monthly rollups, # and period summaries keyed by product. Subscriber bases are the period base # (active-at-start + new) per bucket so the UI can re-aggregate by product without # recomputing denominators. Relies on cal...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/creator_analytics/churn/date_window.rb
Ruby
mit
8,966
main
1,763
# frozen_string_literal: true # Normalizes and clamps requested churn date ranges for a seller, exposing daily # and monthly buckets. # class CreatorAnalytics::Churn::DateWindow DEFAULT_RANGE_DAYS = 30 attr_reader :seller, :product_scope def initialize(seller:, product_scope:, start_date:, end_date:) @sell...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/creator_analytics/caching_proxy/formatters/by_state.rb
Ruby
mit
8,966
main
1,169
# frozen_string_literal: true module CreatorAnalytics::CachingProxy::Formatters::ByState # See #merge_data_by_date def merge_data_by_state(days_data, _dates = nil) data = { by_state: { views: {}, sales: {}, totals: {} } } permalinks = days_data.flat_map do |day_data| day_data[:by_state].values.map(&...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/creator_analytics/caching_proxy/formatters/by_date.rb
Ruby
mit
8,966
main
2,734
# frozen_string_literal: true module CreatorAnalytics::CachingProxy::Formatters::ByDate # Merges several `#by_date` results into singular data. # Does not generate any queries of any kind. # Example: # day_1 = Web.new(dates: (monday .. monday).to_a).by_date # day_2 = Web.new(dates: (tuesday .. tuesday).t...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/creator_analytics/caching_proxy/formatters/by_referral.rb
Ruby
mit
8,966
main
3,236
# frozen_string_literal: true module CreatorAnalytics::CachingProxy::Formatters::ByReferral # See #merge_data_by_date def merge_data_by_referral(days_data, dates) data = { by_referral: { views: {}, sales: {}, totals: {} } } # We compile all products first, # because some products may not have existed ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/creator_analytics/caching_proxy/formatters/helpers.rb
Ruby
mit
8,966
main
1,113
# frozen_string_literal: true module CreatorAnalytics::CachingProxy::Formatters::Helpers private # When getting data from a mix of cached and uncached sources, # `month_index` may not be sequential. This ensures it is the case. def rebuild_month_index_values!(dates_and_months) last_month = nil ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/pdf_stamping_service/stamp_for_purchase.rb
Ruby
mit
8,966
main
2,106
# frozen_string_literal: true module PdfStampingService::StampForPurchase extend self def perform!(purchase) product = purchase.link return unless product.has_stampable_pdfs? url_redirect = UrlRedirect.find(purchase.url_redirect.id) product_files_to_stamp = find_products_to_stamp(product, url_red...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/pdf_stamping_service/upload_to_s3.rb
Ruby
mit
8,966
main
467
# frozen_string_literal: true # Upload the stamped PDF to S3 module PdfStampingService::UploadToS3 extend self def perform!(product_file:, stamped_pdf_path:) guid = SecureRandom.hex path = "attachments/#{guid}/original/#{File.basename(product_file.s3_url)}" Aws::S3::Resource.new.bucket(S3_BUCKET).obje...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/pdf_stamping_service/stamp.rb
Ruby
mit
8,966
main
6,738
# frozen_string_literal: true module PdfStampingService::Stamp class Error < StandardError; end extend self def can_stamp_file?(product_file:) stamped_pdf_path = perform!(product_file:, watermark_text: "noop@gumroad.com") true # We don't actually do anything with the file, we just wanted to check that ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/services/product_review/update_service.rb
Ruby
mit
8,966
main
1,396
# frozen_string_literal: true class ProductReview::UpdateService def initialize(product_review, rating:, message:, video_options: {}) @product_review = product_review @rating = rating @message = message @video_options = video_options.to_h.with_indifferent_access end def update @product_revie...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/bundle_product_purchase.rb
Ruby
mit
8,966
main
761
# frozen_string_literal: true class BundleProductPurchase < ApplicationRecord belongs_to :bundle_purchase, class_name: "Purchase", foreign_key: :bundle_purchase_id belongs_to :product_purchase, class_name: "Purchase", foreign_key: :product_purchase_id validate :purchases_must_have_same_seller validate :produc...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/price.rb
Ruby
mit
8,966
main
921
# frozen_string_literal: true class Price < BasePrice belongs_to :link, optional: true validates :link, presence: true validate :recurrence_validation after_commit :invalidate_product_cache def as_json(*) json = { id: external_id, price_cents:, recurrence: } if recurrence.pre...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/product_tagging.rb
Ruby
mit
8,966
main
922
# frozen_string_literal: true class ProductTagging < ApplicationRecord belongs_to :tag, optional: true belongs_to :product, class_name: "Link", optional: true validates_uniqueness_of :product_id, scope: :tag_id scope :owned_by_user, lambda { |user| joins(:product).where(links: { user_id: user.id }) } ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/dropbox_file.rb
Ruby
mit
8,966
main
4,891
# frozen_string_literal: true class DropboxFile < ApplicationRecord include ExternalId # A Dropbox file always belongs to a user. This is done because without it we could not fetch the dropbox files # for the user when they visit an upload page. belongs_to :user, optional: true # A Dropbox file can belong t...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/blocked_customer_object.rb
Ruby
mit
8,966
main
1,724
# frozen_string_literal: true class BlockedCustomerObject < ApplicationRecord SUPPORTED_OBJECT_TYPES = { email: "email", charge_processor_fingerprint: "charge_processor_fingerprint" }.freeze has_paper_trail belongs_to :seller, class_name: "User" validates_presence_of :object_type, :object_value ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/preorder_link.rb
Ruby
mit
8,966
main
2,561
# frozen_string_literal: true class PreorderLink < ApplicationRecord REMINDER_EMAIL_TO_RELEASE_TIME = 1.day # Send the seller reminder email 1 day before the release time. belongs_to :link, optional: true has_many :preorders validates :link, presence: true validates :release_at, presence: true validate :...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/san_marino_bank_account.rb
Ruby
mit
8,966
main
1,038
# frozen_string_literal: true class SanMarinoBankAccount < BankAccount BANK_ACCOUNT_TYPE = "SM" BANK_CODE_FORMAT_REGEX = /^[0-9a-zA-Z]{8,11}$/ private_constant :BANK_CODE_FORMAT_REGEX alias_attribute :bank_code, :bank_number validate :validate_bank_code validate :validate_account_number def routing_n...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/angola_bank_account.rb
Ruby
mit
8,966
main
1,071
# frozen_string_literal: true class AngolaBankAccount < BankAccount BANK_ACCOUNT_TYPE = "AO" BANK_CODE_FORMAT_REGEX = /^([0-9a-zA-Z]){8,11}$/ private_constant :BANK_CODE_FORMAT_REGEX alias_attribute :bank_code, :bank_number validate :validate_bank_code validate :validate_account_number, if: -> { Rails.e...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/charge.rb
Ruby
mit
8,966
main
7,950
# frozen_string_literal: true class Charge < ApplicationRecord include ExternalId, Chargeable, Purchase::ChargeEventsHandler, Disputable, FlagShihTzu, Refundable COMBINED_CHARGE_PREFIX = "CH-" belongs_to :order belongs_to :seller, class_name: "User" belongs_to :merchant_account, optional: true belongs_to...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/mailer_info.rb
Ruby
mit
8,966
main
2,349
# frozen_string_literal: true module MailerInfo extend self include Kernel EMAIL_PROVIDER_SENDGRID = "sendgrid" EMAIL_PROVIDER_RESEND = "resend" SENDGRID_X_SMTPAPI_HEADER = "X-SMTPAPI" FIELD_NAMES = %i[ email_provider environment category mailer_class mailer_method mailer_args purchase_id charge_id ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/uae_bank_account.rb
Ruby
mit
8,966
main
684
# frozen_string_literal: true class UaeBankAccount < BankAccount BANK_ACCOUNT_TYPE = "AE" validate :validate_account_number, if: -> { Rails.env.production? } def bank_account_type BANK_ACCOUNT_TYPE end def country Compliance::Countries::ARE.alpha2 end def currency Currency::AED end d...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/thumbnail.rb
Ruby
mit
8,966
main
2,297
# frozen_string_literal: true class Thumbnail < ApplicationRecord include Deletable include CdnUrlHelper DISPLAY_THUMBNAIL_DIMENSION = 600 MAX_FILE_SIZE = 5.megabytes ALLOW_CONTENT_TYPES = /jpeg|gif|png|jpg/i belongs_to :product, class_name: "Link", optional: true has_one_attached :file before_crea...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/user_external_authentication.rb
Ruby
mit
8,966
main
230
# frozen_string_literal: true class UserExternalAuthentication < ApplicationRecord belongs_to :user validates :provider, presence: true validates :uid, presence: true validates :uid, uniqueness: { scope: :provider } end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/third_party_analytic.rb
Ruby
mit
8,966
main
2,508
# frozen_string_literal: true class ThirdPartyAnalytic < ApplicationRecord include ExternalId include Deletable belongs_to :user, optional: true belongs_to :link, optional: true validates :user, presence: true after_commit :clear_related_products_cache scope :universal, -> { where("link_id is null") ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/product_review_video.rb
Ruby
mit
8,966
main
925
# frozen_string_literal: true class ProductReviewVideo < ApplicationRecord include ExternalId include Deletable belongs_to :product_review has_one :video_file, as: :record, dependent: :destroy validates :video_file, presence: true accepts_nested_attributes_for :video_file APPROVAL_STATUES = %w[pending...