Class: Whop_sdk::CheckoutConfigurations::Client
- Inherits:
-
Object
- Object
- Whop_sdk::CheckoutConfigurations::Client
- Defined in:
- lib/whop_sdk/checkout_configurations/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Whop_sdk::CheckoutConfigurations::Types::CreateCheckoutConfigurationsResponse
Creates a reusable checkout configuration for an existing or inline plan.
-
#delete(request_options: {}, **params) ⇒ Whop_sdk::CheckoutConfigurations::Types::DeleteCheckoutConfigurationsResponse
Deletes a checkout configuration so its checkout URL can no longer be used.
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Whop_sdk::CheckoutConfigurations::Types::ListCheckoutConfigurationsResponse
Lists checkout configurations for an account.
-
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::CheckoutConfigurations::Types::RetrieveCheckoutConfigurationsResponse
Retrieves a checkout configuration by ID.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/whop_sdk/checkout_configurations/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Whop_sdk::CheckoutConfigurations::Types::CreateCheckoutConfigurationsResponse
Creates a reusable checkout configuration for an existing or inline plan.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/whop_sdk/checkout_configurations/client.rb', line 93 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: "checkout_configurations", body: Whop_sdk::CheckoutConfigurations::Types::CreateCheckoutConfigurationsRequest.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::CheckoutConfigurations::Types::CreateCheckoutConfigurationsResponse.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::CheckoutConfigurations::Types::DeleteCheckoutConfigurationsResponse
Deletes a checkout configuration so its checkout URL can no longer be used.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/whop_sdk/checkout_configurations/client.rb', line 169 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: "checkout_configurations/#{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::CheckoutConfigurations::Types::DeleteCheckoutConfigurationsResponse.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::CheckoutConfigurations::Types::ListCheckoutConfigurationsResponse
Lists checkout configurations for an account.
35 36 37 38 39 40 41 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 |
# File 'lib/whop_sdk/checkout_configurations/client.rb', line 35 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["plan_id"] = params[:plan_id] if params.key?(:plan_id) 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) 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: "checkout_configurations", 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::CheckoutConfigurations::Types::ListCheckoutConfigurationsResponse.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::CheckoutConfigurations::Types::RetrieveCheckoutConfigurationsResponse
Retrieves a checkout configuration by ID. This endpoint is public so a checkout page can load from the configuration URL.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/whop_sdk/checkout_configurations/client.rb', line 132 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: "checkout_configurations/#{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::CheckoutConfigurations::Types::RetrieveCheckoutConfigurationsResponse.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |