@->code == 503);
my $db = $self->{_db};
$db->create({created => $currentDate, request_json => $request_json});
}
}
sub put_url {
my $self = shift;
eval {
$self->SUPER::put_url(@_);
};
if (
@->code == 503);
my $db = $self->{_db};
$db->create({created => $currentDate, request_json => $request_json});
}
}
sub delete_url {
my $self = shift;
eval {
$self->SUPER::delete_url(@_);
};
if ($@) {
die $@ unless ($@->code == 503);
my $db = $self->{_db};
$db->create({created => $currentDate, request_json => $request_json});
}
}
e_filled { return qw(); }
sub needs_login { return 1; }
# Shopify recently just killed all their JSON apis for non-api stuff. Why? Who knows?
# They're just delaying the inevitable.
sub needs_form_en
=head1 SYNOPSIS
use Webservice::OVH;
my $ovh = Webservice::OVH->new_from_json("credentials.json");
my $email_domains = $ovh->email->domain->domains;
foreach $email_do
oduct_reference variant_reference file_reference number_integer number_decimal date date_time url json boolean color weight volume dimension rating)]),
"value" => new WWW::Shopify::Field::MediumText(
=head1 SYNOPSIS
use Webservice::OVH;
my $ovh = Webservice::OVH->new_from_json("credentials.json");
my $services = $ovh->domain->services;
foreach my $service (@$services)
ists" => new WWW::Shopify::Field::Boolean(),
"format" => new WWW::Shopify::Field::String::Enum(["json", "xml"]),
"requires_shipping_method" => new WWW::Shopify::Field::Boolean(),
"tracking_support"
tive" => new WWW::Shopify::Field::Boolean(),
"format" => new WWW::Shopify::Field::String::Enum(["json", "xml"]),
"carrier_service_type" => new WWW::Shopify::Field::String::Enum(["api"]),
}; }
sub c
e_filled { return qw(); }
sub needs_login { return 1; }
# Shopify recently just killed all their JSON apis for non-api stuff. Why? Who knows?
# They're just delaying the inevitable.
sub needs_form_en
OAuth2Login> for Google's
documentation.
This is not yet supported, and would require the use of JSON Web Tokens to
support.
=item Web Server Application
This is intended for applications running o
viceAccount> for
Google's documentation.
This is not yet supported, and would require the use of JSON Web Tokens to
support.
=back
=head1 AUTHORS
=over 4
=item *
Ben Tilly, <btilly at gmail.com>
::Cart::Item
=head1 SYNOPSIS
use Webservice::OVH;
my $ovh = Webservice::OVH->new_from_json("credentials.json");
my $cart = $ovh->order->new_cart(ovh_subsidiary => 'DE');
my $items = $cart->items;
h-api
=head1 SYNOPSIS
use Webservice::OVH;
my $ovh = Webservice::OVH->new("credentials.json");
my $ovh = Webservice::OVH->new(application_key => $key, application_secret => $secret, co
equirements
use JSON;
use File::Slurp qw(read_file);
=head2 new_from_json
Creates an api Object based on credentials in a json File
=over
=item * Parameter: $file_json - dir to json file
=item *
Return: L<Webservice::OVH>
=item * Synopsis: Webservice::OVH->new_from_json("path/file");
=back
=over 2
=item * application_key is generated when creating an application via ovh web interface
r> can also require you to authenticate
in any further way that they please. You will get back a JSON response.
An example request might look like this:
POST /o/oauth2/token HTTP/1.1
Host:
onse if you're lucky will look something like:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Cache-Control: no-store
Pragma: no-cache
{
"access_token":"1
}
or if you're unlucky, maybe like this:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Cache-Control: no-store
Pragma: no-cache
{
"error":"invalid_
<to_ref>
Construct an unblessed data structure to represent the object that can be
serialized as JSON. The default implementation just creates a shallow copy
and assumes there are no blessed subobje
WP::UserAgent lazyloads these, but we always need it.
use HTTP::Request::Common;
use JSON qw(encode_json decode_json);
use LWP::UserAgent;
use Module::Load qw(load);
our @CARP_NOT = map "LWP::Authen:
access_token}->to_ref;
$ref->{_class} = ref($self->{access_token});
return encode_json($ref);
}
else {
return undef;
}
}
# This does the actual saving.
sub _set_to
e_provider_headers || {};
}
my $response = $params ? $self->post($url, Content => encode_json($params), %$headers) : $self->get($url, %$headers);
if (! $response->is_success()) {
qw{ carp croak };
use JSON ();
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Class variables
my $Json = JSON->new->allow_nonref;
# End -
'response'}->content };
}
eval { $content = $Json->decode($self->{'response'}->content); 1; } or do {
carp 'Failed to parse JSON content from the answer: ', $self->{'response'}->cont
<isSuccess|/isSuccess>.
It takes no parameter.
=head1 SEE ALSO
The guts of module are using: C<JSON>.
=head1 COPYRIGHT
Copyright (c) 2013, OVH SAS.
All rights reserved.
This library is distribut
d thereof.
#
package API::Octopart;
$VERSION = 1.003;
use 5.010;
use strict;
use warnings;
use JSON;
use LWP::UserAgent;
use Digest::MD5 qw(md5_hex);
use Data::Dumper;
=head1 NAME
API::Octopart
and provides API communication details.
=item * json_debug => 1
JSON response debugging. This is very verbose and dumps the Octopart response
in JSON.
=back
=cut
our %valid_opts = map { $_ =>
1 } qw/token include_specs cache cache_age ua_debug query_limit json_debug/;
sub new
{
my ($class, %args) = @_;
foreach my $arg (keys %args)
{
die "invalid option: $arg => $args{$arg}" if !$val
;
use Carp qw{ carp croak };
use List::Util 'first';
use LWP::UserAgent ();
use JSON ();
use Digest::SHA1 'sha1_hex';
# # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # #
# Class variables
my $UserAgent = LWP::UserAgent->new(timeout => 10);
my $Json = JSON->new->allow_nonref;
my @accessRuleMethods = qw{ GET POST PUT DELETE };
# End - Class vari
e 'get' and $method ne 'delete')
{
$body = $Json->encode($params{'body'});
$httpHeaders{'Content-type'} = 'application/json';
$content{'Content'} = $body;
}
unles
= '0.20'; # VERSION
use 5.006;
use strict;
use warnings;
use Carp qw(confess croak);
use JSON qw(decode_json);
use Memoize qw(memoize);
use Module::Load qw(load);
use URI;
our @CARP_NOT = qw(LWP::A
ntent};
if (not defined($content)) {
$content = '';
}
my $data = eval {decode_json($content)};
my $parse_error = $@;
my $token_endpoint = $self->token_endpoint();
# Ca
ne;
return <<"EOT"
Token endpoint gave invalid JSON in response.
Endpoint: $token_endpoint
Status: $status
Parse error: $parse_error
JSON:
$content
EOT
}
elsif ($data->{error}) {
=head1 SYNOPSIS
use Webservice::OVH;
my $ovh = Webservice::OVH->new_from_json("credentials.json");
my $projects = $ovh->cloud->projects;
foreach my $project (@$project) {
/" . $self->api_version . "/locales/$locale_id.json", { s => \%mapping });
my $package = "WWW::Shopify::Model::Locale";
my $object = $package->from_json($decoded->{$package->singular}, $self);
retu
/api/" . $self->api_version . "/locale_translations/english_translations.json");
return map { my $object = $package->from_json($_, $self); $object; } @{$decoded->{$package->plural}};
}
sub update {
se = $self->url_handler->upload_url("POST", 'https://' . $self->shop_url . '/admin/settings/files.json', 'file', $item->key, ($item->content_type || "application/octet-stream"), $attachment);
die ne