Class: Whop_sdk::SocialAccounts::Client
- Inherits:
-
Object
- Object
- Whop_sdk::SocialAccounts::Client
- Defined in:
- lib/whop_sdk/social_accounts/client.rb
Instance Method Summary collapse
-
#connect(request_options: {}, **params) ⇒ Whop_sdk::SocialAccounts::Types::ConnectSocialAccountsResponse
Starts an OAuth connection flow and returns an authorize_url where the user can connect a social account.
-
#create(request_options: {}, **params) ⇒ Whop_sdk::Types::SocialAccount
Creates or returns a Whop-managed Facebook page for an account.
-
#delete(request_options: {}, **params) ⇒ Whop_sdk::SocialAccounts::Types::DeleteSocialAccountsResponse
Disconnects a social account from an account or user without deleting the underlying platform account.
- #initialize(client:) ⇒ void constructor
-
#lead_forms(request_options: {}, **params) ⇒ Whop_sdk::SocialAccounts::Types::LeadFormsSocialAccountsResponse
Lists the active lead (instant) forms that already exist on a connected Facebook page, so an ad can reuse one as its
lead_gen_form_idinstead of authoring a new form. -
#list(request_options: {}, **params) ⇒ Whop_sdk::SocialAccounts::Types::ListSocialAccountsResponse
Lists the social accounts linked to an account or user.
-
#posts(request_options: {}, **params) ⇒ Whop_sdk::SocialAccounts::Types::PostsSocialAccountsResponse
Lists the existing posts of a connected Facebook page, Instagram account, or TikTok account.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/whop_sdk/social_accounts/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#connect(request_options: {}, **params) ⇒ Whop_sdk::SocialAccounts::Types::ConnectSocialAccountsResponse
Starts an OAuth connection flow and returns an authorize_url where the user can connect a social account.
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/whop_sdk/social_accounts/client.rb', line 133 def connect(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: "social_accounts/connect", body: Whop_sdk::SocialAccounts::Types::ConnectSocialAccountsRequest.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::SocialAccounts::Types::ConnectSocialAccountsResponse.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#create(request_options: {}, **params) ⇒ Whop_sdk::Types::SocialAccount
Creates or returns a Whop-managed Facebook page for an account.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/whop_sdk/social_accounts/client.rb', line 96 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: "social_accounts", body: Whop_sdk::SocialAccounts::Types::CreateSocialAccountsRequest.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::SocialAccount.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::SocialAccounts::Types::DeleteSocialAccountsResponse
Disconnects a social account from an account or user without deleting the underlying platform account.
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/whop_sdk/social_accounts/client.rb', line 173 def delete(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["user_id"] = params[:user_id] if params.key?(:user_id) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "social_accounts/#{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::SocialAccounts::Types::DeleteSocialAccountsResponse.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#lead_forms(request_options: {}, **params) ⇒ Whop_sdk::SocialAccounts::Types::LeadFormsSocialAccountsResponse
Lists the active lead (instant) forms that already exist on a connected Facebook page, so an ad can reuse one as
its lead_gen_form_id instead of authoring a new form. Every active form comes back in a single response — the
list is not paginated.
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/whop_sdk/social_accounts/client.rb', line 221 def lead_forms(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: "social_accounts/#{URI.encode_uri_component(params[:id].to_s)}/lead_forms", 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::SocialAccounts::Types::LeadFormsSocialAccountsResponse.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::SocialAccounts::Types::ListSocialAccountsResponse
Lists the social accounts linked to an account or user.
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 75 76 77 78 79 80 |
# File 'lib/whop_sdk/social_accounts/client.rb', line 38 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["user_id"] = params[:user_id] if params.key?(:user_id) query_params["platform"] = params[:platform] if params.key?(:platform) query_params["verified"] = params[:verified] if params.key?(:verified) query_params["scopes"] = params[:scopes] if params.key?(:scopes) query_params["first"] = params[:first] if params.key?(:first) query_params["after"] = params[:after] if params.key?(:after) query_params["last"] = params[:last] if params.key?(:last) 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: "social_accounts", 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::SocialAccounts::Types::ListSocialAccountsResponse.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 |
#posts(request_options: {}, **params) ⇒ Whop_sdk::SocialAccounts::Types::PostsSocialAccountsResponse
Lists the existing posts of a connected Facebook page, Instagram account, or TikTok account.
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/whop_sdk/social_accounts/client.rb', line 269 def posts(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["post_id"] = params[:post_id] if params.key?(:post_id) 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: "social_accounts/#{URI.encode_uri_component(params[:id].to_s)}/posts", 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::SocialAccounts::Types::PostsSocialAccountsResponse.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 |