Class: Whop_sdk::SupportChannels::Client
- Inherits:
-
Object
- Object
- Whop_sdk::SupportChannels::Client
- Defined in:
- lib/whop_sdk/support_channels/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Whop_sdk::Types::SupportChannel
Open a new support channel between a company team member and a customer.
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Whop_sdk::SupportChannels::Types::ListSupportChannelsResponse
Returns a paginated list of support channels for a specific company, with optional filtering by resolution status and custom sorting.
-
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Types::SupportChannel
Retrieves the details of an existing support channel.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/whop_sdk/support_channels/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Whop_sdk::Types::SupportChannel
Open a new support channel between a company team member and a customer. Returns the existing channel if one already exists for that user.
Required permissions:
support_chat:create
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/whop_sdk/support_channels/client.rb', line 107 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: "support_channels", body: Whop_sdk::SupportChannels::Types::CreateSupportChannelsRequest.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::SupportChannel.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::SupportChannels::Types::ListSupportChannelsResponse
Returns a paginated list of support channels for a specific company, with optional filtering by resolution status and custom sorting.
Required permissions:
support_chat: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/support_channels/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["view"] = params[:view] if params.key?(:view) query_params["open"] = params[:open] if params.key?(:open) query_params["direction"] = params[:direction] if params.key?(:direction) query_params["order"] = params[:order] if params.key?(:order) 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: "support_channels", 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::SupportChannels::Types::ListSupportChannelsResponse.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::SupportChannel
Retrieves the details of an existing support channel.
Required permissions:
support_chat:read
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/whop_sdk/support_channels/client.rb', line 148 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: "support_channels/#{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::SupportChannel.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |