API-Mathpix

 view release on metacpan or  search on metacpan

lib/API/Mathpix.pm  view on Meta::CPAN

package API::Mathpix;

use Moose;
use JSON::PP;
use LWP::UserAgent;
use HTTP::Request;
use MIME::Base64;
use Algorithm::LeakyBucket;

use API::Mathpix::Response;

has 'app_id' => (
  is  => 'rw',
  isa => 'Str'
);

lib/API/Mathpix.pm  view on Meta::CPAN

  my $url = 'https://api.mathpix.com/v3/text';

  my $headers = [
    'Content-Type'  => 'application/json',
    ':app_id'       => $self->app_id,
    ':app_key'      => $self->app_key,
  ];

  my $encoded_data = encode_json($opt);

  my $r = HTTP::Request->new('POST', $url, $headers, $encoded_data);

  my $response;

  if ($self->_bucket->tick) {
    $response = $self->_ua->request($r);
  }
  else {
    warn 'Rate limiting !';
  }



( run in 0.747 second using v1.01-cache-2.11-cpan-4505f990765 )