Skip to content

Commit

Permalink
Add audience APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
aashikam committed Oct 3, 2024
1 parent 29baf30 commit 2436123
Show file tree
Hide file tree
Showing 7 changed files with 464 additions and 1 deletion.
8 changes: 8 additions & 0 deletions gen_resources/config_fb.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@
{
"openapiOperationID": "Delete Ad",
"connectorOperationName": "deleteAd"
},
{
"openapiOperationID": "CreateCustomAudience",
"connectorOperationName": "createCustomAudience"
},
{
"openapiOperationID": "GetCustomAudiences",
"connectorOperationName": "getCustomAudiences"
}
]
}
Expand Down
113 changes: 112 additions & 1 deletion gen_resources/facebook_ads_open_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,60 @@ tags:
description: A group of ads that share the same daily or lifetime budget, schedule, bid type, bid info, and targeting data.
- name: Ad
description: Contains information to display an ad and associate it with an ad set.
- name: CustomAudience
description: Represent a custom audience
security:
- ApiKeyAuth: []
- ApiKeyAuth: [ ]
paths:
/act_{ad_account_id}/custom_audiences:
get:
tags:
- "CustomAudience"
description: Retrieves custom audiences for an ad account.
operationId: GetCustomAudiences
parameters:
- name: ad_account_id
in: path
description: The ID of the ad account.
required: true
schema:
type: string
- name: fields
in: query
description: Comma-separated list of fields to retrieve for each custom audience.
schema:
type: string
responses:
200:
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/CustomAudienceList'
post:
tags:
- "CustomAudience"
description: Creates a new custom audience under the specified ad account.
operationId: CreateCustomAudience
parameters:
- name: ad_account_id
in: path
description: The ID of the ad account.
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CustomAudienceCreate'
responses:
201:
description: Custom Audience created successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/CustomAudienceResponse'
/act_{ad_account_id}/campaigns:
get:
tags:
Expand Down Expand Up @@ -684,6 +735,66 @@ components:
$ref: '#/components/schemas/Paging'
summary:
$ref: '#/components/schemas/ListSummary'
CustomAudienceCreate:
type: object
properties:
name:
type: string
description: Name of the custom audience.
description:
type: string
description: Description of the custom audience.
subtype:
type: string
enum:
- CUSTOM
- WEBSITE
- APP
- OFFLINE_CONVERSION
description: The type of custom audience being created.
retention_days:
type: integer
description: The number of days to retain audience members.
rule:
type: string
description: A rule that defines this custom audience.

CustomAudienceResponse:
type: object
properties:
id:
type: string
description: ID of the newly created custom audience.
name:
type: string
description: Name of the custom audience.
description:
type: string
description: Description of the custom audience.
success:
type: boolean
description: Operation status.
CustomAudienceList:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/CustomAudience'
paging:
$ref: '#/components/schemas/Paging'
CustomAudience:
type: object
properties:
id:
type: string
description: ID of the custom audience.
name:
type: string
description: Name of the custom audience.
description:
type: string
description: Description of the custom audience.
Paging:
type: object
properties:
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/functions/component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,13 @@
<file>updateCampaign.xml</file>
<description>Updates a campaign.</description>
</component>
<component name="createCustomAudience">
<file>createCustomAudience.xml</file>
<description>Creates a new custom audience under the specified ad account.</description>
</component>
<component name="getCustomAudiences">
<file>getCustomAudiences.xml</file>
<description>Retrieves custom audiences for an ad account.</description>
</component>
</subComponents>
</component>
76 changes: 76 additions & 0 deletions src/main/resources/functions/createCustomAudience.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com). All Rights Reserved.
~
~ This software is the property of WSO2 LLC. and its suppliers, if any.
~ Dissemination of any information or reproduction of any material contained
~ herein is strictly forbidden, unless permitted by WSO2 in accordance with
~ the WSO2 Software License available at: https://wso2.com/licenses/eula/3.2
~ For specific language governing the permissions and limitations under
~ this license, please see the license as well as any agreement you’ve
~ entered into with WSO2 governing the purchase of this software and any
~ associated services.
-->

<!-- Generated on 03-Thu, 10, 2024 22:01:35+0530 -->

