Class: Whop_sdk::Affiliates::Client
- Inherits:
-
Object
- Object
- Whop_sdk::Affiliates::Client
- Defined in:
- lib/whop_sdk/affiliates/client.rb
Instance Method Summary collapse
-
#archive(request_options: {}, **params) ⇒ Boolean
Archives an existing Affiliate.
-
#create(request_options: {}, **params) ⇒ Whop_sdk::Types::Affiliate
Creates or finds an affiliate for a company and user.
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Whop_sdk::Affiliates::Types::ListAffiliatesResponse
Returns a paginated list of affiliates for the actor in context, with optional filtering by status, search, and sorting.
- #overrides ⇒ Whop_sdk::Overrides::Client
-
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Types::Affiliate
Retrieves the details of an existing affiliate.
-
#unarchive(request_options: {}, **params) ⇒ Boolean
Unarchives an existing Affiliate.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/whop_sdk/affiliates/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#archive(request_options: {}, **params) ⇒ Boolean
Archives an existing Affiliate
Required permissions:
affiliate:update
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/whop_sdk/affiliates/client.rb', line 187 def archive(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: "affiliates/#{URI.encode_uri_component(params[:id].to_s)}/archive", 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 |
#create(request_options: {}, **params) ⇒ Whop_sdk::Types::Affiliate
Creates or finds an affiliate for a company and user.
Required permissions:
affiliate:create
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/whop_sdk/affiliates/client.rb', line 106 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: "affiliates", body: Whop_sdk::Affiliates::Types::CreateAffiliatesRequest.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::Affiliate.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::Affiliates::Types::ListAffiliatesResponse
Returns a paginated list of affiliates for the actor in context, with optional filtering by status, search, and sorting.
Required permissions:
affiliate:basic:read
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 |
# File 'lib/whop_sdk/affiliates/client.rb', line 44 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["direction"] = params[:direction] if params.key?(:direction) query_params["order"] = params[:order] if params.key?(:order) query_params["query"] = params[:query] if params.key?(:query) query_params["status"] = params[:status] if params.key?(:status) 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: "affiliates", 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::Affiliates::Types::ListAffiliatesResponse.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 |
#overrides ⇒ Whop_sdk::Overrides::Client
246 247 248 |
# File 'lib/whop_sdk/affiliates/client.rb', line 246 def overrides @overrides ||= Whop_sdk::Affiliates::Overrides::Client.new(client: @client) end |
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Types::Affiliate
Retrieves the details of an existing affiliate.
Required permissions:
affiliate:basic:read
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/affiliates/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: "affiliates/#{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::Affiliate.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#unarchive(request_options: {}, **params) ⇒ Boolean
Unarchives an existing Affiliate
Required permissions:
affiliate:update
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/whop_sdk/affiliates/client.rb', line 225 def unarchive(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: "affiliates/#{URI.encode_uri_component(params[:id].to_s)}/unarchive", 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 |