Skip to content

voucherifyio/sdk-java-openapi-based

Repository files navigation

Voucherify Java SDK

Official Voucherify SDK for Java

Voucherify empowers marketers and developers with flexible building blocks to come up with, implement, and track targeted promotional campaigns.

Learn more about Voucherify by visiting our site.

This SDK is automatically generated by the OpenAPI Generator based on our Documentation with v2018-08-01 version.

The legacy version of Java SDK could be found here

📝 Documentation

You will find detailed description and example responses at our official documentation. Most method headers point to more detailed descriptions of arguments you can use.

📚 Want to learn more? Visit our official site or our Success Portal.

👽 Having troubles? Check our Help center.

🧪 Looking for promotion ideas? Check our Cookbook to get an inspiration.

🐛 Encounter a bug? Please file a report in the Issues.

✅ Supported endpoint can be found here

Requirements

Building the API client library requires:

  1. Java 1.8+
  2. Maven (3.8.3+)/Gradle (7.2+)

Installation

To install the API client library to your local Maven repository, simply execute:

mvn clean install

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

mvn clean deploy

Refer to the OSSRH Guide for more information.

Maven users

Add this dependency to your project's POM:

<dependency>
  <groupId>io.voucherify.client</groupId>
  <artifactId>voucherify-java-sdk</artifactId>
  <version>12.0.0</version>
  <scope>compile</scope>
</dependency>

Gradle users

Add this dependency to your project's build file:

  repositories {
    mavenCentral()
  }

  dependencies {
     implementation "io.voucherify.client:voucherify-java-sdk:12.0.0"
  }

Others

At first generate the JAR by executing:

mvn clean package

