Class: Whop_sdk::AuthorizedUsers::Client
- Inherits:
-
Object
- Object
- Whop_sdk::AuthorizedUsers::Client
- Defined in:
- lib/whop_sdk/authorized_users/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Whop_sdk::Types::AuthorizedUser
Add a new authorized user to a company.
-
#delete(request_options: {}, **params) ⇒ Boolean
Remove an authorized user from a company.
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Whop_sdk::AuthorizedUsers::Types::ListAuthorizedUsersResponse
Returns a paginated list of authorized team members for a company, with optional filtering by user, role, and creation date.
-
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Types::AuthorizedUser
Retrieves the details of an existing authorized user.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/whop_sdk/authorized_users/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Whop_sdk::Types::AuthorizedUser
Add a new authorized user to a company.
Required permissions:
authorized_user:createmember:email:read
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/whop_sdk/authorized_users/client.rb', line 112 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: "authorized_users", body: Whop_sdk::AuthorizedUsers::Types::CreateAuthorizedUsersRequest.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::AuthorizedUser.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) ⇒ Boolean
Remove an authorized user from a company.
Required permissions:
authorized_user:delete
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/whop_sdk/authorized_users/client.rb', line 198 def delete(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["company_id"] = params[:company_id] if params.key?(:company_id) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "authorized_users/#{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 return if code.between?(200, 299) error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#list(request_options: {}, **params) ⇒ Whop_sdk::AuthorizedUsers::Types::ListAuthorizedUsersResponse
Returns a paginated list of authorized team members for a company, with optional filtering by user, role, and creation date.
Required permissions:
company:authorized_user:readmember:email:read
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 |
# File 'lib/whop_sdk/authorized_users/client.rb', line 48 def list(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["after"] = params[:after] if params.key?(:after) query_params["before"] = params[:before] if params.key?(:before) query_params["first"] = params[:first] if params.key?(:first) query_params["last"] = params[:last] if params.key?(:last) query_params["company_id"] = params[:company_id] if params.key?(:company_id) 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) 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: "authorized_users", 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::AuthorizedUsers::Types::ListAuthorizedUsersResponse.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::AuthorizedUser
Retrieves the details of an existing authorized user.
Required permissions:
company:authorized_user:readmember:email:read
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/whop_sdk/authorized_users/client.rb', line 154 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: "authorized_users/#{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::AuthorizedUser.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |