All URIs are relative to https://api.voucherify.io
Method | HTTP request | Description |
---|---|---|
createPublication | POST /v1/publications | Create Publication |
listPublications | GET /v1/publications | List Publications |
PublicationsCreateResponseBody createPublication(joinOnce, publicationsCreateRequestBody)
Create Publication
This method selects vouchers that are suitable for publication, adds a publish entry and returns the publication. A voucher is suitable for publication when it's active and hasn't been published yet. <!-- theme: warning --> > 🚧 Clearly define the source of the voucher > > You must clearly define which source you want to publish the voucher code from. It can either be a code from a campaign or a specific voucher identified by a code. <!-- theme: warning --> > 🚧 Publish multiple vouchers > In case you want to publish multiple vouchers within a single publication, you need to specify the campaign name and number of vouchers you want to publish. <!-- theme: info --> > 📘 Auto-update campaign > > In case you want to ensure the number of publishable codes increases automatically with the number of customers, you should use an auto-update campaign.
// Import classes:
import voucherify.client.ApiClient;
import voucherify.client.ApiException;
import voucherify.client.Configuration;
import voucherify.client.auth.*;
import voucherify.client.models.*;
import 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
ApiKeyAuth X-App-Id = (ApiKeyAuth) defaultClient.getAuthentication("X-App-Id");
X-App-Id.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//X-App-Id.setApiKeyPrefix("Token");
// Configure API key authorization: X-App-Token
ApiKeyAuth X-App-Token = (ApiKeyAuth) defaultClient.getAuthentication("X-App-Token");
X-App-Token.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//X-App-Token.setApiKeyPrefix("Token");
PublicationsApi apiInstance = new PublicationsApi(defaultClient);
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.
PublicationsCreateRequestBody publicationsCreateRequestBody = new PublicationsCreateRequestBody(); // PublicationsCreateRequestBody | Specify the publication parameters.
try {
PublicationsCreateResponseBody result = apiInstance.createPublication(joinOnce, publicationsCreateRequestBody);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PublicationsApi#createPublication");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
joinOnce | 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. | [optional] |
publicationsCreateRequestBody | PublicationsCreateRequestBody | Specify the publication parameters. | [optional] |
PublicationsCreateResponseBody
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Returns a publication object if a valid identifier was provided. | - |
PublicationsListResponseBody listPublications(limit, page, order, campaign, customer, voucher, result, voucherType, isReferralCode, filters, sourceId)
List Publications
Retrieve a list of publications. To return a particular publication, you can use the `source_id` query parameter and provide the `source_id` of the publication you are looking for specifically. ## Pagination <!-- theme: warning --> > 🚧 Important! > > If you want to scroll through a huge set of records, it is recommended to use the <!-- Exports API -->Exports API. This API will return an error `page_over_limit` if you reach a page above 1000. ## Filter Query The `filters` query parameter allows for joining multiple parameters with logical operators. The syntax looks as follows: <!-- title: "Filter template" --> ```url filters[<field_name>][conditions][<operator>][<index>]=<value> ``` ### Operators: <!-- title: "Operators" --> ``` "$in" "$not_in" "$is" "$is_not" "$has_value" "$is_unknown" "$contains" "$starts_with" "$ends_with" "$more_than" "$less_than" "$more_than_equal" "$less_than_equal" ``` ### Examples <!-- title: "Example 1 - List publications of a given customer" --> ```url GET /v1/publications?filters[customer_id][conditions][$is][0]=cust_lUET6gRpO5Wxlg5p2j2gRCgL ``` <!-- title: "Example 2 - List publications of 2 customers" --> ```url GET /v1/publications?filters[customer_id][conditions][$in][0]=cust_lUET6gRpO5Wxlg5p2j2gRCgL&filters[customer_id][conditions][$in][1]=cust_aR7NfHusxT7PdTMAKMfWDXnc ``` <!-- title: "Example 3 - List publications of 2 customers using junction operator" --> ```url GET /v1/publications?filters[customer_id][conditions][$is][0]=cust_lUET6gRpO5Wxlg5p2j2gRCgL&filters[customer_id][conditions][$is][1]=cust_aR7NfHusxT7PdTMAKMfWDXnc&filters[junction]=OR ```
// Import classes:
import voucherify.client.ApiClient;
import voucherify.client.ApiException;
import voucherify.client.Configuration;
import voucherify.client.auth.*;
import voucherify.client.models.*;
import 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
ApiKeyAuth X-App-Id = (ApiKeyAuth) defaultClient.getAuthentication("X-App-Id");
X-App-Id.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//X-App-Id.setApiKeyPrefix("Token");
// Configure API key authorization: X-App-Token
ApiKeyAuth X-App-Token = (ApiKeyAuth) defaultClient.getAuthentication("X-App-Token");
X-App-Token.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//X-App-Token.setApiKeyPrefix("Token");
PublicationsApi apiInstance = new PublicationsApi(defaultClient);
Integer limit = 56; // Integer | 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; // Integer | Which page of results to return. The lowest value is `1`.
ParameterOrderListPublications order = ParameterOrderListPublications.fromValue("id"); // ParameterOrderListPublications | Sorts the results using one of the filtering options, where the dash `-` preceding a sorting option means sorting in a descending order.
String campaign = "campaign_example"; // String | Filters by a given campaign name.
String customer = "customer_example"; // String | Filters by a unique customer ID.
String voucher = "voucher_example"; // String | Filters by a given voucher code.
ParameterResultListPublications result = ParameterResultListPublications.fromValue("SUCCESS"); // ParameterResultListPublications | Filters by a publication result.
ParameterVoucherTypeListPublications voucherType = ParameterVoucherTypeListPublications.fromValue("discount"); // ParameterVoucherTypeListPublications | Filters by a voucher type.
Boolean isReferralCode = true; // Boolean | This filter works only for the `true` option. If set to `true`, the query returns only publications of codes from referral campaigns.
String filters = "filters_example"; // String | Allows for combining the filters mentioned in the endpoint description.
String sourceId = "sourceId_example"; // String | Using this endpoint with a particular publication `source_id`, which was sent with the original request to create a publication, returns in the response, exactly the same code published initially because the code was assigned to the given publication. As a result, you can use this endpoint as a reference and return a code that was assigned in a publication by using a particular `source_id`.
try {
PublicationsListResponseBody result = apiInstance.listPublications(limit, page, order, campaign, customer, voucher, result, voucherType, isReferralCode, filters, sourceId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PublicationsApi#listPublications");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
limit | Integer | 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. | [optional] |
page | Integer | Which page of results to return. The lowest value is `1`. | [optional] |
order | ParameterOrderListPublications | Sorts the results using one of the filtering options, where the dash `-` preceding a sorting option means sorting in a descending order. | [optional] [enum: id, -id, voucher_code, -voucher_code, tracking_id, -tracking_id, customer_id, -customer_id, created_at, -created_at, channel, -channel] |
campaign | String | Filters by a given campaign name. | [optional] |
customer | String | Filters by a unique customer ID. | [optional] |
voucher | String | Filters by a given voucher code. | [optional] |
result | ParameterResultListPublications | Filters by a publication result. | [optional] [enum: SUCCESS, FAILURE] |
voucherType | ParameterVoucherTypeListPublications | Filters by a voucher type. | [optional] [enum: discount, loyalty, lucky_draw] |
isReferralCode | Boolean | This filter works only for the `true` option. If set to `true`, the query returns only publications of codes from referral campaigns. | [optional] |
filters | String | Allows for combining the filters mentioned in the endpoint description. | [optional] |
sourceId | String | Using this endpoint with a particular publication `source_id`, which was sent with the original request to create a publication, returns in the response, exactly the same code published initially because the code was assigned to the given publication. As a result, you can use this endpoint as a reference and return a code that was assigned in a publication by using a particular `source_id`. | [optional] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Returns a list of publications you’ve previously created with <!-- create publication -->create publication or implicitly by the distribution manager. The publications are returned in sorted order, with the most recent ones appearing first. | - |