Class: Whop_sdk::Bounties::Submissions::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/bounties/submissions/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void



10
11
12
# File 'lib/whop_sdk/bounties/submissions/client.rb', line 10

def initialize(client:)
  @client = client
end

Instance Method Details

#list(request_options: {}, **params) ⇒ Whop_sdk::Bounties::Submissions::Types::ListSubmissionsResponse

Lists a bounty's publicly visible work — submitted, approved, and denied submissions in the reduced public shape. Authentication is optional; a bounty that is not publicly visible returns 404.

Examples:

client.bounties.submissions.list(bounty_id: "bounty_id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

Returns:



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
# File 'lib/whop_sdk/bounties/submissions/client.rb', line 39

def list(request_options: {}, **params)
  params = Whop_sdk::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["status"] = params[:status] if params.key?(:status)
  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: request_options[:base_url],
      method: "GET",
      path: "bounties/#{URI.encode_uri_component(params[:bounty_id].to_s)}/submissions",
      query: query_params,
      request_options: 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::Submissions::Types::ListSubmissionsResponse.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::PublicBountySubmission

Retrieves one of a bounty's publicly visible submissions in the reduced public shape — the read behind a shared proof link, whose submission is usually outside the bounty page's capped preview. Authentication is optional; a bounty that is not publicly visible, and a submission that is not publicly visible work on it, both return 404.

Examples:

client.bounties.submissions.retrieve(
  bounty_id: "bounty_id",
  id: "id"
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :bounty_id (String)
  • :id (String)

Returns:



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/whop_sdk/bounties/submissions/client.rb', line 103

def retrieve(request_options: {}, **params)
  params = Whop_sdk::Internal::Types::Utils.normalize_keys(params)
  request = Whop_sdk::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "bounties/#{URI.encode_uri_component(params[:bounty_id].to_s)}/submissions/#{URI.encode_uri_component(params[:id].to_s)}",
    request_options: 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::PublicBountySubmission.load(response.body)
  else
    error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end