NAME
Stancer::Core::Object - Basic API object
VERSION
version 1.0.2
DESCRIPTION
You should not use this class directly.
This module is an internal class, regouping method for every API object.
ATTRIBUTES
id
Read-only 29 characters string.
Current object identifier.
created
Read-only instance of DateTime
.
A DateTime object representing the creation date.
Value is only present for object returned by the API, so the method can return undef
.
endpoint
Read-only string.
API endpoint.
is_modified
is_not_modified
Read/Write boolean.
Indicate if the current object is modified or not.
populated
Read-only boolean.
Indicate if the current object has been populated from API data.
uri
Read-only String.
Return a complete location for the current object.
METHODS
Stancer::Core::Object->new() : self
Stancer::Core::Object->new($token) : self
Stancer::Core::Object->new(%args) : self
Stancer::Core::Object->new(\%args) : self
This method accept an optional string, it will be used as an entity ID for API calls.
$obj->del() : self
Delete the current object.
$obj->get() : hash | undef
$obj->get( $attr ) : mixed
Return raw data from the API.
$attr
must be a string, keys should be an object property.
$obj->hydrate( \%data ) : self
$obj->hydrate( %data ) : self
Hydrate the current object.
%data
must be an hash or a hashref, keys should be an object property.
$obj->populate() : self
Contact the API to populate current object.
$obj->save() : self
Save the current object.
$obj->send() : self
Send the current object.
$obj->toJSON() : string
Return a JSON representation of current object.
$obj->to_hash() : hash
Return an hash representing the current object.
$obj->TO_JSON() : hash
Return an hash representing the current object.
This method is used by JSON module for convertions.
USAGE
Logging
We use the Log::Any framework for logging events. You may tell where it should log using any available Log::Any::Adapter module.
For example, to log everything to a file you just have to add a line to your script, like this: #! /usr/bin/env perl use Log::Any::Adapter (File => '/var/log/payment.log'); use Stancer::Core::Object;
You must import Log::Any::Adapter
before our libraries, to initialize the logger instance before use.
You can choose your log level on import directly: use Log::Any::Adapter (File => '/var/log/payment.log', log_level => 'info');
Read the Log::Any documentation to know what other options you have.
SECURITY
Never, never, NEVER register a card or a bank account number in your database.
Always uses HTTPS in card/SEPA in communication.
Our API will never give you a complete card/SEPA number, only the last four digits. If you need to keep track, use these last four digit.
BUGS
Please report any bugs or feature requests on the bugtracker website https://gitlab.com/wearestancer/library/lib-perl/-/issues or by email to bug-stancer@rt.cpan.org.
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
AUTHOR
Joel Da Silva <jdasilva@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2018-2024 by Stancer / Iliad78.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)