forked from Bindambc/whatsapp-business-java-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Bindambc#112 from Bindambc/52-new-commerce-setting…
…s-endpoint-api-v160 Commerce Settings Endpoint
- Loading branch information
Showing
8 changed files
with
250 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/main/java/com/whatsapp/api/domain/config/CommerceDataItem.java
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,54 @@ | ||
package com.whatsapp.api.domain.config; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* The type Commerce data item. | ||
* | ||
* <p> | ||
* <li> <b>is_catalog_visible</b> – <i>Optional</i>. Set to true to enable cart and display cart-related buttons in the business phone number's messages, catalogs, and product details. | ||
* Set to false to disable cart. When disabled, customers can see products and their details in messages, but all cart related buttons will not appear in any message view. | ||
* </br> | ||
* <p> | ||
* <li> <b>is_cart_enabled</b> – <i>Optional</i>. Set to true to enable catalog. When enabled, catalog storefront icon and catalog-related buttons appear in the business phone number's messages and business profile. | ||
* Set to false to disable catalog. If disabled, the storefront icon and catalog-related buttons will not appear in any views and the catalog preview with thumbnails will not appear in the business profile view. | ||
* In addition, wa.me links to the business's catalog, as well as the View catalog button that appears when sending catalog links in a message will display an Invalid catalog link warning when tapped. | ||
* <p> | ||
*/ | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class CommerceDataItem { | ||
@JsonProperty("id") | ||
private String id; | ||
|
||
@JsonProperty("is_catalog_visible") | ||
private Boolean isCatalogVisible; | ||
|
||
@JsonProperty("is_cart_enabled") | ||
private Boolean isCartEnabled; | ||
|
||
public CommerceDataItem() { | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public Boolean isCatalogVisible() { | ||
return isCatalogVisible; | ||
} | ||
|
||
public CommerceDataItem setCatalogVisible(Boolean catalogVisible) { | ||
isCatalogVisible = catalogVisible; | ||
return this; | ||
} | ||
|
||
public Boolean isCartEnabled() { | ||
return isCartEnabled; | ||
} | ||
|
||
public CommerceDataItem setCartEnabled(Boolean cartEnabled) { | ||
isCartEnabled = cartEnabled; | ||
return this; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/whatsapp/api/domain/config/GraphCommerceSettings.java
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,14 @@ | ||
package com.whatsapp.api.domain.config; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.List; | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public record GraphCommerceSettings( | ||
|
||
@JsonProperty("data") | ||
List<CommerceDataItem> data | ||
) { | ||
} |
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
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
27 changes: 27 additions & 0 deletions
27
src/test/java/com/whatsapp/api/examples/GetWhatsappCommerceSettingsExample.java
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,27 @@ | ||
package com.whatsapp.api.examples; | ||
|
||
import com.whatsapp.api.WhatsappApiFactory; | ||
import com.whatsapp.api.impl.WhatsappBusinessManagementApi; | ||
|
||
import static com.whatsapp.api.TestConstants.PHONE_NUMBER_ID; | ||
import static com.whatsapp.api.TestConstants.TOKEN; | ||
|
||
public class GetWhatsappCommerceSettingsExample { | ||
|
||
public static void main(String[] args) { | ||
|
||
WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); | ||
|
||
WhatsappBusinessManagementApi whatsappBusinessManagementApi = factory.newBusinessManagementApi(); | ||
//request without parameters | ||
var response = whatsappBusinessManagementApi.getWhatsappCommerceSettings(PHONE_NUMBER_ID); | ||
|
||
System.out.println(response); | ||
|
||
//request with parameters | ||
var response2 = whatsappBusinessManagementApi.getWhatsappCommerceSettings(PHONE_NUMBER_ID, "id", "is_cart_enabled"); | ||
|
||
System.out.println(response2); | ||
|
||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/test/java/com/whatsapp/api/examples/UpdateWhatsappCommerceSettingsExample.java
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,26 @@ | ||
package com.whatsapp.api.examples; | ||
|
||
import com.whatsapp.api.WhatsappApiFactory; | ||
import com.whatsapp.api.domain.config.CommerceDataItem; | ||
import com.whatsapp.api.impl.WhatsappBusinessManagementApi; | ||
|
||
import static com.whatsapp.api.TestConstants.PHONE_NUMBER_ID; | ||
import static com.whatsapp.api.TestConstants.TOKEN; | ||
|
||
public class UpdateWhatsappCommerceSettingsExample { | ||
|
||
public static void main(String[] args) { | ||
|
||
WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); | ||
|
||
WhatsappBusinessManagementApi whatsappBusinessManagementApi = factory.newBusinessManagementApi(); | ||
|
||
CommerceDataItem dataItem = new CommerceDataItem() | ||
.setCatalogVisible(true); | ||
|
||
var response = whatsappBusinessManagementApi.updateWhatsappCommerceSettings(PHONE_NUMBER_ID, dataItem); | ||
|
||
System.out.println(response); | ||
|
||
} | ||
} |
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
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,9 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"is_cart_enabled": true, | ||
"is_catalog_visible": true, | ||
"id": "1001185490903808" | ||
} | ||
] | ||
} |