Then manually install the following JARs:

  • target/voucherify-java-sdk-12.0.0.jar
  • target/lib/*.jar

🚀 Running code

Please follow the installation instruction and execute the following Java code:

// 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.CampaignsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://us1.api.voucherify.io"); //(defaults to "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 | The campaign ID or name of the campaign to which voucher will be added. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value.
        String code = "code_example"; // String | A custom **code** that identifies the voucher.
        CampaignsVouchersCreateRequestBody campaignsVouchersCreateRequestBody = new CampaignsVouchersCreateRequestBody(); // CampaignsVouchersCreateRequestBody | Specify the voucher parameters that you would like to overwrite.
        try {
            CampaignsVouchersCreateResponseBody result = apiInstance.addVoucherWithSpecificCodeToCampaign(campaignId, code, campaignsVouchersCreateRequestBody);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling CampaignsApi#addVoucherWithSpecificCodeToCampaign");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

It may be useful to check the test implementation in the folder test (./src/test)

🐳 Running local tests with docker

  1. Copy .env.example to .env and fill in the values.
  2. Run docker build -t java . to build the image.
  3. Run docker run --rm java to run the tests and delete container immediately after.

🛠️ Contributing

Read more about how to Contribute to Voucherify Java SDK by visiting main repo GENERATING-SDKS.md

Remember that this SDK is auto generated (except of the tests) so changes made here will be overwritten by generator.

📅 Changelog

  • 2024-07-12 - 12.0.0 - The new version of the SKD includes coverage for all the most commonly used Voucherify endpoints and supports typed models.

Previous versions of the API are no longer supported, and we highly recommend upgrading to version 12.0.0, which is now designated as Long-Term Support (LTS).

Changelog for previous versions could be found in the CHANGELOG.md file

🔐 Documentation for Authorization

// Setup ApiClient Authorization:

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;
    }
}

Documentation for API Endpoints

All URIs are relative to https://api.voucherify.io

Class Method HTTP request Description
CampaignsApi addVoucherWithSpecificCodeToCampaign POST /v1/campaigns/{campaignId}/vouchers/{code} Add Voucher with Specific Code to Campaign
CampaignsApi addVouchersToCampaign POST /v1/campaigns/{campaignId}/vouchers Add Vouchers to Campaign
CampaignsApi createCampaign POST /v1/campaigns Create Campaign
CampaignsApi deleteCampaign DELETE /v1/campaigns/{campaignId} Delete Campaign
CampaignsApi disableCampaign POST /v1/campaigns/{campaignId}/disable Disable Campaign
CampaignsApi enableCampaign POST /v1/campaigns/{campaignId}/enable Enable Campaign
CampaignsApi getCampaign GET /v1/campaigns/{campaignId} Get Campaign
CampaignsApi importVouchersToCampaign POST /v1/campaigns/{campaignId}/import Import Vouchers to Campaign
CampaignsApi importVouchersToCampaignUsingCsv POST /v1/campaigns/{campaignId}/importCSV Import Vouchers to Campaign by CSV
CampaignsApi listCampaigns GET /v1/campaigns List Campaigns
CampaignsApi updateCampaign PUT /v1/campaigns/{campaignId} Update Campaign
CategoriesApi createCategory POST /v1/categories Create Category
CategoriesApi deleteCategory DELETE /v1/categories/{categoryId} Delete Category
CategoriesApi getCategory GET /v1/categories/{categoryId} Get Category
CategoriesApi listCategories GET /v1/categories List Categories
CategoriesApi updateCategory PUT /v1/categories/{categoryId} Update Category
ClientSideApi checkEligibilityClientSide POST /client/v1/qualifications Check Eligibility (client-side)
ClientSideApi redeemStackedDiscountsClientSide POST /client/v1/redemptions Redeem Stackable Discounts (client-side)
ClientSideApi trackCustomEventClientSide POST /client/v1/events Track Custom Event (client-side)
ClientSideApi updateCustomersConsentsClientSide PUT /client/v1/customers/{customerId}/consents Update Customer's consents (client-side)
ClientSideApi validateStackedDiscountsClientSide POST /client/v1/validations Validate Stackable Discounts (client-side)
CustomersApi createCustomer POST /v1/customers Create Customer
CustomersApi customerPermanentlyDeletion POST /v1/customers/{customerId}/permanent-deletion Delete Customer Permanently
CustomersApi deleteCustomer DELETE /v1/customers/{customerId} Delete Customer
CustomersApi getCustomer GET /v1/customers/{customerId} Get Customer
CustomersApi importCustomersUsingCsv POST /v1/customers/importCSV Import and Update Customers using CSV
CustomersApi listCustomerSegments GET /v1/customers/{customerId}/segments List Customer's Segments
CustomersApi listCustomers GET /v1/customers List Customers
CustomersApi updateCustomer PUT /v1/customers/{customerId} Update Customer
CustomersApi updateCustomersConsents PUT /v1/customers/{customerId}/consents Update Customer's consents
CustomersApi updateCustomersInBulk POST /v1/customers/bulk/async Update Customers in bulk
CustomersApi updateCustomersMetadataInBulk POST /v1/customers/metadata/async Update Customers' Metadata in bulk
EventsApi trackCustomEvent POST /v1/events Track Custom Event
ExportsApi createExport POST /v1/exports Create Export
ExportsApi deleteExport DELETE /v1/exports/{exportId} Delete Export
ExportsApi downloadExport GET /v1/exports/{export_Id} Download Export
ExportsApi getExport GET /v1/exports/{exportId} Get Export
ExportsApi listExports GET /v1/exports List Exports
LoyaltiesApi createInBulkLoyaltyTiers POST /v1/loyalties/{campaignId}/tiers Create loyalty tiers
LoyaltiesApi deleteEarningRule DELETE /v1/loyalties/{campaignId}/earning-rules/{earningRuleId} Delete Earning Rule
LoyaltiesApi deleteLoyaltyProgram DELETE /v1/loyalties/{campaignId} Delete Loyalty Campaign
LoyaltiesApi deleteRewardAssignment1 DELETE /v1/loyalties/{campaignId}/rewards/{assignmentId} Delete Reward Assignment
LoyaltiesApi disableEarningRule POST /v1/loyalties/{campaignId}/earning-rules/{earningRuleId}/disable Disable Earning Rule
LoyaltiesApi enableEarningRule POST /v1/loyalties/{campaignId}/earning-rules/{earningRuleId}/enable Enable Earning Rule
LoyaltiesApi exportLoyaltyCardTransactions POST /v1/loyalties/members/{memberId}/transactions/export Export Loyalty Card Transactions
LoyaltiesApi exportLoyaltyCardTransactions1 POST /v1/loyalties/{campaignId}/members/{memberId}/transactions/export Export Loyalty Card Transactions
LoyaltiesApi getEarningRule GET /v1/loyalties/{campaignId}/earning-rules/{earningRuleId} Get Earning Rule
LoyaltiesApi getLoyaltyTier GET /v1/loyalties/{campaignId}/tiers/{loyaltyTierId} Get Loyalty Tier
LoyaltiesApi getRewardAssignment1 GET /v1/loyalties/{campaignId}/reward-assignments/{assignmentId} Get Reward Assignment
LoyaltiesApi getRewardAssignment2 GET /v1/loyalties/{campaignId}/rewards/{assignmentId} Get Reward Assignment
LoyaltiesApi getRewardDetails GET /v1/loyalties/{campaignId}/reward-assignments/{assignmentId}/reward Get Reward Details
LoyaltiesApi listLoyaltyCardTransactions GET /v1/loyalties/members/{memberId}/transactions List Loyalty Card Transactions
LoyaltiesApi listLoyaltyCardTransactions1 GET /v1/loyalties/{campaignId}/members/{memberId}/transactions List Loyalty Card Transactions
LoyaltiesApi listLoyaltyTierEarningRules GET /v1/loyalties/{campaignId}/tiers/{loyaltyTierId}/earning-rules List Loyalty Tier Earning Rules
LoyaltiesApi listLoyaltyTierRewards GET /v1/loyalties/{campaignId}/tiers/{loyaltyTierId}/rewards List Loyalty Tier Rewards
LoyaltiesApi listLoyaltyTiers GET /v1/loyalties/{campaignId}/tiers List Loyalty Tiers
LoyaltiesApi listMemberLoyaltyTier GET /v1/loyalties/members/{memberId}/tiers List Member's Loyalty Tiers
LoyaltiesApi listMemberRewards GET /v1/loyalties/members/{memberId}/rewards List Member Rewards
LoyaltiesApi listPointsExpiration GET /v1/loyalties/{campaignId}/members/{memberId}/points-expiration Get Points Expiration
LoyaltiesApi redeemReward POST /v1/loyalties/members/{memberId}/redemption Redeem Reward
LoyaltiesApi redeemReward1 POST /v1/loyalties/{campaignId}/members/{memberId}/redemption Redeem Reward
LoyaltiesApi transferPoints POST /v1/loyalties/{campaignId}/members/{memberId}/transfers Transfer Loyalty Points
LoyaltiesApi updateLoyaltyCardBalance POST /v1/loyalties/members/{memberId}/balance Add or Remove Loyalty Card Balance
LoyaltiesApi updateLoyaltyCardBalance1 POST /v1/loyalties/{campaignId}/members/{memberId}/balance Add or Remove Loyalty Card Balance
OrdersApi createOrder POST /v1/orders Create Order
OrdersApi createOrderExport POST /v1/orders/export Create Orders Export
OrdersApi getOrder GET /v1/orders/{orderId} Get Order
OrdersApi importOrders POST /v1/orders/import Import Orders
OrdersApi listOrders GET /v1/orders List Orders
OrdersApi updateOrder PUT /v1/orders/{orderId} Update Order
ProductCollectionsApi createProductCollection POST /v1/product-collections Create Product Collection
ProductCollectionsApi deleteProductCollection DELETE /v1/product-collections/{productCollectionId} Delete Product Collection
ProductCollectionsApi getProductCollection GET /v1/product-collections/{productCollectionId} Get Product Collection
ProductCollectionsApi listProductCollections GET /v1/product-collections List Product Collections
ProductCollectionsApi listProductsInCollection GET /v1/product-collections/{productCollectionId}/products List Products in Collection
ProductsApi createProduct POST /v1/products Create Product
ProductsApi createSku POST /v1/products/{productId}/skus Create SKU
ProductsApi deleteProduct DELETE /v1/products/{productId} Delete Product
ProductsApi deleteSku DELETE /v1/products/{productId}/skus/{skuId} Delete SKU
ProductsApi getProduct GET /v1/products/{productId} Get Product
ProductsApi getSku GET /v1/skus/{skuId} Get SKU
ProductsApi importProductsUsingCsv POST /v1/products/importCSV Import Products using CSV
ProductsApi importSkusUsingCsv POST /v1/skus/importCSV Import SKUs using CSV
ProductsApi listProducts GET /v1/products List Products
ProductsApi listSkusInProduct GET /v1/products/{productId}/skus List SKUs in Product
ProductsApi updateProduct PUT /v1/products/{productId} Update Product
ProductsApi updateProductsInBulk POST /v1/products/bulk/async Update Products in bulk
ProductsApi updateProductsMetadataInBulk POST /v1/products/metadata/async Update Products' Metadata in bulk
ProductsApi updateSku PUT /v1/products/{productId}/skus/{skuId} Update SKU
PromotionsApi createPromotionStack POST /v1/promotions/{campaignId}/stacks Create Promotion Stack
PromotionsApi deletePromotionStack DELETE /v1/promotions/{campaignId}/stacks/{stackId} Delete Promotion Stack
PromotionsApi deletePromotionTier DELETE /v1/promotions/tiers/{promotionTierId} Delete Promotion Tier
PromotionsApi disablePromotionTier POST /v1/promotions/tiers/{promotionTierId}/disable Disable Promotion Tier
PromotionsApi enablePromotionTier POST /v1/promotions/tiers/{promotionTierId}/enable Enable Promotion Tier
PromotionsApi getPromotionStack GET /v1/promotions/{campaignId}/stacks/{stackId} Get Promotion Stack
PromotionsApi getPromotionTier GET /v1/promotions/tiers/{promotionTierId} Get Promotion Tier
PromotionsApi listAllPromotionStacks GET /v1/promotions/stacks List Promotion Stacks
PromotionsApi listPromotionStacksInCampaign GET /v1/promotions/{campaignId}/stacks List Promotion Stacks in Campaign
PromotionsApi listPromotionTiersFromCampaign GET /v1/promotions/{campaignId}/tiers List Promotion Tiers from Campaign
PromotionsApi updatePromotionStack PUT /v1/promotions/{campaignId}/stacks/{stackId} Update Promotion Stack
PublicationsApi createPublication POST /v1/publications Create Publication
PublicationsApi createPublication1 GET /v1/publications/create Create Publication
PublicationsApi listPublications GET /v1/publications List Publications
QualificationsApi checkEligibility POST /v1/qualifications Check Eligibility
RedemptionsApi getRedemption GET /v1/redemptions/{redemptionId} Get Redemption
RedemptionsApi getVoucherRedemptions GET /v1/vouchers/{code}/redemption Get Voucher's Redemptions
RedemptionsApi listRedemptions GET /v1/redemptions List Redemptions
RedemptionsApi redeemStackedDiscounts POST /v1/redemptions Redeem Stackable Discounts
RedemptionsApi rollbackRedemption POST /v1/redemptions/{redemptionId}/rollback Rollback Redemption
RedemptionsApi rollbackStackedRedemptions POST /v1/redemptions/{parentRedemptionId}/rollbacks Rollback Stackable Redemptions
RewardsApi createRewardAssignment POST /v1/rewards/{rewardId}/assignments Create Reward Assignment
RewardsApi deleteReward DELETE /v1/rewards/{rewardId} Delete Reward
RewardsApi deleteRewardAssignment DELETE /v1/rewards/{rewardId}/assignments/{assignmentId} Delete Reward Assignment
RewardsApi getRewardAssignment GET /v1/rewards/{rewardId}/assignments/{assignmentId} Get Reward Assignment
RewardsApi listRewardAssignments GET /v1/rewards/{rewardId}/assignments List Reward Assignments
RewardsApi updateRewardAssignment PUT /v1/rewards/{rewardId}/assignments/{assignmentId} Update Reward Assignment
SegmentsApi deleteSegment DELETE /v1/segments/{segmentId} Delete Segment
ValidationRulesApi createValidationRuleAssignment POST /v1/validation-rules/{validationRuleId}/assignments Create Validation Rules Assignments
ValidationRulesApi createValidationRules POST /v1/validation-rules Create Validation Rules
ValidationRulesApi deleteValidationRuleAssignment DELETE /v1/validation-rules/{validationRuleId}/assignments/{assignmentId} Delete Validation Rule Assignment
ValidationRulesApi deleteValidationRules DELETE /v1/validation-rules/{validationRuleId} Delete Validation Rule
ValidationRulesApi getValidationRule GET /v1/validation-rules/{validationRuleId} Get Validation Rule
ValidationRulesApi listValidationRuleAssignments GET /v1/validation-rules/{validationRuleId}/assignments List Validation Rule Assignments
ValidationRulesApi listValidationRules GET /v1/validation-rules List Validation Rules
ValidationRulesApi listValidationRulesAssignments GET /v1/validation-rules-assignments List Validation Rules' Assignment(s)
ValidationRulesApi updateValidationRule PUT /v1/validation-rules/{validationRuleId} Update Validation Rule
ValidationsApi validateStackedDiscounts POST /v1/validations Validate Stackable Discounts
VouchersApi deleteVoucher DELETE /v1/vouchers/{code} Delete Voucher
VouchersApi disableVoucher POST /v1/vouchers/{code}/disable Disable Voucher
VouchersApi enableVoucher POST /v1/vouchers/{code}/enable Enable Voucher
VouchersApi exportVoucherTransactions POST /v1/vouchers/{code}/transactions/export Export Voucher Transactions
VouchersApi getVoucher GET /v1/vouchers/{code} Get Voucher
VouchersApi importVouchersUsingCsv POST /v1/vouchers/importCSV Import Vouchers using CSV
VouchersApi listVoucherTransactions GET /v1/vouchers/{code}/transactions List Voucher Transactions
VouchersApi releaseValidationSession DELETE /v1/vouchers/{code}/sessions/{sessionKey} Release Validation Session
VouchersApi updateVoucherBalance POST /v1/vouchers/{code}/balance Add or Remove Voucher Balance

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

X-App-Id

  • Type: API key
  • API key parameter name: X-App-Id
  • Location: HTTP header

X-App-Token

  • Type: API key
  • API key parameter name: X-App-Token
  • Location: HTTP header

X-Client-Token

  • Type: API key
  • API key parameter name: X-Client-Token
  • Location: HTTP header

X-Client-Application-Id

  • Type: API key
  • API key parameter name: X-Client-Application-Id
  • Location: HTTP header

Recommendation

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages