Class: Whop_sdk::RecommendedActions::Client
- Inherits:
-
Object
- Object
- Whop_sdk::RecommendedActions::Client
- Defined in:
- lib/whop_sdk/recommended_actions/client.rb
Instance Method Summary collapse
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Whop_sdk::RecommendedActions::Types::ListRecommendedActionsResponse
Lists the recommended action chains for an account — short sequences of actions (create a product, price it, publish it) the account should run next, gated on what it already has.
-
#list_executions(request_options: {}, **params) ⇒ Whop_sdk::RecommendedActions::Types::ListExecutionsRecommendedActionsResponse
Lists the per-step record of a recommended action chain the server ran — one entry per step in position order, each carrying its current status and, once the step completed, the API response it produced.
-
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Types::AccountRecommendedActionChain
Retrieves a recommended action chain by id, including chains that have already been run.
-
#run(request_options: {}, **params) ⇒ Whop_sdk::RecommendedActions::Types::RunRecommendedActionsResponse
Records that the caller ran a recommended action chain.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/whop_sdk/recommended_actions/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#list(request_options: {}, **params) ⇒ Whop_sdk::RecommendedActions::Types::ListRecommendedActionsResponse
Lists the recommended action chains for an account — short sequences of actions (create a product, price it, publish it) the account should run next, gated on what it already has.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/whop_sdk/recommended_actions/client.rb', line 29 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) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "recommended_actions", 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::RecommendedActions::Types::ListRecommendedActionsResponse.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_executions(request_options: {}, **params) ⇒ Whop_sdk::RecommendedActions::Types::ListExecutionsRecommendedActionsResponse
Lists the per-step record of a recommended action chain the server ran — one entry per step in position order, each carrying its current status and, once the step completed, the API response it produced. A chain that was never run server-side returns an empty list.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/whop_sdk/recommended_actions/client.rb', line 160 def list_executions(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: "recommended_actions/#{URI.encode_uri_component(params[:id].to_s)}/executions", 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::RecommendedActions::Types::ListExecutionsRecommendedActionsResponse.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::AccountRecommendedActionChain
Retrieves a recommended action chain by id, including chains that have already been run. Seeded chains are reconstructed from their hard-coded chain; generated chains are read from the account's stored chain, with each step's filled-in input.
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 |
# File 'lib/whop_sdk/recommended_actions/client.rb', line 73 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: "recommended_actions/#{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::Types::AccountRecommendedActionChain.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#run(request_options: {}, **params) ⇒ Whop_sdk::RecommendedActions::Types::RunRecommendedActionsResponse
Records that the caller ran a recommended action chain. Nothing is executed server-side yet — the client follows
the chain's step CTAs itself; this writes the recommended_action_chain.executed analytics event.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/whop_sdk/recommended_actions/client.rb', line 116 def run(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: "POST", path: "recommended_actions/#{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::RecommendedActions::Types::RunRecommendedActionsResponse.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |