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
Name | Value |
---|---|
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:
|
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
![](https://developer.gameball.co/~gitbook/image?url=https%3A%2F%2F1167798217-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-M3kSf4Ga0rOah5Au2jA-856047512%252Fuploads%252FkgLk7ekqQ31cZzFZeDt3%252FScreen%2520Shot%25202023-04-17%2520at%252012.40.49%2520AM.png%3Falt%3Dmedia%26token%3D148332dc-bafe-4103-903f-3add27974e53&width=768&dpr=4&quality=100&sign=15784e02&sv=1)
Click on test connection to check if your configurations is correct or not.
Last updated