Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add improvements for FacebookAds Audience Management APIs #9

Merged
merged 9 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions .connector-store/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,131 @@
"rank": 51,
"type": "Connector",
"releases": [
{
"tagName": "v1.1.0",
"products": [
"MI 4.3.0"
],
"operations": [
{
"name":"init",
"description":"Config operation",
"isHidden":true
},
{
"name":"createAd",
"description":"Create an ad.",
"isHidden":false
},
{
"name":"createAdSet",
"description":"Creates an ad set.",
"isHidden":false
},
{
"name":"createCampaign",
"description":"Create a campaign.",
"isHidden":false
},
{
"name":"deleteAd",
"description":"Deletes an ad.",
"isHidden":false
},
{
"name":"deleteAdSet",
"description":"Deletes an ad set.",
"isHidden":false
},
{
"name":"deleteCampaign",
"description":"Deletes a campaign.",
"isHidden":false
},
{
"name":"dissociateCampaign",
"description":"Dissociate a campaign from an AdAccount.",
"isHidden":false
},
{
"name":"getAd",
"description":"Returns data of an ad.",
"isHidden":false
},
{
"name":"getAdSet",
"description":"Return data related to an ad set.",
"isHidden":false
},
{
"name":"getAdSets",
"description":"Returns all ad sets from one ad account.",
"isHidden":false
},
{
"name":"getAds",
"description":"Returns ads under this ad account.",
"isHidden":false
},
{
"name":"getCampaigns",
"description":"Returns campaigns under this ad account.",
"isHidden":false
},
{
"name":"updateAd",
"description":"Updates an ad.",
"isHidden":false
},
{
"name":"updateAdSet",
"description":"Updates an ad set.",
"isHidden":false
},
{
"name":"updateCampaign",
"description":"Updates a campaign.",
"isHidden":false
},
{
"name":"createAdCreative",
"description":"Creates an ad creative.",
"isHidden":false
},
{
"name":"createCustomAudience",
"description":"Creates a custom audience.",
"isHidden":false
},
{
"name":"updateCustomAudience",
"description":"Updates a custom audience.",
"isHidden":false
},
{
"name":"addUsersToAudience",
"description":"Add users to your custom audience.",
"isHidden":false
},
{
"name":"removeUsersFromAudience",
"description":"Remove users from your custom audience.",
"isHidden":false
},
{
"name":"getCustomAudiences",
"description":"Returns all the custom audiences.",
"isHidden":false
}
],
"connections": [
{
"name": "facebookAds",
"description": "Connection for interacting with Facebook Ads."
}
],
"isHidden": false
},
{
"tagName": "v1.0.3",
"products": [
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

| Connector Version | Supported WSO2 MI Version |
|-------------------|---------------------------|
| 1.0.2 | MI 4.3.0 |
| 1.1.0 | MI 4.3.0 |


## Documentation
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<groupId>org.wso2.integration.connector</groupId>
<artifactId>mi-connector-facebookads</artifactId>
<version>1.0.4-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>

<name>WSO2 Carbon - Facebook Ads Connector</name>
<url>http://wso2.org</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
public class Constants {

public static final String PROPERTY_ACCESS_TOKEN = "_FB_ACCESS_TOKEN_";
public static final String HASHED_PAYLOAD = "HASHED_PAYLOAD";
public static final String ACCESS_TOKEN = "access_token";
public static final String PROPERTY_ERROR_CODE = "ERROR_CODE";
public static final String PROPERTY_ERROR_MESSAGE = "ERROR_MESSAGE";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.facebook.ads.connector;

import org.apache.synapse.MessageContext;
import org.apache.synapse.mediators.AbstractMediator;
import org.wso2.carbon.connector.core.util.ConnectorUtils;
import org.json.JSONArray;
import org.json.JSONObject;

public class FacebookDataClassMediator extends AbstractMediator {
public static final String PROPERTIES = "properties";
public static final String INPUT_STRUCTURE = "inputStructure";
public static final String FACEBOOK_API_COMPATIBLE = "FACEBOOK_API_COMPATIBLE";

@Override
public boolean mediate(MessageContext synCtx) {
String inputStructure = (String) ConnectorUtils.lookupTemplateParamater(synCtx, INPUT_STRUCTURE);
String jsonString = (String) ConnectorUtils.lookupTemplateParamater(synCtx, PROPERTIES);

// set the payload as it is for FACEBOOK_API_COMPATIBLE input structure
// executes if the inputStructure is not given or is empty too
if (FACEBOOK_API_COMPATIBLE.equals(inputStructure)
|| inputStructure == null
|| inputStructure.trim().isEmpty()) {
synCtx.setProperty(Constants.HASHED_PAYLOAD, jsonString);
return true;
}

if (jsonString == null || jsonString.isEmpty()) {
return true;
}
JSONArray inputArray = new JSONArray(jsonString);
JSONObject finalObj = FacebookDataProcessor.processData(inputArray);
synCtx.setProperty(Constants.HASHED_PAYLOAD, finalObj.toString());
return true;
}
}
Loading