### Get Customer Example Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/CustomersApi.md Demonstrates how to initialize the ApiClient, configure authentication with API keys, and retrieve customer details using the CustomersApi. ```java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.CustomersApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); CustomersApi apiInstance = new CustomersApi(defaultClient); String customerId = "customerId_example"; // String | A Voucherify customers id or source_id. try { CustomersGetResponseBody result = apiInstance.getCustomer(customerId); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling CustomersApi#getCustomer"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Voucherify Java SDK Async Actions Example Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/AsyncActionsApi.md Example Java code demonstrating how to use the Voucherify Java SDK to interact with the Async Actions API, including setting up the client, authentication, and making calls to get and list async actions. ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.AsyncActionsApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); AsyncActionsApi apiInstance = new AsyncActionsApi(defaultClient); // Example for getAsyncAction String asyncActionId = "asyncActionId_example"; // String | Unique ID of the asynchronous operation. try { AsyncActionGetResponseBody result = apiInstance.getAsyncAction(asyncActionId); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling AsyncActionsApi#getAsyncAction"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } // Example for listAsyncActions Integer limit = 56; // Integer | Limit the number of asynchronous actions that the API returns in the response. OffsetDateTime endDate = OffsetDateTime.now(); // OffsetDateTime | Limits results to actions scheduled before the end_date. The date format needs to be consistent with ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). try { AsyncActionsListResponseBody result = apiInstance.listAsyncActions(limit, endDate); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling AsyncActionsApi#listAsyncActions"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Java SDK Example: Get Campaign Template Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/TemplatesApi.md Example of how to use the Voucherify Java SDK to retrieve a campaign template. It demonstrates setting up the API client, configuring authentication, and handling the API call and potential exceptions. ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.TemplatesApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); TemplatesApi apiInstance = new TemplatesApi(defaultClient); String campaignTemplateId = "campaignTemplateId_example"; // String | Pass the campaign template ID that was assigned by Voucherify. try { TemplatesCampaignsGetResponseBody result = apiInstance.getCampaignTemplate(campaignTemplateId); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling TemplatesApi#getCampaignTemplate"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Get Promotion Stack - Java SDK Example Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/PromotionsApi.md Example of how to retrieve promotion stack details using the Voucherify Java SDK. It shows how to initialize the client, authenticate, and call the getPromotionStack method with campaign and stack IDs. ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.PromotionsApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); PromotionsApi apiInstance = new PromotionsApi(defaultClient); String campaignId = "campaignId_example"; // String | ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. String stackId = "stackId_example"; // String | Promotion stack ID. try { PromotionsStacksGetResponseBody result = apiInstance.getPromotionStack(campaignId, stackId); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling PromotionsApi#getPromotionStack"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Create Order Example Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/OrdersApi.md Example of how to create an order using the OrdersApi in Java. Demonstrates API client configuration, authentication, and making the createOrder call. ```java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.OrdersApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); OrdersApi apiInstance = new OrdersApi(defaultClient); OrdersCreateRequestBody ordersCreateRequestBody = new OrdersCreateRequestBody(); // OrdersCreateRequestBody | Specify the order parameters. try { OrdersCreateResponseBody result = apiInstance.createOrder(ordersCreateRequestBody); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling OrdersApi#createOrder"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Manual JAR Installation Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/README.md Builds the JAR for the SDK and manually installs it along with its dependencies. ```Shell mvn clean package ``` -------------------------------- ### Maven Installation Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/README.md Installs the Voucherify Java SDK to your local Maven repository. ```Shell mvn clean install ``` -------------------------------- ### Enable Voucher Java Example Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/VouchersApi.md Example code demonstrating how to enable a voucher using the Voucherify Java SDK. It covers API client configuration, authentication, and error handling. ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.VouchersApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); VouchersApi apiInstance = new VouchersApi(defaultClient); String code = "code_example"; // String | A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. try { VouchersEnableResponseBody result = apiInstance.enableVoucher(code); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling VouchersApi#enableVoucher"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Enable Promotion Tier - Java SDK Example Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/PromotionsApi.md Example of how to enable a promotion tier using the Voucherify Java SDK. It demonstrates setting up the API client, authentication, and calling the enablePromotionTier method. ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.PromotionsApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); PromotionsApi apiInstance = new PromotionsApi(defaultClient); String promotionTierId = "promotionTierId_example"; // String | Unique promotion tier ID. try { PromotionsTiersEnableResponseBody result = apiInstance.enablePromotionTier(promotionTierId); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling PromotionsApi#enablePromotionTier"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Java SDK Example: Update Campaign Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/CampaignsApi.md Demonstrates how to use the Voucherify Java SDK to update a campaign. It covers API client configuration, authentication, and calling the `updateCampaign` method with example parameters. ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.CampaignsApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); CampaignsApi apiInstance = new CampaignsApi(defaultClient); String campaignId = "campaignId_example"; // String | You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. CampaignsUpdateRequestBody campaignsUpdateRequestBody = new CampaignsUpdateRequestBody(); // CampaignsUpdateRequestBody | Specify the campaign parameters to be updated. try { CampaignsUpdateResponseBody result = apiInstance.updateCampaign(campaignId, campaignsUpdateRequestBody); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling CampaignsApi#updateCampaign"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Voucherify Java SDK Example Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/README.md Demonstrates how to initialize the Voucherify Java SDK, configure API keys, and make a call to retrieve an asynchronous action. ```Java // Import classes: import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.AsyncActionsApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR X-App-Id"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR X-App-Token"); AsyncActionsApi apiInstance = new AsyncActionsApi(defaultClient); String asyncActionId = "asyncActionId_example"; // String | Unique ID of the asynchronous operation. try { AsyncActionGetResponseBody result = apiInstance.getAsyncAction(asyncActionId) System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling AsyncActionsApi#getAsyncAction"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Get Redemption Example Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/RedemptionsApi.md Example of how to use the getRedemption method from the RedemptionsApi to retrieve a specific redemption object using its ID. ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.RedemptionsApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); RedemptionsApi apiInstance = new RedemptionsApi(defaultClient); String redemptionId = "redemptionId_example"; // String | ID of previously created redemption. try { RedemptionsGetResponseBody result = apiInstance.getRedemption(redemptionId); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling RedemptionsApi#getRedemption"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Get Voucher Redemptions Example Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/RedemptionsApi.md Example of how to use the getVoucherRedemptions method from the RedemptionsApi to retrieve redemption details for a specific voucher using its code. ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.RedemptionsApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); RedemptionsApi apiInstance = new RedemptionsApi(defaultClient); String code = "code_example"; // String | A **code** that identifies the voucher. try { VouchersRedemptionGetResponseBody result = apiInstance.getVoucherRedemptions(code); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling RedemptionsApi#getVoucherRedemptions"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Create Product Example Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/ProductsApi.md Demonstrates how to create a product using the Voucherify Java SDK. This includes setting up the API client, configuring authentication, creating a product request body, and handling the API response or exceptions. ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.ProductsApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); ProductsApi apiInstance = new ProductsApi(defaultClient); ProductsCreateRequestBody productsCreateRequestBody = new ProductsCreateRequestBody(); // ProductsCreateRequestBody | Specify the product parameters. try { ProductsCreateResponseBody result = apiInstance.createProduct(productsCreateRequestBody); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling ProductsApi#createProduct"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Get Metadata Schema Example Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/MetadataSchemasApi.md Example of how to use the getMetadataSchema method from the MetadataSchemasApi in the Voucherify Java SDK. Demonstrates API client configuration, authentication, and error handling. ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.MetadataSchemasApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); MetadataSchemasApi apiInstance = new MetadataSchemasApi(defaultClient); String resource = "resource_example"; // String | There is an infinite number of possibilities for retrieving metadata schemas by the resource type because you can define custom metadata schemas. try { MetadataSchemasGetResponseBody result = apiInstance.getMetadataSchema(resource); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling MetadataSchemasApi#getMetadataSchema"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Voucherify Java SDK Example Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/ProductsApi.md Example Java code demonstrating how to use the Voucherify Java SDK to interact with the API, including authentication and making calls to retrieve SKU details and import products. ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.ProductsApi; import java.io.File; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); ProductsApi apiInstance = new ProductsApi(defaultClient); String skuId = "skuId_example"; // String | A Voucherify SKU identifier or SKU source ID. try { SkusGetResponseBody result = apiInstance.getSku(skuId); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling ProductsApi#getSku"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } File _file = new File("/path/to/file"); // File | File path. try { ProductsImportCsvCreateResponseBody result = apiInstance.importProductsUsingCsv(_file); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling ProductsApi#importProductsUsingCsv"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Track Custom Event Example - Java Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/EventsApi.md A Java code example demonstrating how to use the Voucherify Java SDK to track a custom event. It shows the setup of the API client, configuration of authentication, instantiation of the EventsApi, creation of the request body, and handling of the API response or exceptions. ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.EventsApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); EventsApi apiInstance = new EventsApi(defaultClient); EventsCreateRequestBody eventsCreateRequestBody = new EventsCreateRequestBody(); // EventsCreateRequestBody | Specify the details of the custom event. try { EventsCreateResponseBody result = apiInstance.trackCustomEvent(eventsCreateRequestBody); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling EventsApi#trackCustomEvent"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Get Reward - Java Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/RewardsApi.md Shows how to retrieve details of a specific reward using its ID with the Voucherify Java SDK. Includes setup for authentication and error handling. ```java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.RewardsApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); RewardsApi apiInstance = new RewardsApi(defaultClient); String rewardId = "rewardId_example"; // String | A unique reward ID. try { Reward result = apiInstance.getReward(rewardId); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling RewardsApi#getReward"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Create SKU Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/ProductsApi.md Demonstrates how to create a SKU for a product using the Voucherify Java SDK. It includes setting up the API client, authentication, and making the API call to create the SKU. ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.ProductsApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); ProductsApi apiInstance = new ProductsApi(defaultClient); String productId = "productId_example"; // String | A Voucherify product ID or product source ID. ProductsSkusCreateRequestBody productsSkusCreateRequestBody = new ProductsSkusCreateRequestBody(); // ProductsSkusCreateRequestBody | Specify the SKU parameters to be created. try { ProductsSkusCreateResponseBody result = apiInstance.createSku(productId, productsSkusCreateRequestBody); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling ProductsApi#createSku"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Get Webhook Configuration Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/ManagementApi.md Retrieves a specific webhook configuration for a project. Requires project and webhook identifiers. Includes setup for API key authentication and error handling. ```APIDOC # getWebhook > ManagementProjectsWebhooksGetResponseBody getWebhook(projectId, webhookId) Get Webhook Retrieves a webhook configuration. 📘 Webhook Documentation Read Webhooks v2024-01-1 article to learn how webhooks work in Voucherify. ### Parameters | Name | Type | Description | |-------------|-------------|-------------|| | **projectId** | **String**| Provide the unique identifier of the project. | | **webhookId** | **String**| Provide the unique identifier of the webhook configuration. | ### Return type [**ManagementProjectsWebhooksGetResponseBody**](ManagementProjectsWebhooksGetResponseBody.md) ### Authorization [X-Management-Token](../README.md#X-Management-Token), [X-Management-Id](../README.md#X-Management-Id) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------|| | **200** | Returns the stacking rules for the project. | - | ``` ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.ManagementApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-Management-Token defaultClient.setAuthentication("X-Management-Token", "YOUR API KEY"); // Configure API key authorization: X-Management-Id defaultClient.setAuthentication("X-Management-Id", "YOUR API KEY"); ManagementApi apiInstance = new ManagementApi(defaultClient); String projectId = "projectId_example"; // String | Provide the unique identifier of the project. String webhookId = "webhookId_example"; // String | Provide the unique identifier of the webhook configuration. try { ManagementProjectsWebhooksGetResponseBody result = apiInstance.getWebhook(projectId, webhookId); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling ManagementApi#getWebhook"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Delete Reward Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/RewardsApi.md Provides an example of how to delete a reward using its ID with the Voucherify Java SDK. It covers API client setup, authentication, and error handling for the deletion process. ```java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.RewardsApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); RewardsApi apiInstance = new RewardsApi(defaultClient); String rewardId = "rewardId_example"; // String | A unique reward ID. try { apiInstance.deleteReward(rewardId); } catch (ApiException e) { System.err.println("Exception when calling RewardsApi#deleteReward"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### List Products with Voucherify Java SDK Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/ProductsApi.md Demonstrates how to initialize the Voucherify Java SDK, configure API key authentication, and call the `listProducts` method to retrieve a list of products. It includes parameters for limiting results, pagination, sorting, and date filtering. Error handling for API exceptions is also shown. ```java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.ProductsApi; import java.time.OffsetDateTime; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); ProductsApi apiInstance = new ProductsApi(defaultClient); Integer limit = 56; // Limits the number of objects to be returned. The limit can range between 1 and 100 items. If no limit is set, it returns 10 items. Integer page = 56; // Which page of results to return. The lowest value is 1. ParameterOrder order = ParameterOrder.fromValue("created_at"); // Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. OffsetDateTime startDate = OffsetDateTime.now(); // Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. OffsetDateTime endDate = OffsetDateTime.now(); // Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. try { ProductsListResponseBody result = apiInstance.listProducts(limit, page, order, startDate, endDate); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling ProductsApi#listProducts"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Delete Customer (Java) Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/CustomersApi.md Provides an example of deleting a customer using the Voucherify Java SDK. This method handles the API client setup, authentication, and error handling for the deletion process. ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.CustomersApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); CustomersApi apiInstance = new CustomersApi(defaultClient); String customerId = "customerId_example"; // String | A Voucherify customers id or source_id. try { apiInstance.deleteCustomer(customerId); } catch (ApiException e) { System.err.println("Exception when calling CustomersApi#deleteCustomer"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Voucherify Java SDK Authorization Setup Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/README.md Demonstrates how to set up the ApiClient for authorization with Voucherify using an API key. This includes setting the base path and authentication credentials (X-App-Id and X-App-Token). ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.Configuration; import io.voucherify.client.auth.ApiKeyAuth; public class Main { public static ApiClient getClient() { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); defaultClient.setAuthentication("X-App-Id", "YOUR_X_APP_ID"); defaultClient.setAuthentication("X-App-Token", "YOUR_X_APP_TOKEN"); return defaultClient; } } ``` -------------------------------- ### Java SDK Example: Create Publication Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/PublicationsApi.md Example of how to use the Voucherify Java SDK to create a publication. This code demonstrates setting up the API client, configuring authentication, and calling the `createPublication1` method with sample parameters. It also includes error handling for API exceptions. ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.PublicationsApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-App-Id defaultClient.setAuthentication("X-App-Id", "YOUR API KEY"); // Configure API key authorization: X-App-Token defaultClient.setAuthentication("X-App-Token", "YOUR API KEY"); PublicationsApi apiInstance = new PublicationsApi(defaultClient); Customer customer = new Customer(); // Customer | Contains information about the customer to whom the publication was directed. Boolean joinOnce = true; // Boolean | Through this flag, you can control if a particular person gets only one and always the same code even if the app sends multiple publication requests. It means that if you have a referral program, a referrer is assigned only to one code if an integration sends publication requests more than once for the same customer. String voucher = "voucher_example"; // String | Code of voucher being published. CreatePublicationCampaign campaign = new CreatePublicationCampaign(); // CreatePublicationCampaign | Create publication with campaign. String sourceId = "sourceId_example"; // String | The merchants publication ID if it is different from the Voucherify publication ID. Its an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. If source_id is provided only 1 voucher can be published per request. Object metadata = null; // Object | The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. try { PublicationsCreateResponseBody result = apiInstance.createPublication1(customer, joinOnce, voucher, campaign, sourceId, metadata); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling PublicationsApi#createPublication1"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Get Project User Details Source: https://github.com/voucherifyio/voucherify-java-sdk/blob/master/docs/ManagementApi.md Retrieves the details of a specific user within a project. Requires project and user identifiers. Includes setup for API key authentication and error handling. ```APIDOC # getUser > ManagementProjectsUsersGetUserResponseBody getUser(projectId, userId) Get User Retrieves the project users details. ### Parameters | Name | Type | Description | |-------------|-------------|-------------|| | **projectId** | **String**| Provide the unique identifier of the project. | | **userId** | **String**| Provide the unique identifier of the user. Alternatively, provide the users login. | ### Return type [**ManagementProjectsUsersGetUserResponseBody**](ManagementProjectsUsersGetUserResponseBody.md) ### Authorization [X-Management-Token](../README.md#X-Management-Token), [X-Management-Id](../README.md#X-Management-Id) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------|| | **200** | Returns the project user's details. | - | ``` ```Java import io.voucherify.client.ApiClient; import io.voucherify.client.ApiException; import io.voucherify.client.Configuration; import io.voucherify.client.auth.*; import io.voucherify.client.models.*; import io.voucherify.client.api.ManagementApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.voucherify.io"); // Configure API key authorization: X-Management-Token defaultClient.setAuthentication("X-Management-Token", "YOUR API KEY"); // Configure API key authorization: X-Management-Id defaultClient.setAuthentication("X-Management-Id", "YOUR API KEY"); ManagementApi apiInstance = new ManagementApi(defaultClient); String projectId = "projectId_example"; // String | Provide the unique identifier of the project. String userId = "userId_example"; // String | Provide the unique identifier of the user. Alternatively, provide the users login. try { ManagementProjectsUsersGetUserResponseBody result = apiInstance.getUser(projectId, userId); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling ManagementApi#getUser"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ```