Class: Whop_sdk::Payouts::Client
- Inherits:
-
Object
- Object
- Whop_sdk::Payouts::Client
- Defined in:
- lib/whop_sdk/payouts/client.rb
Instance Method Summary collapse
-
#cancel(request_options: {}, **params) ⇒ Whop_sdk::Payouts::Types::CancelPayoutsResponse
Cancels a payout that is still in review and returns the funds, fees included, to the balance.
-
#create(request_options: {}, **params) ⇒ Whop_sdk::Payouts::Types::CreatePayoutsResponse
Sends money from an account or user balance to a saved payout method for that owner.
-
#create_quote(request_options: {}, **params) ⇒ Whop_sdk::Payouts::Types::CreateQuotePayoutsResponse
Creates a short-lived, provider-backed quote for a payout.
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Whop_sdk::Payouts::Types::ListPayoutsResponse
Lists an account's or user's payouts, newest first.
- #methods ⇒ Whop_sdk::Methods::Client
-
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Payouts::Types::RetrievePayoutsResponse
Fetches one payout by its
wdrl_ID, or by thecofr_conversion request ID a stablecoin payout carries aspayout_request_id— both ids answer with the same payout object. - #supported_methods ⇒ Whop_sdk::SupportedMethods::Client
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/whop_sdk/payouts/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#cancel(request_options: {}, **params) ⇒ Whop_sdk::Payouts::Types::CancelPayoutsResponse
Cancels a payout that is still in review and returns the funds, fees included, to the balance. A payout can be
canceled while its status is in_review. A requested payout is still being prepared (its funds may be
converting) and answers 409 until it reaches review; from processing on, the money is on its way and the
answer is 409 with error type not_cancelable. Canceling a payout that is already canceled succeeds and returns
it unchanged.
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/whop_sdk/payouts/client.rb', line 231 def cancel(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["account_id"] = params[:account_id] if params.key?(:account_id) query_params["user_id"] = params[:user_id] if params.key?(:user_id) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "payouts/#{URI.encode_uri_component(params[:id].to_s)}/cancel", 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::Payouts::Types::CancelPayoutsResponse.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#create(request_options: {}, **params) ⇒ Whop_sdk::Payouts::Types::CreatePayoutsResponse
Sends money from an account or user balance to a saved payout method for that owner.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/whop_sdk/payouts/client.rb', line 101 def create(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "payouts", body: Whop_sdk::Payouts::Types::CreatePayoutsRequest.new(params).to_h, 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::Payouts::Types::CreatePayoutsResponse.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#create_quote(request_options: {}, **params) ⇒ Whop_sdk::Payouts::Types::CreateQuotePayoutsResponse
Creates a short-lived, provider-backed quote for a payout. No funds move until the returned quote_token is submitted to POST /payouts. An Idempotency-Key header is required.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/whop_sdk/payouts/client.rb', line 142 def create_quote(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "payouts/quotes", body: Whop_sdk::Payouts::Types::CreateQuotePayoutsRequest.new(params).to_h, 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::Payouts::Types::CreateQuotePayoutsResponse.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list(request_options: {}, **params) ⇒ Whop_sdk::Payouts::Types::ListPayoutsResponse
Lists an account's or user's payouts, newest first.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/whop_sdk/payouts/client.rb', line 39 def list(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["account_id"] = params[:account_id] if params.key?(:account_id) query_params["user_id"] = params[:user_id] if params.key?(:user_id) query_params["currency"] = params[:currency] if params.key?(:currency) query_params["status"] = params[:status] if params.key?(:status) query_params["source"] = params[:source] if params.key?(:source) query_params["payout_method_id"] = params[:payout_method_id] if params.key?(:payout_method_id) query_params["created_before"] = params[:created_before] if params.key?(:created_before) query_params["created_after"] = params[:created_after] if params.key?(:created_after) 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: "payouts", 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::Payouts::Types::ListPayoutsResponse.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 |
#methods ⇒ Whop_sdk::Methods::Client
259 260 261 |
# File 'lib/whop_sdk/payouts/client.rb', line 259 def methods @methods ||= Whop_sdk::Payouts::Methods::Client.new(client: @client) end |
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Payouts::Types::RetrievePayoutsResponse
Fetches one payout by its wdrl_ ID, or by the cofr_ conversion request ID a stablecoin payout carries as
payout_request_id — both ids answer with the same payout object.
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/whop_sdk/payouts/client.rb', line 183 def retrieve(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["account_id"] = params[:account_id] if params.key?(:account_id) query_params["user_id"] = params[:user_id] if params.key?(:user_id) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "payouts/#{URI.encode_uri_component(params[:id].to_s)}", 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::Payouts::Types::RetrievePayoutsResponse.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#supported_methods ⇒ Whop_sdk::SupportedMethods::Client
264 265 266 |
# File 'lib/whop_sdk/payouts/client.rb', line 264 def supported_methods @supported_methods ||= Whop_sdk::Payouts::SupportedMethods::Client.new(client: @client) end |