From 061172031d7f247065b012cbffac8099409d5143 Mon Sep 17 00:00:00 2001 From: Aliza Solomon <44541615+alizas1@users.noreply.github.com> Date: Wed, 11 Jun 2025 14:58:20 +0300 Subject: [PATCH 1/5] Update QueryVsSearch.md --- guides/QueryVsSearch.md | 1 + 1 file changed, 1 insertion(+) diff --git a/guides/QueryVsSearch.md b/guides/QueryVsSearch.md index fa005d6512..cdbbd2744e 100644 --- a/guides/QueryVsSearch.md +++ b/guides/QueryVsSearch.md @@ -8,6 +8,7 @@ All three methods retrieve collections of items, but they're optimized for diffe * **Query methods** are designed for efficient, low-latency data retrieval with predictable filtering and sorting capabilities. * **List methods** provide simple, straightforward access to collections with basic pagination options. Generally only avaialable for collections that are limited in size. +> **Note:** The Wix Data Items API has a dedicated Aggregate method, XXX. ## Key differences From f3c929a2b3520114f30456e3e0909fcd4dfe3568 Mon Sep 17 00:00:00 2001 From: Aliza Solomon <44541615+alizas1@users.noreply.github.com> Date: Thu, 12 Jun 2025 10:52:24 +0300 Subject: [PATCH 2/5] Update QueryVsSearch.md --- guides/QueryVsSearch.md | 91 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 2 deletions(-) diff --git a/guides/QueryVsSearch.md b/guides/QueryVsSearch.md index cdbbd2744e..9688dfa3ba 100644 --- a/guides/QueryVsSearch.md +++ b/guides/QueryVsSearch.md @@ -8,7 +8,7 @@ All three methods retrieve collections of items, but they're optimized for diffe * **Query methods** are designed for efficient, low-latency data retrieval with predictable filtering and sorting capabilities. * **List methods** provide simple, straightforward access to collections with basic pagination options. Generally only avaialable for collections that are limited in size. -> **Note:** The Wix Data Items API has a dedicated Aggregate method, XXX. +> **Note:** The Wix Data Items API has a dedicated Aggregate method. ## Key differences @@ -106,6 +106,8 @@ These examples illustrate common applications for both methods in the [Payment L A business may want to identify all test payment links and check what types of tests were run. +::::tabs +:::REST Example ``` curl -X POST \ 'https://www.wixapis.com/payment-links/v1/payment-links/search' \ @@ -139,11 +141,51 @@ curl -X POST \ } }' ``` +::: +:::SDK Example +``` +async function searchPaymentLinks() { + try { + const response = await myWixClient.paymentLinks.searchPaymentLinks({ + search: { + sort: [ + { + fieldName: "createdDate", + order: "DESC" + } + ], + aggregations: [ + { + name: "statuses", + type: "VALUE", + fieldPath: "status", + value: { + sortType: "COUNT" + } + } + ], + search: { + fuzzy: true, + expression: "Test", + fields: [ + "title" + ] + } + } + }); +``` +::: +:::: + + ### Query example: Retrieve a list of payment links filtered by price and sorted by creation date A business may want to review all payment links for premium offerings to ensure the most recent links reflect current marketing strategies. You can retrieve a list of payment links filtered by a specific price range and sorted chronologically by creation date with the following call: + +::::tabs +:::REST Example ``` curl -X POST \ 'https://www.wixapis.com/payment-links/v1/payment-links/query' \ @@ -168,13 +210,58 @@ curl -X POST \ } }' ``` +::: +:::SDK Example +``` +async function queryPaymentLinks() { + try { + const results = await myWixClient.queryPaymentLinks({ + query: { + filter: { + price: { + $gt: 100 + } + }, + sort: [ + { + fieldName: "createdDate", + order: "DESC" + } + ], + cursorPaging: { + limit: 1 + } + } + }); +``` +::: +:::: + ### List example: Retrieving all payment links with basic pagination -A business needs to display a list of all their payment links in a dashboard with page navigation. +A business needs to display a list of all their payment links in a dashboard with page navigation. If the Payment Links API included a List call, it would look like the example below. +::::tabs +:::REST Example ``` curl -X GET \ 'https://www.wixapis.com/payment-links/v1/payment-links?limit=10&offset=0' \ -H 'Authorization: ' ``` +::: +:::SDK Example +``` +async function getPaymentLinks() { + try { + const response = await paymentLinksService.queryPaymentLinks({ + query: { + paging: { + limit: 10, + offset: 0 + } + } + }); +``` +::: +:::: From e1d691db1acaea84986d47d9e617acd8c7a1bd9d Mon Sep 17 00:00:00 2001 From: Aliza Solomon <44541615+alizas1@users.noreply.github.com> Date: Thu, 12 Jun 2025 10:54:22 +0300 Subject: [PATCH 3/5] Update QueryVsSearch.md --- guides/QueryVsSearch.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/guides/QueryVsSearch.md b/guides/QueryVsSearch.md index 9688dfa3ba..09afb78162 100644 --- a/guides/QueryVsSearch.md +++ b/guides/QueryVsSearch.md @@ -107,7 +107,7 @@ These examples illustrate common applications for both methods in the [Payment L A business may want to identify all test payment links and check what types of tests were run. ::::tabs -:::REST Example +:::REST_TAB ``` curl -X POST \ 'https://www.wixapis.com/payment-links/v1/payment-links/search' \ @@ -142,7 +142,7 @@ curl -X POST \ }' ``` ::: -:::SDK Example +:::SDK_TAB ``` async function searchPaymentLinks() { try { @@ -185,7 +185,7 @@ A business may want to review all payment links for premium offerings to ensure You can retrieve a list of payment links filtered by a specific price range and sorted chronologically by creation date with the following call: ::::tabs -:::REST Example +:::REST_TAB ``` curl -X POST \ 'https://www.wixapis.com/payment-links/v1/payment-links/query' \ @@ -211,7 +211,7 @@ curl -X POST \ }' ``` ::: -:::SDK Example +:::SDK_TAB ``` async function queryPaymentLinks() { try { @@ -243,14 +243,14 @@ async function queryPaymentLinks() { A business needs to display a list of all their payment links in a dashboard with page navigation. If the Payment Links API included a List call, it would look like the example below. ::::tabs -:::REST Example +:::REST_TAB ``` curl -X GET \ 'https://www.wixapis.com/payment-links/v1/payment-links?limit=10&offset=0' \ -H 'Authorization: ' ``` ::: -:::SDK Example +:::SDK_TAB ``` async function getPaymentLinks() { try { From 8ad90398bf6363d7da81820c84d85da8e18cbdd9 Mon Sep 17 00:00:00 2001 From: Aliza Solomon <44541615+alizas1@users.noreply.github.com> Date: Thu, 26 Jun 2025 11:01:42 +0300 Subject: [PATCH 4/5] Update QueryVsSearch.md --- guides/QueryVsSearch.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/guides/QueryVsSearch.md b/guides/QueryVsSearch.md index 09afb78162..2fb487ae6f 100644 --- a/guides/QueryVsSearch.md +++ b/guides/QueryVsSearch.md @@ -144,11 +144,12 @@ curl -X POST \ ::: :::SDK_TAB ``` -async function searchPaymentLinks() { +import { paymentLinks } from "@wix/get-paid"; + +export async function searchPaymentLinks() { try { - const response = await myWixClient.paymentLinks.searchPaymentLinks({ - search: { - sort: [ + const response = await paymentLinks.searchPaymentLinks({ + sort: [ { fieldName: "createdDate", order: "DESC" @@ -170,9 +171,14 @@ async function searchPaymentLinks() { fields: [ "title" ] - } - } - }); + }, + }) + return response + }, catch (error) { + console.error(error); + }, + }; + ``` ::: :::: From 1384c0f7553ef1c7f75889f3822dc285c16bf629 Mon Sep 17 00:00:00 2001 From: Aliza Solomon <44541615+alizas1@users.noreply.github.com> Date: Thu, 3 Jul 2025 13:34:07 +0300 Subject: [PATCH 5/5] Update QueryVsSearch.md --- guides/QueryVsSearch.md | 100 ++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 51 deletions(-) diff --git a/guides/QueryVsSearch.md b/guides/QueryVsSearch.md index 2fb487ae6f..ed896ccc48 100644 --- a/guides/QueryVsSearch.md +++ b/guides/QueryVsSearch.md @@ -102,15 +102,15 @@ When choosing between search, query, and list methods for your data retrieval ne ## Example use cases These examples illustrate common applications for both methods in the [Payment Links API](https://dev.wix.com/docs/rest/business-management/get-paid/payment-links/payment-links/introduction). -### Search example: Finding payment links containing "test" with aggregated counts by status +### Search example: Finding Loyalty accounts containing "test" in the contact email address with aggregated counts by points balance -A business may want to identify all test payment links and check what types of tests were run. +A business may want to identify all test loyalty accounts and check their point balances, sorted by latest created date. ::::tabs :::REST_TAB ``` curl -X POST \ - 'https://www.wixapis.com/payment-links/v1/payment-links/search' \ + 'https://www.wixapis.com/loyalty-accounts/v1/accounts/search' \ -H 'Authorization: ' \ -H 'Content-Type: application/json' \ --data-binary '{ @@ -123,9 +123,9 @@ curl -X POST \ ], "aggregations": [ { - "name": "statuses", + "name": "balances", "type": "VALUE", - "fieldPath": "status", + "fieldPath": "points.balance", "value": { "sortType": "COUNT" } @@ -133,9 +133,9 @@ curl -X POST \ ], "search": { "fuzzy": true, - "expression": "Test", + "expression": "test", "fields": [ - "title" + "contact.email" ] } } @@ -144,11 +144,11 @@ curl -X POST \ ::: :::SDK_TAB ``` -import { paymentLinks } from "@wix/get-paid"; +import { accounts } from "@wix/loyalty"; -export async function searchPaymentLinks() { +export async function searchAccounts() { try { - const response = await paymentLinks.searchPaymentLinks({ + const response = await loyalty.searchAccounts({ sort: [ { fieldName: "createdDate", @@ -157,9 +157,9 @@ export async function searchPaymentLinks() { ], aggregations: [ { - name: "statuses", + name: "balances", type: "VALUE", - fieldPath: "status", + fieldPath: "points.balance", value: { sortType: "COUNT" } @@ -167,9 +167,9 @@ export async function searchPaymentLinks() { ], search: { fuzzy: true, - expression: "Test", + expression: "test", fields: [ - "title" + "contact.email" ] }, }) @@ -186,21 +186,21 @@ export async function searchPaymentLinks() { -### Query example: Retrieve a list of payment links filtered by price and sorted by creation date -A business may want to review all payment links for premium offerings to ensure the most recent links reflect current marketing strategies. -You can retrieve a list of payment links filtered by a specific price range and sorted chronologically by creation date with the following call: +### Query example: Retrieve a list of Loyalty accounts filtered by points balances +A business may want to review all Loyalty accounts and their current balance to send reminders to customers with high balances about ways to use their points. +You can retrieve a list of Loyalty accounts filtered by a specific points balance range and sorted chronologically by creation date with the following call: ::::tabs :::REST_TAB ``` curl -X POST \ - 'https://www.wixapis.com/payment-links/v1/payment-links/query' \ + 'https://www.wixapis.com/loyalty-accounts/v1/accounts/query' \ -H 'Authorization: ' \ -H 'Content-Type: application/json' \ --data-binary '{ "query": { "filter": { - "price": { + "points.balance": { "$gt": 100, } }, @@ -219,55 +219,53 @@ curl -X POST \ ::: :::SDK_TAB ``` -async function queryPaymentLinks() { - try { - const results = await myWixClient.queryPaymentLinks({ - query: { - filter: { - price: { - $gt: 100 - } - }, - sort: [ - { - fieldName: "createdDate", - order: "DESC" - } - ], - cursorPaging: { - limit: 1 - } - } - }); +import { accounts } from "@wix/loyalty"; + +async function queryLoyaltyAccounts() { + const { items } = await loyalty.queryLoyaltyAccounts().gt("points.balance", 100).descending("createdDate").find(); +} ``` ::: :::: -### List example: Retrieving all payment links with basic pagination +### List example: Retrieving Loyalty accounts for specific customers with basic pagination -A business needs to display a list of all their payment links in a dashboard with page navigation. If the Payment Links API included a List call, it would look like the example below. +A business needs to access a list of specific Loyalty accounts in a dashboard with page navigation. +You can retrieve a list of specified Loyalty accounts with the deprecated List Accounts method. ::::tabs :::REST_TAB ``` curl -X GET \ - 'https://www.wixapis.com/payment-links/v1/payment-links?limit=10&offset=0' \ + 'https://www.wixapis.com/loyalty-accounts/v1/accountscontactIds[]=88615e02-3e8a-4297-8939-5d0a432b322a&contactIds[]=fb8f125e-bfc3-4d9a-80c2-215494f24731' \ -H 'Authorization: ' ``` ::: :::SDK_TAB ``` -async function getPaymentLinks() { +import { accounts } from "@wix/loyalty"; + +export async function myListLoyaltyAccountsFunction() { try { - const response = await paymentLinksService.queryPaymentLinks({ - query: { - paging: { - limit: 10, - offset: 0 - } - } - }); + const accountsList = await accounts.listAccounts(options); + + const firstAccountId = accountsList.accounts[0]._id; + const firstAccountBalance = accountsList.accounts[0].points.balance; + + console.log( + "Success! The ID and point balance for the first account in your list is: ", + firstAccountId, + " and ", + firstAccountBalance, + ); + + return accountsList; + } catch (error) { + console.error(error); + } +} + ``` ::: ::::