From 7d621941dfe9087ac9ce9c0b2f0b2c60656add8c Mon Sep 17 00:00:00 2001 From: aashikam Date: Wed, 16 Oct 2024 19:58:01 +0530 Subject: [PATCH 1/2] Add audience management APIs to the spec --- gen_resources/facebook_ads_open_api.yaml | 157 +++++++++++++++++++++++ 1 file changed, 157 insertions(+) diff --git a/gen_resources/facebook_ads_open_api.yaml b/gen_resources/facebook_ads_open_api.yaml index 5780769..6f21ad1 100644 --- a/gen_resources/facebook_ads_open_api.yaml +++ b/gen_resources/facebook_ads_open_api.yaml @@ -16,6 +16,8 @@ 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: Custom Audience + description: Manage custom audiences for ad targeting. security: - ApiKeyAuth: [ ] paths: @@ -129,6 +131,57 @@ paths: application/json: schema: $ref: '#/components/schemas/CustomAudience' + /{custom_audience_id}/users: + post: + tags: + - "Custom Audience" + summary: Add users to a custom audience. + operationId: Add Users to Custom Audience + parameters: + - in: path + name: custom_audience_id + required: true + schema: + type: string + description: The ID of the custom audience. + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CustomAudienceUsersAdd' + responses: + '200': + description: Users added to custom audience successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/CustomAudienceUsersResponse' + delete: + tags: + - "Custom Audience" + summary: Remove users from a custom audience. + operationId: Remove Users from Custom Audience + parameters: + - in: path + name: custom_audience_id + required: true + schema: + type: string + description: The ID of the custom audience. + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CustomAudienceUsersRemove' + responses: + '200': + description: Users removed from custom audience successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/CustomAudienceUsersResponse' /act_{ad_account_id}/campaigns: get: tags: @@ -2366,6 +2419,110 @@ components: lifetime_budget: type: integer description: Lifetime budget + # New schema for adding users to a custom audience + CustomAudienceUsersAdd: + type: object + properties: + payload: + $ref: '#/components/schemas/CustomAudiencePayload' + session: + $ref: '#/components/schemas/CustomAudienceSession' + data_processing_options: + type: array + items: + type: string + description: Data processing options. + data_processing_options_country: + type: integer + description: Data processing options country code. + data_processing_options_state: + type: integer + description: Data processing options state code. + required: + - payload + CustomAudienceUsersRemove: + type: object + properties: + payload: + $ref: '#/components/schemas/CustomAudiencePayload' + required: + - payload + CustomAudienceUsersReplace: + type: object + properties: + payload: + $ref: '#/components/schemas/CustomAudiencePayload' + session: + $ref: '#/components/schemas/CustomAudienceSession' + required: + - payload + - session + CustomAudiencePayload: + type: object + properties: + schema: + oneOf: + - type: string + - type: array + items: + type: string + description: The schema of the user data. Can be a single string or an array of strings for multi-key matching. + data: + type: array + items: + type: array + items: + type: string + description: The user data to be added or removed. + is_raw: + type: boolean + description: Indicates if the data is raw. + page_ids: + type: array + items: + type: string + description: List of page IDs when using PAGEUID. + required: + - schema + - data + CustomAudienceSession: + type: object + properties: + session_id: + type: integer + description: Identifier used to track the session. + batch_seq: + type: integer + description: Sequential number to identify the batch in the current session. + last_batch_flag: + type: boolean + description: Indicates if this is the last batch in the session. + estimated_num_total: + type: integer + description: Estimated total number of users to be uploaded in this session. + required: + - session_id + - batch_seq + CustomAudienceUsersResponse: + type: object + properties: + audience_id: + type: string + description: Audience identifier. + session_id: + type: integer + description: Session ID provided in the request. + num_received: + type: integer + description: Total number of users received in this session so far. + num_invalid_entries: + type: integer + description: Number of entries sent with incorrect hashing or invalid format. + invalid_entry_samples: + type: array + items: + type: string + description: Up to 100 samples of invalid entries found in the current request. securitySchemes: ApiKeyAuth: type: apiKey From 7d4ddf9b7d86c0e004ee90325bbeee1be4b93d29 Mon Sep 17 00:00:00 2001 From: aashikam Date: Wed, 16 Oct 2024 20:13:28 +0530 Subject: [PATCH 2/2] Add audience management APIs --- .connector-store/meta.json | 2 +- README.md | 2 +- gen_resources/config_fb.json | 2 +- gen_resources/facebook_ads_open_api.yaml | 2 +- pom.xml | 2 +- .../ads/connector/RestURLBuilder.java | 1 + .../functions/addUsersToAudience.xml | 60 ++++++++++++++++++ src/main/resources/functions/component.xml | 8 +++ .../functions/removeUsersFromAudience.xml | 60 ++++++++++++++++++ .../uischema/addUsersToAudience.json | 61 +++++++++++++++++++ .../uischema/removeUsersFromAudience.json | 61 +++++++++++++++++++ 11 files changed, 256 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/functions/addUsersToAudience.xml create mode 100644 src/main/resources/functions/removeUsersFromAudience.xml create mode 100644 src/main/resources/uischema/addUsersToAudience.json create mode 100644 src/main/resources/uischema/removeUsersFromAudience.json diff --git a/.connector-store/meta.json b/.connector-store/meta.json index 87edc7b..2f50ae9 100644 --- a/.connector-store/meta.json +++ b/.connector-store/meta.json @@ -7,7 +7,7 @@ "status": "Active", "releases": [ { - "tagName": "v1.0.1", + "tagName": "v1.0.2", "products": [ "MI 4.3.0" ], diff --git a/README.md b/README.md index 503736f..7e461f5 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ | Connector Version | Supported WSO2 MI Version | |-------------------|---------------------------| -| 1.0.1 | MI 4.3.0 | +| 1.0.2 | MI 4.3.0 | ## Documentation diff --git a/gen_resources/config_fb.json b/gen_resources/config_fb.json index a0dc526..3661251 100644 --- a/gen_resources/config_fb.json +++ b/gen_resources/config_fb.json @@ -9,7 +9,7 @@ "project": { "groupId": "org.wso2.carbon.esb.connector", "artifactId": "facebook.ads", - "version": "1.0.1-SNAPSHOT" + "version": "1.0.2-SNAPSHOT" }, "iconFolderPath": "", "mappers": { diff --git a/gen_resources/facebook_ads_open_api.yaml b/gen_resources/facebook_ads_open_api.yaml index 6f21ad1..61f4ddf 100644 --- a/gen_resources/facebook_ads_open_api.yaml +++ b/gen_resources/facebook_ads_open_api.yaml @@ -22,7 +22,7 @@ security: - ApiKeyAuth: [ ] paths: /act_{ad_account_id}/adcreatives: - get: + get: summary: Retrieve a list of ad creatives. operationId: Get Ad Creatives responses: diff --git a/pom.xml b/pom.xml index 1933a93..410fc39 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ org.wso2.carbon.esb.connector facebook.ads - 1.0.1 + 1.0.2 WSO2 Carbon - Facebook Ads Connector http://wso2.org diff --git a/src/main/java/org/wso2/carbon/facebook/ads/connector/RestURLBuilder.java b/src/main/java/org/wso2/carbon/facebook/ads/connector/RestURLBuilder.java index 08e1266..a30495e 100644 --- a/src/main/java/org/wso2/carbon/facebook/ads/connector/RestURLBuilder.java +++ b/src/main/java/org/wso2/carbon/facebook/ads/connector/RestURLBuilder.java @@ -48,6 +48,7 @@ public class RestURLBuilder extends AbstractConnector { put("summary", "summary"); put("objectCount", "object_count"); put("adAccountId", "ad_account_id"); + put("customAudienceId", "custom_audience_id"); put("campaignId", "campaign_id"); put("beforeDate", "before_date"); put("updatedSince", "updated_since"); diff --git a/src/main/resources/functions/addUsersToAudience.xml b/src/main/resources/functions/addUsersToAudience.xml new file mode 100644 index 0000000..045d6d5 --- /dev/null +++ b/src/main/resources/functions/addUsersToAudience.xml @@ -0,0 +1,60 @@ + + + + + diff --git a/src/main/resources/functions/component.xml b/src/main/resources/functions/component.xml index 2410b98..50e7476 100644 --- a/src/main/resources/functions/component.xml +++ b/src/main/resources/functions/component.xml @@ -93,5 +93,13 @@ updateCustomAudience.xml Updates a custom audience. + + addUsersToAudience.xml + Add users to your Custom Audience. + + + removeUsersFromAudience.xml + Remove users from your Custom Audience. + diff --git a/src/main/resources/functions/removeUsersFromAudience.xml b/src/main/resources/functions/removeUsersFromAudience.xml new file mode 100644 index 0000000..8ec06a7 --- /dev/null +++ b/src/main/resources/functions/removeUsersFromAudience.xml @@ -0,0 +1,60 @@ + + + + + diff --git a/src/main/resources/uischema/addUsersToAudience.json b/src/main/resources/uischema/addUsersToAudience.json new file mode 100644 index 0000000..3190dd6 --- /dev/null +++ b/src/main/resources/uischema/addUsersToAudience.json @@ -0,0 +1,61 @@ +{ + "connectorName": "facebookAds", + "operationName": "addUsersToAudience", + "title": "Add Users To Custom Audience", + "help": "This is Add Users to Custom Audience operation.", + "elements": [ + { + "type": "attributeGroup", + "value": { + "groupName": "General", + "elements": [ + { + "type": "attribute", + "value": { + "name": "configRef", + "displayName": "Connection", + "inputType": "connection", + "allowedConnectionTypes": [ + "facebookAds" + ], + "defaultType": "connection.facebookAds", + "defaultValue": "", + "required": "true", + "helpTip": "Connection to be used." + } + }, + { + "type": "attributeGroup", + "value": { + "groupName": "Parameters", + "elements": [ + { + "type": "attribute", + "value": { + "name": "customAudienceId", + "displayName": "Custom Audience Id", + "inputType": "stringOrExpression", + "defaultValue": "", + "required": "true", + "helpTip": "ID of the custom audience." + } + }, + { + "type": "attribute", + "value": { + "name": "properties", + "displayName": "Properties", + "inputType": "stringOrExpression", + "defaultValue": "", + "required": "true", + "helpTip": "Custom audience users properties." + } + } + ] + } + } + ] + } + } + ] +} diff --git a/src/main/resources/uischema/removeUsersFromAudience.json b/src/main/resources/uischema/removeUsersFromAudience.json new file mode 100644 index 0000000..185967d --- /dev/null +++ b/src/main/resources/uischema/removeUsersFromAudience.json @@ -0,0 +1,61 @@ +{ + "connectorName": "facebookAds", + "operationName": "removeUsersFromAudience", + "title": "Remove Users From Custom Audience", + "help": "This is Remove Users from Custom Audience operation.", + "elements": [ + { + "type": "attributeGroup", + "value": { + "groupName": "General", + "elements": [ + { + "type": "attribute", + "value": { + "name": "configRef", + "displayName": "Connection", + "inputType": "connection", + "allowedConnectionTypes": [ + "facebookAds" + ], + "defaultType": "connection.facebookAds", + "defaultValue": "", + "required": "true", + "helpTip": "Connection to be used." + } + }, + { + "type": "attributeGroup", + "value": { + "groupName": "Parameters", + "elements": [ + { + "type": "attribute", + "value": { + "name": "customAudienceId", + "displayName": "Custom audience Id", + "inputType": "stringOrExpression", + "defaultValue": "", + "required": "true", + "helpTip": "ID of the ad set." + } + }, + { + "type": "attribute", + "value": { + "name": "properties", + "displayName": "Properties", + "inputType": "stringOrExpression", + "defaultValue": "", + "required": "true", + "helpTip": "Custom audience users update properties." + } + } + ] + } + } + ] + } + } + ] +}