Class: PostForMe::Resources::SocialAccounts

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

Overview

Social accounts represent platform-specific accounts (e.g. Twitter, LinkedIn, Facebook) that are used for publishing posts. Each social account has a unique id that can be referenced when creating or scheduling posts to specify which platforms the content should be published to.

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:



197
198
199
# File 'lib/post_for_me/resources/social_accounts.rb', line 197

def initialize(client:)
  @client = client
end

Instance Method Details

#create(access_token:, access_token_expires_at:, platform:, user_id:, external_id: nil, metadata: nil, refresh_token: nil, refresh_token_expires_at: nil, username: nil, request_options: {}) ⇒ PostForMe::Models::SocialAccount

If a social account with the same platform and user_id already exists, it will be updated. If not, a new social account will be created.

Parameters:

  • access_token (String)

    The access token of the social account

  • access_token_expires_at (Time)

    The access token expiration date of the social account

  • platform (Symbol, PostForMe::Models::SocialAccountCreateParams::Platform)

    The platform of the social account

  • user_id (String)

    The user id of the social account

  • external_id (String, nil)

    The external id of the social account

  • metadata (Object)

    The metadata of the social account

  • refresh_token (String, nil)

    The refresh token of the social account

  • refresh_token_expires_at (Time, nil)

    The refresh token expiration date of the social account

  • username (String, nil)

    The platform's username of the social account

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

Returns:

See Also:



38
39
40
41
42
43
44
45
46
47
# File 'lib/post_for_me/resources/social_accounts.rb', line 38

def create(params)
  parsed, options = PostForMe::SocialAccountCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/social-accounts",
    body: parsed,
    model: PostForMe::SocialAccount,
    options: options
  )
end

#create_auth_url(platform:, external_id: nil, permissions: nil, platform_data: nil, redirect_url_override: nil, request_options: {}) ⇒ PostForMe::Models::SocialAccountCreateAuthURLResponse

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

Generates a URL that initiates the authentication flow for a user's social media account. When visited, the user is redirected to the selected social platform's login/authorization page. Upon successful authentication, they are redirected back to your application.

For Quickstart projects using Post for Me system credentials, redirect_url_override is not accepted. Configure the project redirect URL in the dashboard instead.

Parameters:

Returns:

See Also:



162
163
164
165
166
167
168
169
170
171
# File 'lib/post_for_me/resources/social_accounts.rb', line 162

def create_auth_url(params)
  parsed, options = PostForMe::SocialAccountCreateAuthURLParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/social-accounts/auth-url",
    body: parsed,
    model: PostForMe::Models::SocialAccountCreateAuthURLResponse,
    options: options
  )
end

#disconnect(id, request_options: {}) ⇒ PostForMe::Models::SocialAccountDisconnectResponse

Disconnecting an account with remove all auth tokens and mark the account as disconnected. The record of the account will be kept and can be retrieved and reconnected by the owner of the account.

Parameters:

Returns:

See Also:



185
186
187
188
189
190
191
192
# File 'lib/post_for_me/resources/social_accounts.rb', line 185

def disconnect(id, params = {})
  @client.request(
    method: :post,
    path: ["v1/social-accounts/%1$s/disconnect", id],
    model: PostForMe::Models::SocialAccountDisconnectResponse,
    options: params[:request_options]
  )
end

#list(id: nil, external_id: nil, limit: nil, offset: nil, platform: nil, status: nil, username: nil, request_options: {}) ⇒ PostForMe::Models::SocialAccountListResponse

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

Get a paginated result for social accounts based on the applied filters

Parameters:

  • id (Array<String>)

    Filter by id(s). Multiple values imply OR logic (e.g., ?id=spc_xxxxxx&id=spc_yyy

  • external_id (Array<String>)

    Filter by externalId(s). Multiple values imply OR logic (e.g., ?externalId=test&

  • limit (Float)

    Number of items to return

  • offset (Float)

    Number of items to skip

  • platform (Array<String>)

    Filter by platform(s). Multiple values imply OR logic (e.g., ?platform=x&platfor

  • status (Array<Symbol, PostForMe::Models::SocialAccountListParams::Status>)

    Filter by status. Multiple values imply OR logic (e.g., ?status=connected&status

  • username (Array<String>)

    Filter by username(s). Multiple values imply OR logic (e.g., ?username=test&user

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

Returns:

See Also:



121
122
123
124
125
126
127
128
129
130
131
# File 'lib/post_for_me/resources/social_accounts.rb', line 121

def list(params = {})
  parsed, options = PostForMe::SocialAccountListParams.dump_request(params)
  query = PostForMe::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v1/social-accounts",
    query: query,
    model: PostForMe::Models::SocialAccountListResponse,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ PostForMe::Models::SocialAccount

Get social account by ID

Parameters:

Returns:

See Also:



60
61
62
63
64
65
66
67
# File 'lib/post_for_me/resources/social_accounts.rb', line 60

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["v1/social-accounts/%1$s", id],
    model: PostForMe::SocialAccount,
    options: params[:request_options]
  )
end

#update(id, external_id: nil, username: nil, request_options: {}) ⇒ PostForMe::Models::SocialAccount

Update social account

Parameters:

  • id (String)

    Social Account ID

  • external_id (String)

    The platform's external id of the social account

  • username (String)

    The platform's username of the social account

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

Returns:

See Also:



84
85
86
87
88
89
90
91
92
93
# File 'lib/post_for_me/resources/social_accounts.rb', line 84

def update(id, params = {})
  parsed, options = PostForMe::SocialAccountUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["v1/social-accounts/%1$s", id],
    body: parsed,
    model: PostForMe::SocialAccount,
    options: options
  )
end