Given a file with UTM tags, a domain, and a bitly preferred domain, do a script that converts each of these parameters into a long url and request a short url from bitly within the preferred subdomain. Then return a file with the original information plus the results from each request.
Use Virtual Env and export dependencies when delivering
Bitly API Key: The script should have a variable that it receives when being ran representing a Bitly api key. Create a test one for free and use it for your development.
(Optional) A Column for each UTM Tag that will be added. Columns are:
(Optional) 6 columns so the name of other three parameters along with their values can also be added to the long url
Same for Param_2 and Param_3
(Required) A url to which the parameters should be attached.
(Optional) Bitly’s preferred domain to do shortening (Eg: domain - (optional) the short domain to use; either [login to view URL], [login to view URL], or [login to view URL] or a custom short domain. The default for this parameter is the short domain selected by each user in their bitly account settings. Passing a specific domain via this parameter will override the default settings)
The script should read the input CSV and for each row, construct the domain and the url that will be sent to Bitly. The result of this process will be a long url. The long url should contain the domain, follow by the utm tags with their values, followed by the additional 3 parameters with their values if they exist.
Then, the script will go through each long url and do a request to Bitly and retrieve a short url for each using the preferred subdomain. Please read Bitly’s documentation on how to do this request here: [login to view URL] The script should respect the Bitlys quota so it won’t fail.
Finally, the script will gather the responses and return a file that contains the same columns as before, but additionally will add the columns stated in the output section.
new_hash - designates if this is the first time this long_url was shortened by this user. The return value will equal 1 the first time a long_url is shortened. It will also then be added to the user history.
url - the actual Bitlink that should be used, and is a unique value for the given Bitly account.
hash - a bitly hash for long_url which is unique to the given account.
global_hash - a bitly hash for long_url which can be used to track aggregate stats across all Bitlinks that point to the same long_url.
long_url - an echo back of the longUrl request parameter. This may not always be equal to the URL requested, as some URL normalization may occur (e.g., due to encoding differences, or case differences in the domain). This long_url will always be functionally identical the the request parameter.
Error Message: An error message for each url if present.
Error Code: An error code that bitly returned if present.
Constraints and Requirements:
If a UTM parameter is not present, the script should not fail.
If the extra parameters 1,2, or 3 are not present, the script should not fail.
Any other optional parameter should not make the script fail if not present.
If a required parameter is missing, for any of the urls, the script should stop before processing the urls and inform the user.
The script should be able to convert at least 1000 URLs continuously.
If one of the rows generates an error, the script should continue and an error column should be filled indicating what happened with that row.
You will find a file attached called [login to view URL] which will contain a sample file that should be converted.
You will find an [login to view URL] which will contain a sample file of the output the script should generate.
Unit Tests for functionality