GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Twitter::API::Trait::NormalizeBooleans(3) User Contributed Perl Documentation Twitter::API::Trait::NormalizeBooleans(3)

Twitter::API::Trait::NormalizeBooleans - Normalize Booleans

version 1.0006

    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

Twitter has a strange concept of boolean values. Usually, the API accepts "t", "true", or 1 for true. Sometimes it accepts "f", "false", or 0 for false. But then you have strange cases like the "include_email" parameter used for authorized applications by the "verify_credentials" endpoint. It only accepts "true". Worse, for some boolean values, passing "f", "false", or 0 all work as if you passed "true". For those values, false means not including the parameter at all.

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.

Marc Mims <marc@questright.com>

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.

2021-04-01 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.