Class: WhopSDK::Resources::SocialAccounts

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/resources/social_accounts.rb,
sig/whop_sdk/resources/social_accounts.rbs

Overview

A Social Account represents an external profile connected to a Whop account or user, such as a Facebook page or Instagram account. Connecting a social account lets Whop run ads under that profile's identity and promote its existing posts.

Use the Social Accounts API to list connected accounts, create a Whop-managed Facebook page, start an OAuth connection, disconnect a social account, and list a connected profile's posts.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ SocialAccounts

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SocialAccounts.

Parameters:



187
188
189
# File 'lib/whop_sdk/resources/social_accounts.rb', line 187

def initialize(client:)
  @client = client
end

Instance Method Details

#connect(platform:, account_id: nil, redirect_url: nil, scopes: nil, request_options: {}) ⇒ WhopSDK::Models::SocialAccountConnectResponse

Some parameter documentations has been truncated, see Models::SocialAccountConnectParams for more details.

Starts an OAuth connection flow and returns an authorize_url where the user can connect a social account.

account-scop

Parameters:

Returns:

See Also:



142
143
144
145
146
147
148
149
150
151
# File 'lib/whop_sdk/resources/social_accounts.rb', line 142

def connect(params)
  parsed, options = WhopSDK::SocialAccountConnectParams.dump_request(params)
  @client.request(
    method: :post,
    path: "social_accounts/connect",
    body: parsed,
    model: WhopSDK::Models::SocialAccountConnectResponse,
    options: options
  )
end

#create(platform:, account_id: nil, request_options: {}) ⇒ WhopSDK::Models::SocialAccount

Some parameter documentations has been truncated, see Models::SocialAccountCreateParams for more details.

Creates or returns a Whop-managed Facebook page for an account.

account-scope

Parameters:

Returns:

See Also:



31
32
33
34
35
36
37
38
39
40
# File 'lib/whop_sdk/resources/social_accounts.rb', line 31

def create(params)
  parsed, options = WhopSDK::SocialAccountCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "social_accounts",
    body: parsed,
    model: WhopSDK::SocialAccount,
    options: options
  )
end

#delete(id, account_id: nil, user_id: nil, request_options: {}) ⇒ Boolean

Some parameter documentations has been truncated, see Models::SocialAccountDeleteParams for more details.

Disconnects a social account from an account or user without deleting the underlying platform account.

Parameters:

  • id (String)

    The ID of the social account to disconnect.

  • account_id (String)

    The Account that the social account is connected to. Provide either this or user

  • user_id (String)

    The User that the social account is connected to. Provide either this or account

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (Boolean)

See Also:



108
109
110
111
112
113
114
115
116
117
118
# File 'lib/whop_sdk/resources/social_accounts.rb', line 108

def delete(id, params = {})
  parsed, options = WhopSDK::SocialAccountDeleteParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :delete,
    path: ["social_accounts/%1$s", id],
    query: query,
    model: WhopSDK::Internal::Type::Boolean,
    options: options
  )
end

#list(account_id: nil, after: nil, before: nil, direction: nil, first: nil, last: nil, order: nil, platform: nil, scopes: nil, user_id: nil, verified: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::SocialAccount>

Some parameter documentations has been truncated, see Models::SocialAccountListParams for more details.

Lists the social accounts linked to an account or user.

Parameters:

  • account_id (String)

    The Account that the social accounts are connected to. Provide either this or us

  • after (String)

    Cursor to fetch the page after (from page_info.end_cursor).

  • before (String)

    Cursor to fetch the page before (from page_info.start_cursor).

  • direction (Symbol, WhopSDK::Models::SocialAccountListParams::Direction)

    Sort direction.

  • first (Integer)

    The number of social accounts to return.

  • last (Integer)

    The number of social accounts to return from the end of the range.

  • order (Symbol, WhopSDK::Models::SocialAccountListParams::Order)

    The field to sort social accounts by.

  • platform (Symbol, WhopSDK::Models::SocialAccountListParams::Platform)

    Only return social accounts for the platform that is specified.

  • scopes (Array<Symbol, WhopSDK::Models::SocialAccountListParams::Scope>)

    Only return social accounts that have these scopes.

  • user_id (String)

    The User that the social accounts are connected to. Provide either this or accou

  • verified (Boolean)

    Only return social accounts that are verified on the platform.

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/whop_sdk/resources/social_accounts.rb', line 76

def list(params = {})
  parsed, options = WhopSDK::SocialAccountListParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "social_accounts",
    query: query,
    page: WhopSDK::Internal::CursorPage,
    model: WhopSDK::SocialAccount,
    options: options
  )
end

#posts(id, account_id:, after: nil, first: nil, post_id: nil, request_options: {}) ⇒ WhopSDK::Models::SocialAccountPostsResponse

Lists the existing posts of a connected Facebook page or Instagram account.

Parameters:

  • id (String)

    The social account (a sacc_ identifier) whose posts to list.

  • account_id (String)

    The Account (a biz_ identifier) the social account is connected to.

  • after (String)

    Cursor to fetch the page after (from page_info.end_cursor).

  • first (Integer)

    The number of posts to return.

  • post_id (String)

    Return only the single post with this platform id, instead of the full list.

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



172
173
174
175
176
177
178
179
180
181
182
# File 'lib/whop_sdk/resources/social_accounts.rb', line 172

def posts(id, params)
  parsed, options = WhopSDK::SocialAccountPostsParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["social_accounts/%1$s/posts", id],
    query: query,
    model: WhopSDK::Models::SocialAccountPostsResponse,
    options: options
  )
end