Example using a custom coupon system
A wise proverb says
“TELL ME AND I’LL FORGET. SHOW ME AND I’LL REMEMBER. LET ME DO AND I’LL UNDERSTAND!”-CONFUCIUS
As we believe the best way to learn is by doing, in this section we will integrate a sample coupon system with Gameball to give you a taste of how real integration should look and how to smoothly integrate your coupon system with Gameball. Let's get our hands dirty!
If you already have your own APIs that create coupons, you did not need to re-create your code from scratch, just make sure your endpoint can be reached publicly and make sure to follow along to understand the integration process more.
First, we will define the coupon model and its attributes which will be created by Gameball.
Make sure that your coupon model attributes matches the names of the variables you define in the payload request configuration
Now, lets add the endpoint responsible for creating the coupon, this is the endpoint Gameball backend will send the coupon creation request to.
This endpoint should expect a body that look like this :
Your coupon creation endpoint must returns code 200 if your coupon is created successfully.
Based on the endpoint we created now, we should add the following configurations we mentioned previously
Coupon engine url
Method
POST
Headers
Method to authenticate this API, for example if you authenticate your request using apiKey, your headers will look like:
{"apiKey":"1231afdqda"}
Payload
In the payload json object, the key is always fixed, only values between {{}}
are changed based on coupon class attribute names, for example if we changed name of value
attribute in the coupon properties class to amount
the json body should looks like this :
Define coupon type values. You may have noticed that there are four checkboxes at the end of the configurations page in the dashboard, each representing one of the coupon types supported by Gameball. You only need to check the coupon types that you want to support, and if your coupon system supports a type, you need to provide the corresponding value for it. For example, in the coupon system we have created, we support four coupon types that we have defined earlier inside the ECouponType enum, each type with its corresponding value. We will fill each coupon type with its value, as shown in the example below
Click on test connection to check if your configurations is correct or not.
Last updated