5th iPaas Puzzle: Design your Advent Calendar API (or fun 2023 Calendar API)

Don’t we all love a little puzzle, even more if it helps us keep our webMethods skills sharp?! This time, we propose to develop an Advent Calendar API – but for sure, the core concept of this puzzle can be adapted to work for various holidays & cultural backgrounds!

Background

A traditional Advent Calendar offers 24 small gifts or tokens to count down the days in December before Christmas. The first picture shows a paper Advent Calendar like my mother had one when she was a child more than 75 years ago. It has flaps covering each day’s picture. The second picture shows my kids’ Advent Calendar, which are 24 decorated fabric pockets (in this case only three of them), that I fill with small gifts & candy each year. We hang them on a garland of fir sprigs.

Task

Your Advent Calendar API should provide a different token/gift, e.g. (the link to) a song, joke, story, etc. every day starting from December 1st to December 24th. Alternatively, you could implement a 2023 Calendar API, which provides a different token/gift every month in 2023. Or come up with your very own adaptation of the idea for your favorite holiday!

Stretch Goal

Customize your Advent Calendar API to cater different users with different tokens, like I do with my kids’ Advent Calendar :slight_smile: both my kids get their very special gifts, e.g. toy horses for my daughter and Mangas for my son (not every day in December, I am no Croesus, though).

Submissions

Please post your solution to the puzzle as replies to this thread.
Use the “blur spoiler” tag to hide your results so that folks must click on your solution to indicate they want to see it!

BlurYourResults

iPaaS Puzzle Show Friday 16th of December!

Every third Friday for the next couple of weeks, we are hosting an iPaaS Puzzle Show.

We will briefly talk about the different solutions for this week’s puzzle, what to learn from them, and introduce next week’s iPaaS Puzzle. Hope you can join us.

The 5th iPaaS Puzzle Show will be in on Friday the 16th of December 8am CEST! and 5pm CEST! Details to come!

Deadline

Update: We give you an extra week to finish it. The sooner you publish your solution, the better. But just make sure you have your solution posted before the iPaaS Puzzle Show on 23th of December at 8am CEST. If you want to be invited on the show, please post your solution by Thursday 22nd of December at 8am CEST.

Prizes

The winners get fame and glory. We want this to be a friendly competition and we want to highlight great work, without having to crown a winner.

Suggest a Puzzle

If you have another great idea for an iPaaS Puzzle, please suggest it in this form . It should be a little challenge that is doable within a week and has easy access to the source data needed. If your challenge is geared towards improving our lives, then even better!

If your iPaaS Puzzle suggestion does get selected, we’d invite you to personally introduce it in our iPaaS Puzzle Show and you will receive a wooden Tangram game as a token of our appreciation.

Tangram-Prize

The actual prize may look differently!

5 Likes

I asked the Oracle ChatGPT (openai.com)

How would you create an Advent API on webMethods.io?

To create an Advent Calendar API on webMethods.io, you would need to first sign up for an account on the platform and create a new project. Once you have done this, you can use webMethods.io’s API designer to create an API that provides access to the tokens or gifts that you want to provide to users.

The API designer allows you to define the endpoints, parameters, and responses for your API, as well as specify the underlying data sources and business logic that are used to generate the responses.

Once you have designed your API, you can use webMethods.io’s API gateway to deploy and manage your API. This allows you to make your API available to users and track its usage.

To regularly update the tokens or gifts that are provided by the API, you can use webMethods.io’s integration features to connect your API to a database or other data source that contains the tokens or gifts. This allows you to easily add new content to the API on a daily basis.

Overall, webMethods.io provides a comprehensive set of tools for creating and managing an Advent Calendar API.

1 Like

Time to share my answer to the puzzle so people can make use of the advent calendar before it is too late :slight_smile:

What do we need to create an advent calendar

  • Something to show the doors/information
  • 24 pieces of information to go behind the doors

Let’s start with the information first, then after show you how we can realize this in a HTML page.

Solution follows - click to reveal!

Information Behind the Doors
An advent calendar (of old anyway) typically provides a nice picture or some useful information, however more recent calendars have morphed from pictures to chocolates, to anything now!

To make good use of the iPaaS we need some data sources to provide information, and what better place to get these from than some public APIs. To make the calendar a bit more interesting, I decided to use not 1, but 6 public APIs, which I used via the creation of REST connectors:

I then created a set of simple FlowService that takes each of these REST connectors, and converts the response into a single message string, like this:

Which results in 6 FlowServices, one for each API.

Finally, I want to then create the calendar API which I did in another FlowService (calendar). This is also pretty simple, with a ‘switch/case’ statement for each day, which then determines which API to call on that particular day:

Which I can then test for particular days, e.g. day 5:

The last step then is to expose this FlowService as an API, which we can use from our HTML advent calendar.

To do this we use the API functionality within integration to expose the calendar FlowService as an API:

Then I can test the API through any test tool, or even in a browser, e.g.

This API isn’t complete yet though.
My API from the iPaaS requires basic authentication, or I could choose to expose via OAuth2 or 2-way SSL straight from integration, however, our iPaaS also has API Gateway capabilities, so rather than expose the API from integration directly, I’ll use the API Gateway to do so.

To do this, I can take the API specification from integration, and register this API in the gateway:

You have to remember to add the necessary authentication in a policy so that the API Gateway can invoke the native API in integration:

Something to show the doors/information
Next - I need to create the advent calendar visual side. For this I just need a simple HTML representation of an advent calendar, and to save time, I reused this from github:
azaleamollis/advent-calendar: Advent Calendar with Christmas quotes in JavaScript (github.com) which looks something like this:

Then I edited the javascript to call the calendar REST API using xmlhttprequest object, rather than returning a pre-set piece of text.

Then you can put this into a webserver, but there’s one more crucial piece. As the REST APIs are on a different server than the calendar HTML, you’ll run into CORS (cross-origin-resource) issues.

The API Gateway makes dealing with this easy. You can simply add the Response Processing CORS policy and provide the domain, e.g.

And then, everything works :clap:

And here is the live version!
wM.io Advent Calendar

For those who want to try and recreate this, you’ll find this attached here:
FlowServices: calendar.zip (139.3 KB)
Workflow: advent-calendar-ui-workflow.zip (156.8 KB)

3 Likes

Join us for the holiday edition of the iPaaS Puzzle Show in under 30 minutes at top of the hour.

Click here to join the meeting

Meeting ID: 386 966 187 518
Passcode: pZ2HKi

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.