Class: Whop_sdk::Partners::Client
- Inherits:
-
Object
- Object
- Whop_sdk::Partners::Client
- Defined in:
- lib/whop_sdk/partners/client.rb
Instance Method Summary collapse
- #businesses ⇒ Whop_sdk::Businesses::Client
-
#create(request_options: {}, **_params) ⇒ Whop_sdk::Partners::Types::CreatePartnersResponse
Enrolls the calling user in the Whop partner program, making their partner businesses eligible for earnings.
- #initialize(client:) ⇒ void constructor
-
#leaderboard(request_options: {}, **params) ⇒ Whop_sdk::Partners::Types::LeaderboardPartnersResponse
Ranks referrers by partner business earnings — all-time by default, or over the current day, month, year, or trailing 30 days.
- #links ⇒ Whop_sdk::Links::Client
-
#referred_users(request_options: {}, **params) ⇒ Whop_sdk::Partners::Types::ReferredUsersPartnersResponse
Lists the users the caller referred onto Whop (newest first), each with the second-tier earnings the caller has made from that user's businesses.
-
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Types::Partner
Retrieves the authenticated user's public profile, enrollment date, partner verification timestamp, verification waitlist status, active direct business referral count, and default payout rates.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/whop_sdk/partners/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#businesses ⇒ Whop_sdk::Businesses::Client
193 194 195 |
# File 'lib/whop_sdk/partners/client.rb', line 193 def businesses @businesses ||= Whop_sdk::Partners::Businesses::Client.new(client: @client) end |
#create(request_options: {}, **_params) ⇒ Whop_sdk::Partners::Types::CreatePartnersResponse
Enrolls the calling user in the Whop partner program, making their partner businesses eligible for earnings. Idempotent — enrolling again keeps the original enrollment time.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/whop_sdk/partners/client.rb', line 28 def create(request_options: {}, **_params) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "partners", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Whop_sdk::Partners::Types::CreatePartnersResponse.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#leaderboard(request_options: {}, **params) ⇒ Whop_sdk::Partners::Types::LeaderboardPartnersResponse
Ranks referrers by partner business earnings — all-time by default, or over the current day, month, year, or trailing 30 days. Authentication is optional: authenticated callers also get their own standing, anonymous callers get the rankings alone.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/whop_sdk/partners/client.rb', line 66 def leaderboard(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["period"] = params[:period] if params.key?(:period) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "partners/leaderboard", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Whop_sdk::Partners::Types::LeaderboardPartnersResponse.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#links ⇒ Whop_sdk::Links::Client
198 199 200 |
# File 'lib/whop_sdk/partners/client.rb', line 198 def links @links ||= Whop_sdk::Partners::Links::Client.new(client: @client) end |
#referred_users(request_options: {}, **params) ⇒ Whop_sdk::Partners::Types::ReferredUsersPartnersResponse
Lists the users the caller referred onto Whop (newest first), each with the second-tier earnings the caller has made from that user's businesses.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/whop_sdk/partners/client.rb', line 113 def referred_users(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["has_businesses"] = params[:has_businesses] if params.key?(:has_businesses) query_params["has_earning_businesses"] = params[:has_earning_businesses] if params.key?(:has_earning_businesses) query_params["first"] = params[:first] if params.key?(:first) query_params["after"] = params[:after] if params.key?(:after) query_params["last"] = params[:last] if params.key?(:last) query_params["before"] = params[:before] if params.key?(:before) Whop_sdk::Internal::CursorItemIterator.new( cursor_field: :end_cursor, item_field: :data, initial_cursor: query_params["after"] ) do |next_cursor| query_params["after"] = next_cursor request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "partners/referred_users", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) parsed_response = Whop_sdk::Partners::Types::ReferredUsersPartnersResponse.load(response.body) [parsed_response, response] else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end end |
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Types::Partner
Retrieves the authenticated user's public profile, enrollment date, partner verification timestamp, verification waitlist status, active direct business referral count, and default payout rates. Use me or the authenticated user's own user ID; other users are not accessible. Users who have not enrolled have a null joined_at. Retrieve referral URLs and promotion links from GET /partners/links.
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/whop_sdk/partners/client.rb', line 170 def retrieve(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "partners/#{URI.encode_uri_component(params[:id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Whop_sdk::Types::Partner.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |