Twitte...oleans(3pm)

πŸ’– Twitter::API::Trait::NormalizeBooleans β€” Normalize Booleans πŸ’–

okay so bestie, this is a Perl manual page β€” Twitter::API::Trait::NormalizeBooleans, living in the User Contributed Perl Documentation section (3pm). Yes the header is truncated in your terminal, that's just how manpages do, it's giving ✨drama✨.


🌸 VERSION 🌸

version 1.0006 β€” she's a specific girlie, don't @ me πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

use Twitter::API;

my $client = Twitter::API->new_with_traits(
    traits => [ qw/ApiMethods NormalizeBooleans/ ],
    %other_new_options
);

my ( $r, $c ) = $client->home_timeline({ trim_user => 1 });

say $c->http_request->uri;

# output:
https://api.twitter.com/1.1/statuses/home_timeline.json?trim_user=true

see how you passed 1 and the URL got true? yeah. that's her whole job. main character energy fr fr πŸ‘‘


✨ DESCRIPTION ✨

Twitter has a strange concept of boolean values and honestly? it's a mess. 😭 Usually the API accepts "t", "true", or 1 for true. Sometimes it accepts "f", "false", or 0 for false. But then you get the strange cases β€” like the "include_email" parameter used for authorized applications by the "verify_credentials" endpoint. That one only accepts "true". Nothing else. Not even playing.

And worse?? WORSE?? For some boolean values, passing "f", "false", or 0 all work as if you passed "true". πŸ’€ So for those values, false means not including the parameter at all. Not false. Not zero. Just... gone. Poof. 🧚

So this trait attempts to normalize booleans by transforming any perl truthy value to the Twitter API's preference, "true". It transforms falsey values to "false". And then it removes false parameters that the API always treats as true. 🫢

You're welcome. πŸ’…


πŸ‘‘ AUTHOR πŸ‘‘

Marc Mims <marc@questright.com> β€” thank you king 🫑


This software is copyright (c) 2015-2021 by Marc Mims.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. 🌈


and that's the whole vibe, bestie β€” written against perl v5.32.1, dated 2021-09-11, and yes the footer got truncated too, iykyk πŸ˜­πŸ’–

πŸ“¦ where this page comes from