-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from upwork/v2.1.4
Add GraphQL support
- Loading branch information
Showing
10 changed files
with
194 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
/vendor | ||
*~ | ||
composer.lock | ||
Build | ||
Makefile.PL | ||
META.yml | ||
META.json | ||
MYMETA.yml | ||
MYMETA.json | ||
blib/* | ||
_build/* | ||
*.bak | ||
Net-Upwork-API-*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
## 2.1.4 | ||
* Add GraphQL support | ||
|
||
## 2.1.3 | ||
* Fixed HR module | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Licensed under the Upwork's API Terms of Use; | ||
# you may not use this file except in compliance with the Terms. | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# Author:: Maksym Novozhylov (mnovozhilov@upwork.com) | ||
# Copyright:: Copyright 2021(c) Upwork.com | ||
# License:: See LICENSE.txt and TOS - https://developers.upwork.com/api-tos.html | ||
|
||
package Net::Upwork::API::Routers::Graphql; | ||
|
||
use strict; | ||
use warnings; | ||
use parent "Net::Upwork::API"; | ||
use JSON::MaybeXS qw/encode_json/; | ||
|
||
use constant ENTRY_POINT => Net::Upwork::API::Client::ENTRY_POINT_GQL; | ||
|
||
=pod | ||
=head1 NAME | ||
Graphql | ||
=head1 FUNCTIONS | ||
=over 4 | ||
=item new($api) | ||
Create a new object for accessing GraphQL API | ||
B<Parameters> | ||
$api | ||
API object | ||
=cut | ||
|
||
sub new { | ||
my ($class, $api) = @_; | ||
return Net::Upwork::API::init_router($class, $api, ENTRY_POINT); | ||
} | ||
|
||
=item set_org_uid_header | ||
Configure X-Upwork-API-TenantId header | ||
B<Parameters> | ||
$tenant_id | ||
Organization UID | ||
B<Return value> | ||
void | ||
=cut | ||
|
||
sub set_org_uid_header { | ||
my ($self, $tenant_id) = @_; | ||
|
||
$self->{tenant_id} = $tenant_id; | ||
} | ||
|
||
=item execute | ||
Execute GraphQL request | ||
B<Return value> | ||
JSON response as a string | ||
=cut | ||
|
||
sub execute { | ||
my $self = shift; | ||
my %params = @_; | ||
|
||
my $json = encode_json \%params; | ||
|
||
return $self->client()->graphql_request($json, $self->{tenant_id}); | ||
} | ||
|
||
=back | ||
=head1 AUTHOR | ||
Maksym Novozhylov C<< <mnovozhilov@upwork.com> >> | ||
=head1 COPYRIGHT | ||
Copyright E<copy> Upwork Global Corp., 2021 | ||
=cut | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env perl | ||
use strict; | ||
use Test::More tests => 3; | ||
use lib qw(lib); | ||
use Net::Upwork::API::Routers::Graphql; | ||
|
||
can_ok('Net::Upwork::API::Routers::Graphql', 'new'); | ||
can_ok('Net::Upwork::API::Routers::Graphql', 'set_org_uid_header'); | ||
can_ok('Net::Upwork::API::Routers::Graphql', 'execute'); |