-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP - first draft of a FacebookClient class, including an untested cr…
…eateAudience hook for retl
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
packages/destination-actions/src/destinations/facebook-custom-audiences/fbca-operations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { RequestClient } from '@segment/actions-core' | ||
|
||
const FACEBOOK_API_VERSION = 'v20.0' | ||
|
||
interface AudienceCreationResponse { | ||
id: string | ||
message: string | ||
} | ||
|
||
export default class FacebookClient { | ||
request: RequestClient | ||
baseUrl: string | ||
adAccountId: string | ||
|
||
constructor(request: RequestClient, adAccountId: string) { | ||
this.request = request | ||
this.baseUrl = `https://graph.facebook.com/${FACEBOOK_API_VERSION}/` | ||
this.adAccountId = adAccountId | ||
} | ||
|
||
createAudience = async (name: string) => { | ||
return this.request<AudienceCreationResponse>(`${this.baseUrl}${this.adAccountId}/customaudiences`, { | ||
method: 'post', | ||
json: { | ||
name, | ||
subtype: 'CUSTOM', | ||
description: 'TODO: Hardcoded for now' | ||
} | ||
}) | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
packages/destination-actions/src/destinations/facebook-custom-audiences/sync/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters