package Net::GraphSpace;
use Moose;
our $VERSION = '0.0009'; # VERSION
use v5.10;
use JSON qw(decode_json);
use LWP::UserAgent;
use Net::GraphSpace::Edge;
use Net::GraphSpace::Graph;
use Net::GraphS
', $self->user, $self->password);
return $ua;
},
);
my $JSON = JSON->new->convert_blessed->utf8;
sub to_json { $JSON->encode(shift) }
sub gen_uri {
my ($self, $path) = @_;
#retu
, [], to_json($graph));
$res = $self->_ua->request($req);
} else {
my $uri = $self->gen_uri("users/$user/graphs");
$res = $self->_ua->post($uri, Content => to_json($graph))
package Net::GraphSpace::AttributesToJSON;
use Moose::Role;
use v5.10;
sub TO_JSON {
my ($self) = @_;
my @attrs = $self->meta->get_all_attributes;
return { map $self->_affinitize($_), @at
}
return $name => $value;
}
1;
__END__
=pod
=head1 NAME
Net::GraphSpace::AttributesToJSON
=head1 VERSION
version 0.0009
=head1 AUTHOR
Naveed Massjouni <naveedm9@gmail.com>
=head1 COP
package Net::GraphSpace::Graph;
use Moose;
use Carp qw(croak);
use JSON qw(decode_json);
use Net::GraphSpace::Edge;
use Net::GraphSpace::Node;
use Net::GraphSpace::Types;
has name => (is => '
->add_node($_) foreach @{$_[1]} }
sub add_edges { $_[0]->add_edge($_) foreach @{$_[1]} }
sub TO_JSON {
my ($self) = @_;
return {
metadata => {
map { defined($self->$_) ?
}
};
}
sub new_from_http_response {
my($class, $res) = @_;
my $data = decode_json($res->content);
my $metadata = $data->{metadata};
my $graph = Net::GraphSpace::Graph->new