<template xmlns="http://ws.apache.org/ns/synapse" name="createCustomAudience">
<!-- Path Parameter List -->
<parameter name="adAccountId" description="The ID of the ad account."/>
<!-- Request Body Parameter List -->
<parameter name="name" description="Name of the custom audience. Type: string"/>
<parameter name="description" description="Description of the custom audience. Type: string"/>
<parameter name="subtype" description="The type of custom audience being created. Type: string"/>
<parameter name="retentionDays" description="The number of days to retain audience members. Type: integer"/>
<parameter name="rule" description="A rule that defines this custom audience. Type: string"/>
<sequence>
<class name="org.wso2.healthcare.integration.common.ehr.RestURLBuilder">
<property name="operationPath" value="/act_{ad_account_id}/custom_audiences"/>
<property name="pathParameters" value="adAccountId,"/>
</class>
<payloadFactory media-type="json" template-type="freemarker">
<format>
<![CDATA[{
<#if (args.arg1)?has_content>
"name": "${args.arg1}", </#if>
<#if (args.arg2)?has_content>
"description": "${args.arg2}", </#if>
<#if (args.arg3)?has_content>
"subtype": "${args.arg3}", </#if>
<#if (args.arg4)?has_content>
"retention_days": "${args.arg4}", </#if>
<#if (args.arg5)?has_content>
"rule": "${args.arg5}" </#if>
}]]>
</format>
<args>
<arg evaluator="xml" expression="$func:name"/>
<arg evaluator="xml" expression="$func:description"/>
<arg evaluator="xml" expression="$func:subtype"/>
<arg evaluator="xml" expression="$func:retentionDays"/>
<arg evaluator="xml" expression="$func:rule"/>
</args>
</payloadFactory>
<property name="DISABLE_CHUNKING" scope="axis2" type="STRING" value="true"/>
<property name="messageType" value="application/json" scope="axis2"/>
<property name="ContentType" value="application/json" scope="axis2"/>
<call>
<endpoint>
<http method="POST" uri-template="{uri.var.base}{+uri.var.urlPath}{+uri.var.urlQuery}"/>
</endpoint>
</call>
<class name="org.wso2.healthcare.integration.common.ehr.ResponseProcessingHandler"/>

<!-- Remove custom header information -->
<header name="x-business-use-case-usage" scope="transport" action="remove"/>
<header name="facebook-api-version" scope="transport" action="remove"/>
<header name="Strict-Transport-Security" scope="transport" action="remove"/>
<header name="x-fb-request-id" scope="transport" action="remove"/>
<header name="x-fb-trace-id" scope="transport" action="remove"/>
<header name="x-fb-rev" scope="transport" action="remove"/>
<header name="X-FB-Debug" scope="transport" action="remove"/>
<header name="x-fb-server-load" scope="transport" action="remove"/>
<header name="X-FB-Connection-Quality" scope="transport" action="remove"/>
<header name="Alt-Svc" scope="transport" action="remove"/>
</sequence>
</template>
48 changes: 48 additions & 0 deletions src/main/resources/functions/getCustomAudiences.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com). All Rights Reserved.
~
~ This software is the property of WSO2 LLC. and its suppliers, if any.
~ Dissemination of any information or reproduction of any material contained
~ herein is strictly forbidden, unless permitted by WSO2 in accordance with
~ the WSO2 Software License available at: https://wso2.com/licenses/eula/3.2
~ For specific language governing the permissions and limitations under
~ this license, please see the license as well as any agreement you’ve
~ entered into with WSO2 governing the purchase of this software and any
~ associated services.
-->

<!-- Generated on 03-Thu, 10, 2024 22:01:35+0530 -->

<template xmlns="http://ws.apache.org/ns/synapse" name="getCustomAudiences">
<!-- Path Parameter List -->
<parameter name="adAccountId" description="The ID of the ad account."/>
<!-- Query Parameter List -->
<parameter name="fields" description="Comma-separated list of fields to retrieve for each custom audience."/>
<sequence>
<class name="org.wso2.healthcare.integration.common.ehr.RestURLBuilder">
<property name="operationPath" value="/act_{ad_account_id}/custom_audiences"/>
<property name="pathParameters" value="adAccountId,"/>
<property name="queryParameters" value="fields,"/>
</class>
<header name="Accept" value="application/json" scope="transport" action="set"/>
<call>
<endpoint>
<http method="GET" uri-template="{uri.var.base}{+uri.var.urlPath}{+uri.var.urlQuery}"/>
</endpoint>
</call>
<class name="org.wso2.healthcare.integration.common.ehr.ResponseProcessingHandler"/>

<!-- Remove custom header information -->
<header name="x-business-use-case-usage" scope="transport" action="remove"/>
<header name="facebook-api-version" scope="transport" action="remove"/>
<header name="Strict-Transport-Security" scope="transport" action="remove"/>
<header name="x-fb-request-id" scope="transport" action="remove"/>
<header name="x-fb-trace-id" scope="transport" action="remove"/>
<header name="x-fb-rev" scope="transport" action="remove"/>
<header name="X-FB-Debug" scope="transport" action="remove"/>
<header name="x-fb-server-load" scope="transport" action="remove"/>
<header name="X-FB-Connection-Quality" scope="transport" action="remove"/>
<header name="Alt-Svc" scope="transport" action="remove"/>
</sequence>
</template>
Loading

0 comments on commit 2436123

Please sign in to comment.