Class: Whop_sdk::Bounties::Client
- Inherits:
-
Object
- Object
- Whop_sdk::Bounties::Client
- Defined in:
- lib/whop_sdk/bounties/client.rb
Instance Method Summary collapse
-
#cancel(request_options: {}, **params) ⇒ Whop_sdk::Types::Bounty
Cancels a bounty.
-
#create(request_options: {}, **params) ⇒ Whop_sdk::Types::Bounty
Creates a bounty and escrows its reward pool.
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Whop_sdk::Bounties::Types::ListBountiesResponse
Lists bounties visible to the credential — for an account API key, the account's bounties including scheduled drafts; for a user token, the bounties the user can see and work.
-
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Types::Bounty
Retrieves a bounty by ID.
- #submissions ⇒ Whop_sdk::Submissions::Client
-
#update(request_options: {}, **params) ⇒ Whop_sdk::Types::Bounty
Updates a bounty.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/whop_sdk/bounties/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#cancel(request_options: {}, **params) ⇒ Whop_sdk::Types::Bounty
Cancels a bounty. With no in-flight work, it cancels immediately and refunds the funder. Otherwise it stops new
submissions and cancels once the in-flight work resolves and pays out. Repeating the request is a no-op. A
bounty that already paid out every slot returns 400.
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/whop_sdk/bounties/client.rb', line 233 def cancel(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: "bounties/#{URI.encode_uri_component(params[:id].to_s)}/cancel", 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::Bounty.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::Types::Bounty
Creates a bounty and escrows its reward pool. Publishes immediately, or as a scheduled draft when you set
publish_at.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/whop_sdk/bounties/client.rb', line 110 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: "bounties", body: Whop_sdk::Bounties::Types::CreateBountiesRequest.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::Types::Bounty.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::Bounties::Types::ListBountiesResponse
Lists bounties visible to the credential — for an account API key, the account's bounties including scheduled drafts; for a user token, the bounties the user can see and work.
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 83 84 85 86 87 88 89 |
# File 'lib/whop_sdk/bounties/client.rb', line 43 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["status"] = params[:status] if params.key?(:status) query_params["business_goal_type"] = params[:business_goal_type] if params.key?(:business_goal_type) query_params["country"] = params[:country] if params.key?(:country) query_params["experience_id"] = params[:experience_id] if params.key?(:experience_id) query_params["query"] = params[:query] if params.key?(:query) query_params["created_after"] = params[:created_after] if params.key?(:created_after) query_params["created_before"] = params[:created_before] if params.key?(:created_before) query_params["order"] = params[:order] if params.key?(:order) query_params["direction"] = params[:direction] if params.key?(:direction) 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: "bounties", 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::Bounties::Types::ListBountiesResponse.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::Bounty
Retrieves a bounty by ID. Authentication is optional: a request with no credential reads the bounty when it is
publicly visible — published or completed, and not restricted to a private experience's members. Bounties
outside the caller's scope, and bounties not publicly visible to an anonymous caller, return 404.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/whop_sdk/bounties/client.rb', line 150 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: "bounties/#{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::Bounty.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#submissions ⇒ Whop_sdk::Submissions::Client
256 257 258 |
# File 'lib/whop_sdk/bounties/client.rb', line 256 def submissions @submissions ||= Whop_sdk::Bounties::Submissions::Client.new(client: @client) end |
#update(request_options: {}, **params) ⇒ Whop_sdk::Types::Bounty
Updates a bounty. A published bounty accepts title, description, and country targeting while it is still open with nothing under review. A scheduled (not-yet-published) draft additionally accepts the reward, winner slots, and schedule.
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/whop_sdk/bounties/client.rb', line 189 def update(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) request_data = Whop_sdk::Bounties::Types::UpdateBountiesRequest.new(params).to_h non_body_param_names = %w[id] body = request_data.except(*non_body_param_names) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "PATCH", path: "bounties/#{URI.encode_uri_component(params[:id].to_s)}", body: body, 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::Bounty.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |