repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/post_email_api.rb | app/services/post_email_api.rb | # frozen_string_literal: true
class PostEmailApi
RESEND_EXCLUDED_DOMAINS = ["example.com", "example.org", "example.net", "test.com"]
private_constant :RESEND_EXCLUDED_DOMAINS
def self.process(**args)
post = args[:post]
recipients = args[:recipients]
if Feature.inactive?(:use_resend_for_post_emails,... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/rpush_apns_app_service.rb | app/services/rpush_apns_app_service.rb | # frozen_string_literal: true
class RpushApnsAppService
attr_reader :name
def initialize(name:)
@name = name
end
def first_or_create!
first || create!
end
private
def first
Rpush::Apns2::App.all.select { |app| app.name == name }.first
end
def create!
certificate = File.r... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/rpush_fcm_app_service.rb | app/services/rpush_fcm_app_service.rb | # frozen_string_literal: true
class RpushFcmAppService
attr_reader :name
def initialize(name:)
@name = name
end
def first_or_create!
first || create!
end
private
def first
Rpush::Fcm::App.all.select { |app| app.name == name }.first
end
def create!
app = Rpush::Fcm::App.n... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/purchasing_power_parity_service.rb | app/services/purchasing_power_parity_service.rb | # frozen_string_literal: true
class PurchasingPowerParityService
def get_factor(country_code, seller)
factor = if country_code.present?
(ppp_namespace.get(country_code).presence || 1).to_f
else
1.0
end
[factor, seller.min_ppp_factor].max
end
def set_factor(country_code, factor)
p... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/instant_payouts_service.rb | app/services/instant_payouts_service.rb | # frozen_string_literal: true
class InstantPayoutsService
attr_reader :seller, :date
def initialize(seller, date: Date.today)
@seller = seller
@date = date
end
def perform
return { success: false, error: "Your account is not eligible for instant payouts at this time." } unless seller.instant_payo... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/clean_us_zip_code_database_file.rb | app/services/clean_us_zip_code_database_file.rb | # frozen_string_literal: true
# This script manipulates the United States zip codes file to only include information we need (zip codes and states).
# It's only meant to be executed locally.
#
# Steps:
#
# 1. Ask Sahil to purchase an Enterprise license from https://www.unitedstateszipcodes.org/zip-code-database/ with ... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/offer_code_discount_computing_service.rb | app/services/offer_code_discount_computing_service.rb | # frozen_string_literal: true
class OfferCodeDiscountComputingService
# While computing it rejects the product if quantity of the product is greater
# than the quantity left for the offer_code for e.g. Suppose seller adds a
# universal offer code which has 4 quantity left and a user adds three products
# in bu... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/black_friday_stats_service.rb | app/services/black_friday_stats_service.rb | # frozen_string_literal: true
class BlackFridayStatsService
CACHE_KEY = "black_friday_stats"
CACHE_EXPIRATION = 10.minutes
class << self
def fetch_stats
Rails.cache.fetch(CACHE_KEY, expires_in: CACHE_EXPIRATION) do
calculate_stats
end
end
def calculate_stats
# TODO: Implem... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/user_balance_stats_service.rb | app/services/user_balance_stats_service.rb | # frozen_string_literal: true
class UserBalanceStatsService
include ActionView::Helpers::TranslationHelper
include PayoutsHelper
attr_reader :user
DEFAULT_SALES_CACHING_THRESHOLD = 50_000
def initialize(user:)
@user = user
end
def fetch
if should_use_cache?
UpdateUserBalanceStatsCacheWork... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/redis_key.rb | app/services/redis_key.rb | # frozen_string_literal: true
class RedisKey
class << self
def total_made = "homepage:total_made"
def number_of_creators = "company_page:number_of_creators"
def prev_week_payout_usd = "homepage:prev_week_payout_usd"
def balance_stats_sales_caching_threshold = "balance_stats:sales_caching_threshold"
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/product_indexing_service.rb | app/services/product_indexing_service.rb | # frozen_string_literal: true
class ProductIndexingService
def self.perform(product:, action:, attributes_to_update: [], on_failure: :raise)
case action
when "index"
product.__elasticsearch__.index_document
when "update"
return if attributes_to_update.empty?
attributes = product.build_... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/email_redactor_service.rb | app/services/email_redactor_service.rb | # frozen_string_literal: true
class EmailRedactorService
def self.redact(email)
username, domain = email.split("@")
domain_name, _, tld = domain.rpartition(".")
redacted_username = username.length > 1 ? "#{username[0]}#{'*' * (username.length - 2)}#{username[-1]}" : username
redacted_domain = "#{dom... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/circle_api.rb | app/services/circle_api.rb | # frozen_string_literal: true
class CircleApi
include HTTParty
base_uri "https://app.circle.so/api/v1"
def initialize(api_key)
@api_key = api_key
end
def get_communities
rate_limited_call { self.class.get("/communities", headers:) }
end
def get_spaces(community_id)
rate_limited_call { sel... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/handle_email_event_info.rb | app/services/handle_email_event_info.rb | # frozen_string_literal: true
# Email provider-agnostic service to handle email event info.
# The logic should not handle any email provider (Sendgrid, Resend) specific logic.
# For that, user EmailEventInfo subclasses (SendgridEventInfo, ResendEventInfo).
#
class HandleEmailEventInfo
def self.perform(email_event_in... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/cleanup_rpush_device_service.rb | app/services/cleanup_rpush_device_service.rb | # frozen_string_literal: true
class CleanupRpushDeviceService
def initialize(feedback)
@feedback = feedback
end
def process
Device.where(token: @feedback.device_token).destroy_all
@feedback.destroy
rescue => e
Rails.logger.error "Could not clean up a device token based on APN feedback #{@feedb... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/home_page_link_service.rb | app/services/home_page_link_service.rb | # frozen_string_literal: true
class HomePageLinkService
PAGES = [:privacy, :terms, :about, :features, :university, :pricing, :affiliates, :prohibited]
private_constant :PAGES
ROOT_DOMAIN_WITH_PROTCOL = UrlService.root_domain_with_protocol
private_constant :ROOT_DOMAIN_WITH_PROTCOL
class << self
PAGES.e... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/update_user_country.rb | app/services/update_user_country.rb | # frozen_string_literal: true
class UpdateUserCountry
attr_reader :new_country_code, :user
def initialize(new_country_code:, user:)
@old_country_code = user.alive_user_compliance_info.legal_entity_country_code
@new_country_code = new_country_code
@user = user
end
def process
keep_payment_addr... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/robots_service.rb | app/services/robots_service.rb | # frozen_string_literal: true
class RobotsService
SITEMAPS_CACHE_EXPIRY = 1.week.to_i
private_constant :SITEMAPS_CACHE_EXPIRY
SITEMAPS_CACHE_KEY = "sitemap_configs"
private_constant :SITEMAPS_CACHE_KEY
def sitemap_configs
cache_fetch(SITEMAPS_CACHE_KEY, ex: SITEMAPS_CACHE_EXPIRY) do
generate_site... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/discord_api.rb | app/services/discord_api.rb | # frozen_string_literal: true
class DiscordApi
def oauth_token(code, redirect_uri)
body = {
grant_type: "authorization_code",
code:,
client_id: DISCORD_CLIENT_ID,
client_secret: DISCORD_CLIENT_SECRET,
redirect_uri:
}
headers = { "Content-Type" => "application/x-www-form-url... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/merge_carts_service.rb | app/services/merge_carts_service.rb | # frozen_string_literal: true
class MergeCartsService
attr_reader :source_cart, :target_cart, :user, :browser_guid, :email
def initialize(source_cart:, target_cart:, user: nil, browser_guid: nil)
@source_cart = source_cart
@target_cart = target_cart
@user = user || @target_cart&.user.presence || @sour... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/helper_user_info_service.rb | app/services/helper_user_info_service.rb | # frozen_string_literal: true
class HelperUserInfoService
include Rails.application.routes.url_helpers
def initialize(email:, recent_purchase_period: 1.year)
@email = email
@recent_purchase_period = recent_purchase_period
end
def customer_info
{
**user_details,
metadata: {
**u... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/gumroad_daily_analytics_compiler.rb | app/services/gumroad_daily_analytics_compiler.rb | # frozen_string_literal: true
class GumroadDailyAnalyticsCompiler
class << self
def compile_gumroad_price_cents(between: nil)
paid_purchases_between(between:)
.sum(:price_cents)
end
def compile_gumroad_fee_cents(between: nil)
purchase_cents = paid_purchases_between(between:)
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/admin_search_service.rb | app/services/admin_search_service.rb | # frozen_string_literal: true
class AdminSearchService
class InvalidDateError < StandardError; end
def search_purchases(query: nil, email: nil, product_title_query: nil, purchase_status: nil, creator_email: nil, license_key: nil, transaction_date: nil, last_4: nil, card_type: nil, price: nil, expiry_date: nil, li... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/vat_validation_service.rb | app/services/vat_validation_service.rb | # frozen_string_literal: true
require "valvat"
class VatValidationService
attr_reader :vat_id, :valvat
def initialize(vat_id)
@vat_id = vat_id
@valvat = Valvat.new(vat_id)
end
def process
return false if vat_id.nil?
# If UK, just validate VAT id, no lookup exists for it.
if valvat.vat_c... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/save_content_upsells_service.rb | app/services/save_content_upsells_service.rb | # frozen_string_literal: true
class SaveContentUpsellsService
def initialize(seller:, content:, old_content:)
@seller = seller
@content = content
@old_content = old_content
end
def from_html
old_doc = Nokogiri::HTML.fragment(old_content)
new_doc = Nokogiri::HTML.fragment(content)
old_up... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/firs_tin_validation_service.rb | app/services/firs_tin_validation_service.rb | # frozen_string_literal: true
class FirsTinValidationService
attr_reader :tin
def initialize(tin)
@tin = tin
end
def process
return false if tin.blank?
tin.match?(/^\d{8}-\d{4}$/)
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/installment_search_service.rb | app/services/installment_search_service.rb | # frozen_string_literal: true
class InstallmentSearchService
DEFAULT_OPTIONS = {
### Filters
# Values can be an ActiveRecord object, an id, or an Array of both
seller: nil,
### Fulltext search
q: nil, # String
### Booleans
exclude_deleted: false,
exclude_workflow_installments: false,
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/safe_redirect_path_service.rb | app/services/safe_redirect_path_service.rb | # frozen_string_literal: true
class SafeRedirectPathService
def initialize(path, request, allow_subdomain_host: true)
@path = path
@allow_subdomain_host = allow_subdomain_host
@request = request
end
def process
if (allow_subdomain_host && subdomain_host?) || same_host?
path
else
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/google_calendar_api.rb | app/services/google_calendar_api.rb | # frozen_string_literal: true
class GoogleCalendarApi
include HTTParty
GOOGLE_CALENDAR_OAUTH_URL = "https://oauth2.googleapis.com"
base_uri "https://www.googleapis.com/"
def oauth_token(code, redirect_uri)
body = {
grant_type: "authorization_code",
code:,
redirect_uri:,
client_id:... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/default_abandoned_cart_workflow_generator_service.rb | app/services/default_abandoned_cart_workflow_generator_service.rb | # frozen_string_literal: true
class DefaultAbandonedCartWorkflowGeneratorService
include Rails.application.routes.url_helpers
def initialize(seller:)
@seller = seller
end
def generate
return if seller.workflows.abandoned_cart_type.exists?
ActiveRecord::Base.transaction do
workflow = seller... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/seller_mobile_analytics_service.rb | app/services/seller_mobile_analytics_service.rb | # frozen_string_literal: true
class SellerMobileAnalyticsService
SALES_LIMIT = 300
def initialize(user, range: "day", query: nil, fields: [])
@user = user
@range = range
@query = query
@fields = fields
@result = {}
end
def process
@search_result = PurchaseSearchService.search(search_p... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/balances_by_product_service.rb | app/services/balances_by_product_service.rb | # frozen_string_literal: true
class BalancesByProductService
def initialize(user)
@user = user
@products = Link.for_balance_page(@user).select(:id, :name, :user_id).order(id: :desc).load
end
def process
return [] if @products.empty?
aggregations = PurchaseSearchService.search(search_options).ag... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/ai/product_details_generator_service.rb | app/services/ai/product_details_generator_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/push_notification_service/ios.rb | app/services/push_notification_service/ios.rb | # 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 =... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/push_notification_service/android.rb | app/services/push_notification_service/android.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/handle_email_event_info/for_receipt_email.rb | app/services/handle_email_event_info/for_receipt_email.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/handle_email_event_info/for_installment_email.rb | app/services/handle_email_event_info/for_installment_email.rb | # 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
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/handle_email_event_info/for_abandoned_cart_email.rb | app/services/handle_email_event_info/for_abandoned_cart_email.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/integrations/base_integration_service.rb | app/services/integrations/base_integration_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/integrations/circle_integration_service.rb | app/services/integrations/circle_integration_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/integrations/discord_integration_service.rb | app/services/integrations/discord_integration_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/exports/audience_export_service.rb | app/services/exports/audience_export_service.rb | # frozen_string_literal: true
require "csv"
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 = "Sub... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/exports/purchase_export_service.rb | app/services/exports/purchase_export_service.rb | # 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 ($)", ... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/exports/affiliate_export_service.rb | app/services/exports/affiliate_export_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/exports/payouts/csv.rb | app/services/exports/payouts/csv.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/exports/payouts/annual.rb | app/services/exports/payouts/annual.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/exports/payouts/base.rb | app/services/exports/payouts/base.rb | # frozen_string_literal: true
class Exports::Payouts::Base
PAYPAL_PAYOUTS_HEADING = "PayPal Payouts"
STRIPE_CONNECT_PAYOUTS_HEADING = "Stripe Connect Payouts"
def initialize(payment_id)
@payment_id = payment_id
@running_total = 0
end
private
def payout_data
payout = Payment.find(@payment_... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/exports/tax_summary/annual.rb | app/services/exports/tax_summary/annual.rb | # 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")
CSV.... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/exports/tax_summary/base.rb | app/services/exports/tax_summary/base.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/exports/tax_summary/payable.rb | app/services/exports/tax_summary/payable.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/product/variants_updater_service.rb | app/services/product/variants_updater_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/product/save_cancellation_discount_service.rb | app/services/product/save_cancellation_discount_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/product/compute_call_availabilities_service.rb | app/services/product/compute_call_availabilities_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/product/variant_category_updater_service.rb | app/services/product/variant_category_updater_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/product/save_post_purchase_custom_fields_service.rb | app/services/product/save_post_purchase_custom_fields_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/product/save_integrations_service.rb | app/services/product/save_integrations_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/product/bulk_update_support_email_service.rb | app/services/product/bulk_update_support_email_service.rb | # 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 ... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/product/skus_updater_service.rb | app/services/product/skus_updater_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/ssl_certificates/lets_encrypt.rb | app/services/ssl_certificates/lets_encrypt.rb | # frozen_string_literal: true
module SslCertificates
class LetsEncrypt < Base
CHALLENGE_TTL = 1.hour.to_i
attr_reader :domain, :certificate_private_key
def initialize(domain)
super()
@domain = domain
@certificate_private_key = OpenSSL::PKey::RSA.new(2048)
end
def process
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/ssl_certificates/renew.rb | app/services/ssl_certificates/renew.rb | # frozen_string_literal: true
module SslCertificates
class Renew < Base
def process
custom_domains = CustomDomain.alive.certificate_absent_or_older_than(renew_in)
custom_domains.each do |custom_domain|
custom_domain.generate_ssl_certificate
end
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/ssl_certificates/generate.rb | app/services/ssl_certificates/generate.rb | # frozen_string_literal: true
module SslCertificates
class Generate < Base
attr_reader :custom_domain
include ActionView::Helpers::DateHelper
def initialize(custom_domain)
super()
@custom_domain = custom_domain
@domain_verification_service = CustomDomainVerificationService.new(domain... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/ssl_certificates/base.rb | app/services/ssl_certificates/base.rb | # frozen_string_literal: true
module SslCertificates
class Base
CONFIG_FILE = Rails.root.join("config", "ssl_certificates.yml.erb")
SECRETS_S3_BUCKET = "gumroad-secrets"
attr_reader :renew_in, :rate_limit, :acme_url, :sleep_duration, :rate_limit_hours,
:account_email, :max_retries, :ssl_... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/follower/create_service.rb | app/services/follower/create_service.rb | # frozen_string_literal: true
class Follower::CreateService
delegate :followers, to: :followed_user
def self.perform(**args)
new(**args).perform
end
def initialize(followed_user:, follower_email:, follower_attributes: {}, logged_in_user: nil)
@followed_user = followed_user
@follower_email = follo... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/dispute_evidence/generate_uncategorized_text_service.rb | app/services/dispute_evidence/generate_uncategorized_text_service.rb | # frozen_string_literal: true
class DisputeEvidence::GenerateUncategorizedTextService
def self.perform(purchase)
new(purchase).perform
end
include ActionView::Helpers::NumberHelper
attr_reader :purchase
def initialize(purchase)
@purchase = purchase
end
def perform
rows = [
customer_... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/dispute_evidence/generate_receipt_image_service.rb | app/services/dispute_evidence/generate_receipt_image_service.rb | # 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
Bugsnag.notify("DisputeEvidence::Ge... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/dispute_evidence/create_from_dispute_service.rb | app/services/dispute_evidence/create_from_dispute_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/dispute_evidence/generate_refund_policy_image_service.rb | app/services/dispute_evidence/generate_refund_policy_image_service.rb | # frozen_string_literal: true
class DisputeEvidence::GenerateRefundPolicyImageService
class ImageTooLargeError < StandardError; end
def self.perform(url:, mobile_purchase:, open_fine_print_modal:, max_size_allowed:)
new(url, mobile_purchase:, open_fine_print_modal:, max_size_allowed:).perform
end
def ini... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/dispute_evidence/generate_access_activity_logs_service.rb | app/services/dispute_evidence/generate_access_activity_logs_service.rb | # frozen_string_literal: true
class DisputeEvidence::GenerateAccessActivityLogsService
def self.perform(purchase)
new(purchase).perform
end
include ActionView::Helpers::NumberHelper
def initialize(purchase)
@purchase = purchase
@url_redirect = purchase.url_redirect
end
def perform
[
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/pdf_stamping_service/upload_to_s3.rb | app/services/pdf_stamping_service/upload_to_s3.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/pdf_stamping_service/stamp_for_purchase.rb | app/services/pdf_stamping_service/stamp_for_purchase.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/pdf_stamping_service/stamp.rb | app/services/pdf_stamping_service/stamp.rb | # 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 ... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/admin/unreviewed_users_service.rb | app/services/admin/unreviewed_users_service.rb | # frozen_string_literal: true
class Admin::UnreviewedUsersService
MINIMUM_BALANCE_CENTS = 1000
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) |... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/creator_analytics/following.rb | app/services/creator_analytics/following.rb | # 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)... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/creator_analytics/product_page_views.rb | app/services/creator_analytics/product_page_views.rb | # 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: [{ range: { timestamp: { time_zone:... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/creator_analytics/web.rb | app/services/creator_analytics/web.rb | # 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: {... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/creator_analytics/sales.rb | app/services/creator_analytics/sales.rb | # 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 = ... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/creator_analytics/caching_proxy.rb | app/services/creator_analytics/caching_proxy.rb | # 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)
# ... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/creator_analytics/caching_proxy/formatters/by_referral.rb | app/services/creator_analytics/caching_proxy/formatters/by_referral.rb | # 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 ... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/creator_analytics/caching_proxy/formatters/helpers.rb | app/services/creator_analytics/caching_proxy/formatters/helpers.rb | # 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
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/creator_analytics/caching_proxy/formatters/by_date.rb | app/services/creator_analytics/caching_proxy/formatters/by_date.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/creator_analytics/caching_proxy/formatters/by_state.rb | app/services/creator_analytics/caching_proxy/formatters/by_state.rb | # 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(&... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/subscription/updater_service.rb | app/services/subscription/updater_service.rb | # 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_... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/charge/create_service.rb | app/services/charge/create_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/early_fraud_warning/update_service.rb | app/services/early_fraud_warning/update_service.rb | # frozen_string_literal: true
class EarlyFraudWarning::UpdateService
class AlreadyResolvedError < StandardError; end
def initialize(record)
@record = record
@chargeable = record.chargeable
end
def perform!
# We want to preserve the record in its original state just before it was processed by us.
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/recommended_products/checkout_service.rb | app/services/recommended_products/checkout_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/recommended_products/product_info.rb | app/services/recommended_products/product_info.rb | # 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
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/recommended_products/discover_service.rb | app/services/recommended_products/discover_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/recommended_products/base_service.rb | app/services/recommended_products/base_service.rb | # 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_... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/collaborator/create_service.rb | app/services/collaborator/create_service.rb | # 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])
return { success: false, message: "The email address isn't associated with a Gumroad account... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/collaborator/update_service.rb | app/services/collaborator/update_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/order/charge_service.rb | app/services/order/charge_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/order/create_service.rb | app/services/order/create_service.rb | # 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: ... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/order/confirm_service.rb | app/services/order/confirm_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/order/response_helpers.rb | app/services/order/response_helpers.rb | # 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
{... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/helper/unblock_email_service.rb | app/services/helper/unblock_email_service.rb | # 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... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/helper/client.rb | app/services/helper/client.rb | # 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?)
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/onetime/backfill_payment_option_installment_snapshots.rb | app/services/onetime/backfill_payment_option_installment_snapshots.rb | # frozen_string_literal: true
module Onetime
class BackfillPaymentOptionInstallmentSnapshots
def self.perform
PaymentOption.where.not(product_installment_plan_id: nil)
.where.missing(:installment_plan_snapshot)
.find_each do |payment_option|
next unless payment... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/onetime/notify_sellers_about_paypal_payouts_removal.rb | app/services/onetime/notify_sellers_about_paypal_payouts_removal.rb | # frozen_string_literal: true
class Onetime::NotifySellersAboutPaypalPayoutsRemoval
def self.process
User.alive.not_suspended
.where("users.id > ?", $redis.get("notified_paypal_removal_till_user_id").to_i)
.joins(:user_compliance_infos)
.where("user_compliance_info.deleted_at IS NULL AND ... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/onetime/credit_gumroad_sales_fees.rb | app/services/onetime/credit_gumroad_sales_fees.rb | # frozen_string_literal: true
class Onetime::CreditGumroadSalesFees
GUMROAD_DAY = Date.parse("07-04-2021")
LAST_PURCHASE_TO_PROCESS = 36_793_417
VIPUL_USER_ID = 2_241_816
attr_accessor :purchases_to_credit_by_seller
def initialize
@purchases_to_credit_by_seller = Hash.new { |hash, key| hash[key] = [] }
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/services/onetime/decrease_max_affiliate_basis_points.rb | app/services/onetime/decrease_max_affiliate_basis_points.rb | # frozen_string_literal: true
class Onetime::DecreaseMaxAffiliateBasisPoints
def self.process
SelfServiceAffiliateProduct.where("affiliate_basis_points > ?", max_affiliate_basis_points).find_each do |affiliate_product|
affiliate_product.update(affiliate_basis_points: max_affiliate_basis_points)
end
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.