Business-DPD-SK

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

        /etc/dpd-sk/geordb.ini); see Business::DPD::SK::SPc.

        The file holds the SFTP password, so "./Build install" installs it
        with mode 0640. On upgrades the mode never becomes more permissive
        than it was, so a stricter mode set by the admin is kept. The
        install does not change the owner; give the group of the user that
        runs the download read access.

    etc/dpd-sk/api.ini
        Endpoint URL and account settings for Business::DPD::SK::API. The
        shipped copy selects the DPD test endpoint and holds placeholder
        credentials; the production URL is present but commented out. It is
        installed next to geordb.ini, with the same 0640 mode handling,
        because it holds the API key.

    var/lib/dpd-sk/
        holds the most recent downloaded GeoRDB zip file. The user that runs
        "update" in Business::DPD::SK::GeoRDB needs write access to it; the
        install does not change ownership.

AUTHOR

etc/dpd-sk/api.ini  view on Meta::CPAN

; DPD Slovakia shipment API settings.
; Replace the account values on the installed system copy
[api]
; test endpoint
base_url=https://capi.dpd.sk/shipment/json
; production endpoint
;base_url=https://api.dpd.sk/shipment/json
api_email=user@example.com
api_key=secret
delis_id=DELIS_ID
sender_address_id=0

lib/Business/DPD/SK.pm  view on Meta::CPAN

L<Business::DPD::SK::SPc>.

The file holds the SFTP password, so C<./Build install> installs it with mode
C<0640>. On upgrades the mode never becomes more permissive than it was, so a
stricter mode set by the admin is kept. The install does not change the
owner; give the group of the user that runs the download read access.

=item F<etc/dpd-sk/api.ini>

Endpoint URL and account settings for L<Business::DPD::SK::API>. The shipped
copy selects the DPD test endpoint and holds placeholder credentials; the
production URL is present but commented out. It is installed next to
F<geordb.ini>, with the same C<0640> mode handling, because it holds the API
key.

=item F<var/lib/dpd-sk/>

holds the most recent downloaded GeoRDB zip file. The user that runs
L<Business::DPD::SK::GeoRDB/update> needs write access to it; the install
does not change ownership.

lib/Business/DPD/SK/API.pm  view on Meta::CPAN

__END__

=head1 NAME

Business::DPD::SK::API - create DPD Slovakia shipments and fetch labels

=head1 SYNOPSIS

    use Business::DPD::SK::API;

    # account settings and endpoint from dpd-sk/api.ini
    my $api = Business::DPD::SK::API->new();
    my $res = $api->create(
        recipient_address => {...},
        parcels           => [{weight => 2.5}],
        reference         => 'PO-1',
        labels_filename   => '/tmp/labels.pdf',
    );
    say $res->{msid};

    # constructor arguments override the config file

lib/Business/DPD/SK/API.pm  view on Meta::CPAN

    );

=head1 DESCRIPTION

Thin client for the C<createV3> method of the DPD Slovakia shipment JSON-RPC
API. One call to L</create> registers one shipment with one or more parcels
and saves the label PDF that DPD returns.

=head2 Configuration file

The endpoint and the account settings come from the INI file in
L</config_file>, by default F<dpd-sk/api.ini> below
L<Business::DPD::SK::SPc/sysconfdir> (for example
F</etc/dpd-sk/api.ini> after C<./Build install>). Its C<[api]> section has one
key per attribute:

    [api]
    ; test endpoint
    base_url=https://capi.dpd.sk/shipment/json
    ; production endpoint
    ;base_url=https://api.dpd.sk/shipment/json
    api_email=user@example.com
    api_key=secret
    delis_id=DELIS_ID
    sender_address_id=0

The shipped file selects the test endpoint
C<https://capi.dpd.sk/shipment/json> and holds placeholder account values.
B<To create real shipments, switch the C<base_url> lines to the production
endpoint and fill in the real account values.> DPD may issue separate
credentials for the test and production endpoints; keep them matching the
active C<base_url>.

Each of the five attributes takes its value from the constructor if given,
otherwise from the file. The file is read once, the first time a value is
needed that the constructor did not supply. An object built with all five
values never reads the file.

The file holds the API key. C<./Build install> installs it with mode C<0640>;
give the group of the user that runs the client read access.

t/00_load.t  view on Meta::CPAN

use_ok('Business::DPD::SK');
use_ok('Business::DPD::SK::SPc');
use_ok('Business::DPD::SK::API');

like(Business::DPD::SK->VERSION, qr/^\d+\.\d+/, 'distribution has a version');

subtest 'checkout paths point into the distribution' => sub {
    my $ini = File::Spec->catfile(Business::DPD::SK::SPc->sysconfdir, 'dpd-sk', 'geordb.ini');
    ok(-f $ini, 'geordb.ini found via sysconfdir');
    is(Business::DPD::SK::API->new->base_url, 'https://capi.dpd.sk/shipment/json',
        'shipped api.ini found via sysconfdir and selects the test endpoint');
    my $state = File::Spec->catdir(Business::DPD::SK::SPc->sharedstatedir, 'dpd-sk');
    ok(-d $state, 'dpd-sk state directory found via sharedstatedir');
};

done_testing();



( run in 0.828 second using v1.01-cache-2.11-cpan-74eac9f7fe2 )