Class: Whop_sdk::People::Client
- Inherits:
-
Object
- Object
- Whop_sdk::People::Client
- Defined in:
- lib/whop_sdk/people/client.rb
Instance Method Summary collapse
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Whop_sdk::People::Types::ListPeopleResponse
Lists the people (visitors and customers) of an account: the identity-linked person profiles aggregated from every pixel, payment, and platform event — identities, purchases and LTV, geo/device profile, traffic sources, and first/last marketing touches.
-
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::People::Types::RetrievePeopleResponse
Retrieves one person for an account.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/whop_sdk/people/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#list(request_options: {}, **params) ⇒ Whop_sdk::People::Types::ListPeopleResponse
Lists the people (visitors and customers) of an account: the identity-linked person profiles aggregated from every pixel, payment, and platform event — identities, purchases and LTV, geo/device profile, traffic sources, and first/last marketing touches.
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/whop_sdk/people/client.rb', line 58 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["query"] = params[:query] if params.key?(:query) query_params["source"] = params[:source] if params.key?(:source) query_params["attribution_model"] = params[:attribution_model] if params.key?(:attribution_model) query_params["event_name"] = params[:event_name] if params.key?(:event_name) query_params["custom_event"] = params[:custom_event] if params.key?(:custom_event) query_params["event_from"] = params[:event_from] if params.key?(:event_from) query_params["event_to"] = params[:event_to] if params.key?(:event_to) query_params["audience_id"] = params[:audience_id] if params.key?(:audience_id) query_params["user_id"] = params[:user_id] if params.key?(:user_id) query_params["email"] = params[:email] if params.key?(:email) query_params["phone"] = params[:phone] if params.key?(:phone) query_params["country"] = params[:country] if params.key?(:country) query_params["has_purchased"] = params[:has_purchased] if params.key?(:has_purchased) query_params["contactable"] = params[:contactable] if params.key?(:contactable) query_params["first_seen_within_days"] = params[:first_seen_within_days] if params.key?(:first_seen_within_days) query_params["last_seen_within_days"] = params[:last_seen_within_days] if params.key?(:last_seen_within_days) query_params["first_seen_after"] = params[:first_seen_after] if params.key?(:first_seen_after) query_params["first_seen_before"] = params[:first_seen_before] if params.key?(:first_seen_before) query_params["last_seen_after"] = params[:last_seen_after] if params.key?(:last_seen_after) query_params["last_seen_before"] = params[:last_seen_before] if params.key?(:last_seen_before) query_params["first"] = params[:first] if params.key?(:first) query_params["after"] = params[:after] if params.key?(:after) query_params["before"] = params[:before] if params.key?(:before) query_params["order"] = params[:order] if params.key?(:order) query_params["direction"] = params[:direction] if params.key?(:direction) 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: "people", 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::People::Types::ListPeopleResponse.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::People::Types::RetrievePeopleResponse
Retrieves one person for an account. The identifier can be a person ID (prefixed prsn_), a user ID (prefixed
user_), an email address, or a phone number — merged people resolve to the surviving profile.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/whop_sdk/people/client.rb', line 134 def retrieve(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) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "people/#{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 if code.between?(200, 299) Whop_sdk::People::Types::RetrievePeopleResponse.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |