Class: Whop_sdk::AppBuilds::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void



9
10
11
# File 'lib/whop_sdk/app_builds/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#create(request_options: {}, **params) ⇒ Whop_sdk::Types::AppBuild

Uploads a new build artifact for an app. Upload the file first (POST /files or a direct upload), then reference it here; iOS and Android take a .zip bundle, web takes a JavaScript file or a .zip archive of the hosted site.

Examples:

client.app_builds.create(
  attachment: {},
  checksum: "xxxxxxxxxxxxxxx",
  platform: "ios"
)

Parameters:

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)

Returns:



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/whop_sdk/app_builds/client.rb', line 98

def create(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: "POST",
    path: "app_builds",
    body: Whop_sdk::AppBuilds::Types::CreateAppBuildsRequest.new(params).to_h,
    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::AppBuild.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::AppBuilds::Types::ListAppBuildsResponse

Returns a paginated list of build artifacts for an app, newest first, with optional platform, status, and creation-date filters.

Examples:

client.app_builds.list(app_id: "app_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:



37
38
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
# File 'lib/whop_sdk/app_builds/client.rb', line 37

def list(request_options: {}, **params)
  params = Whop_sdk::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["app_id"] = params[:app_id] if params.key?(:app_id)
  query_params["platform"] = params[:platform] if params.key?(:platform)
  query_params["status"] = params[:status] if params.key?(:status)
  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: request_options[:base_url],
      method: "GET",
      path: "app_builds",
      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::AppBuilds::Types::ListAppBuildsResponse.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

#promote(request_options: {}, **params) ⇒ Whop_sdk::Types::AppBuild

Promotes a draft or approved app build to production so it becomes the active version served to users. Draft builds enter review first.

Examples:

client.app_builds.promote(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):

  • :id (String)

Returns:



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/whop_sdk/app_builds/client.rb', line 174

def promote(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: "POST",
    path: "app_builds/#{URI.encode_uri_component(params[:id].to_s)}/promote",
    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::AppBuild.load(response.body)
  else
    error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Types::AppBuild

Retrieves the details of an existing app build.

Examples:

client.app_builds.retrieve(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):

  • :id (String)

Returns:



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/whop_sdk/app_builds/client.rb', line 136

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: "app_builds/#{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::AppBuild.load(response.body)
  else
    error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end