| 1 | #!/usr/bin/perl | ||||||||||
| 2 | |||||||||||
| 3 | |||||||||||
| 4 | =head1 NAME | ||||||||||
| 5 | |||||||||||
| 6 | WWW::Shopify::Private - Main object representing private app access to a particular Shopify store. | ||||||||||
| 7 | |||||||||||
| 8 | =cut | ||||||||||
| 9 | |||||||||||
| 10 | =head1 DESCRIPTION | ||||||||||
| 11 | |||||||||||
| 12 | Inherits all methods from L<WWW::Shopify>, provides additional mechanisms to modify the used password, user-agent and url handler. | ||||||||||
| 13 | |||||||||||
| 14 | =cut | ||||||||||
| 15 | |||||||||||
| 16 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | package WWW::Shopify::Private; | ||||||||||
| 20 | 1 | ▶ | use parent 'WWW::Shopify'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | |||||||||||
| 22 | =head1 METHODS | ||||||||||
| 23 | |||||||||||
| 24 | =head2 new(url, api_key, password) | ||||||||||
| 25 | |||||||||||
| 26 | Creates a new WWW::Shopify::Private object, which allows you to make calls via the shopify private app interface.s | ||||||||||
| 27 | |||||||||||
| 28 | =cut | ||||||||||
| 29 | |||||||||||
| 30 | sub new { | ||||||||||
| 31 | 0 | ▶ | my $package = shift; | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 32 | 0 | my ($shop_url, $api_key, $password) = @_; | |||||||||
| 33 | 0 | my $self = $package->SUPER::new($shop_url); | |||||||||
| 34 | 0 | $self->api_key($api_key); | |||||||||
| 35 | 0 | $self->password($password); | |||||||||
| 36 | 0 | return $self; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 0 | ▶ | sub url_handler { $_[0]->{_url_handler} = $_[1] if defined $_[1]; return $_[0]->{_url_handler}; } | ||||||||
|
Subroutine
url_handler: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||
| 40 | |||||||||||
| 41 | =head2 encode_url($url) | ||||||||||
| 42 | |||||||||||
| 43 | Modifies the requested url by prepending the api key and the password, as well as the shop's url, before sending the request off to the user agent. | ||||||||||
| 44 | |||||||||||
| 45 | =cut | ||||||||||
| 46 | |||||||||||
| 47 | sub encode_url { | ||||||||||
| 48 | 0 | ▶ | my ($self, $url) = @_; | ||||||||
|
Subroutine
encode_url: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 49 | 0 | ▶ | return "https://" . $self->shop_url . $url if ($self->logged_in_admin); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 0 | return "https://" . $self->api_key . ":" . $_[0]->password . "@" . $self->shop_url . $url; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | |||||||||||
| 54 | =head2 api_key([$api_key]) | ||||||||||
| 55 | |||||||||||
| 56 | Gets/sets the app's access token. | ||||||||||
| 57 | |||||||||||
| 58 | =cut | ||||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | sub api_key { $_[0]->{_api_key} = $_[1] if defined $_[1]; return $_[0]->{_api_key}; } | ||||||||
|
Subroutine
api_key: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||
| 61 | |||||||||||
| 62 | |||||||||||
| 63 | =head2 password([$new_password]) | ||||||||||
| 64 | |||||||||||
| 65 | Gets/sets the app's private password. | ||||||||||
| 66 | |||||||||||
| 67 | =cut | ||||||||||
| 68 | |||||||||||
| 69 | 0 | ▶ | sub password { $_[0]->{_password} = $_[1] if defined $_[1]; return $_[0]->{_password}; } | ||||||||
|
Subroutine
password: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||
| 70 | |||||||||||
| 71 | =head1 SEE ALSO | ||||||||||
| 72 | |||||||||||
| 73 | L<WWW::Shopify::Item>, L<WWW::Shopify> | ||||||||||
| 74 | |||||||||||
| 75 | =head1 AUTHOR | ||||||||||
| 76 | |||||||||||
| 77 | Adam Harrison (adamdharrison@gmail.com) | ||||||||||
| 78 | |||||||||||
| 79 | =head1 LICENSE | ||||||||||
| 80 | |||||||||||
| 81 | See LICENSE in the main directory. | ||||||||||
| 82 | |||||||||||
| 83 | =cut | ||||||||||
| 84 | |||||||||||
| 85 | |||||||||||
| 86 | 1 | 1; | |||||||||