Class: Whop_sdk::TeamMembers::Client
- Inherits:
-
Object
- Object
- Whop_sdk::TeamMembers::Client
- Defined in:
- lib/whop_sdk/team_members/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Whop_sdk::Types::TeamMember
Adds a member to an account's team with a system role.
-
#delete(request_options: {}, **params) ⇒ Whop_sdk::TeamMembers::Types::DeleteTeamMembersResponse
Removes a team member from the account, or revokes a pending invite when given an
ausri_ID. - #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Whop_sdk::TeamMembers::Types::ListTeamMembersResponse
Lists an account's team members, including pending invites (
status: "pending",ausri_ids;userisnullfor invites sent to an email with no Whop account yet). -
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Types::TeamMember
Retrieves a team member by ID.
-
#update(request_options: {}, **params) ⇒ Whop_sdk::Types::TeamMember
Changes a team member's system role.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/whop_sdk/team_members/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Whop_sdk::Types::TeamMember
Adds a member to an account's team with a system role. Identify them by exactly one of user_id or email. If
the person has not yet accepted — or the email does not belong to a Whop account yet — an invitation is sent
instead and the response is 202 with { "object": "team_member_invite", "invitation_sent": true }. If they
already have a pending invite, the request fails with a 400. Custom roles cannot be granted via the API.
Granting the workforce role is also allowed with the bounty:create scope.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/whop_sdk/team_members/client.rb', line 108 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: "team_members", body: Whop_sdk::TeamMembers::Types::CreateTeamMembersRequest.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::TeamMember.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#delete(request_options: {}, **params) ⇒ Whop_sdk::TeamMembers::Types::DeleteTeamMembersResponse
Removes a team member from the account, or revokes a pending invite when given an ausri_ ID. A user session
may delete its own membership to leave the team without the delete scope. Removing a member on the workforce
role is also allowed with the bounty:create scope. The account owner cannot be removed.
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/whop_sdk/team_members/client.rb', line 186 def delete(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "team_members/#{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::TeamMembers::Types::DeleteTeamMembersResponse.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::TeamMembers::Types::ListTeamMembersResponse
Lists an account's team members, including pending invites (status: "pending", ausri_ ids; user is null
for invites sent to an email with no Whop account yet). For accepted members, email requires the
company:authorized_user:email:read scope and is null otherwise. Listing role=workforce is also allowed
with the bounty:create scope.
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 83 84 85 |
# File 'lib/whop_sdk/team_members/client.rb', line 42 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["status"] = params[:status] if params.key?(:status) query_params["user_id"] = params[:user_id] if params.key?(:user_id) query_params["role"] = params[:role] if params.key?(:role) 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["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: "team_members", 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::TeamMembers::Types::ListTeamMembersResponse.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::TeamMember
Retrieves a team member by ID. email requires the company:authorized_user:email:read scope and is null
otherwise.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/whop_sdk/team_members/client.rb', line 147 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: "team_members/#{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::TeamMember.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update(request_options: {}, **params) ⇒ Whop_sdk::Types::TeamMember
Changes a team member's system role. Requires a user session — account API keys cannot change member roles. The account owner's role cannot be changed, and you cannot change your own role.
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/whop_sdk/team_members/client.rb', line 227 def update(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) request_data = Whop_sdk::TeamMembers::Types::UpdateTeamMembersRequest.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: "team_members/#{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::TeamMember.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |