Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kianmeng/webservice-swapi
The Perl helper library for Star War API, http://swapi.co
https://github.com/kianmeng/webservice-swapi
api cpan perl star-wars
Last synced: 3 days ago
JSON representation
The Perl helper library for Star War API, http://swapi.co
- Host: GitHub
- URL: https://github.com/kianmeng/webservice-swapi
- Owner: kianmeng
- License: other
- Created: 2017-01-15T17:16:31.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-05-02T13:53:25.000Z (almost 6 years ago)
- Last Synced: 2024-12-11T06:08:27.220Z (about 2 months ago)
- Topics: api, cpan, perl, star-wars
- Language: Perl
- Homepage:
- Size: 105 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
[![Cpan license](https://img.shields.io/cpan/l/WebService-Swapi.svg)](https://metacpan.org/release/WebService-Swapi)
[![Cpan version](https://img.shields.io/cpan/v/WebService-Swapi.svg)](https://metacpan.org/release/WebService-Swapi)# NAME
WebService::Swapi - Perl library for accessing the Star Wars data,
http://swapi.co# SYNOPSIS
use WebService::Swapi;
$swapi = WebService::Swapi->new;
# Check if API server is up
my $resources = $swapi->ping();# Get information of all available resources
my $resources = $swapi->resources();# View the JSON schema for people resource
my $schema = $swapi->schema('people');# Searching
my $results = $swapi->search('people', 'solo');# Get resource item
my $item = $swapi->get_object('films', '1');# DESCRIPTION
WebService::Swapi is a Perl client helper library for the Star Wars API (swapi.co).
# DEVELOPMENT
Source repository at [https://github.com/kianmeng/webservice-swapi](https://github.com/kianmeng/webservice-swapi).
## Docker
If you have Docker installed, you can build your Docker container for this
project.$ docker build -t webservice-swapi .
$ docker run -it -v $(pwd):/root webservice-swapi bash
# cpanm --installdeps --notest .## Milla
Setting up the required packages.
$ milla authordeps --missing | cpanm
$ milla listdeps --missing | cpanmCheck you code coverage.
$ milla cover
Several ways to run the test.
$ milla test
$ milla test --author --release
$ AUTHOR_TESTING=1 RELEASE_TESTING=1 milla test
$ AUTHOR_TESTING=1 RELEASE_TESTING=1 milla run prove t/01_instantiation.tRelease the module.
$ milla build
$ milla release# METHODS
## new(\[%$args\])
Construct a new WebService::Swapi instance. Optionally takes a hash or hash reference.
# Instantiate the class.
my $swapi = WebService::Swapi->new;### api\_url
The URL of the API resource.
# Instantiate the class by setting the URL of the API endpoints.
my $swapi = WebService::Swapi->new({api_url => 'http://example.com/api/'});## get\_object($object, \[$format\])
Get full details of a object or resource. Optionally takes a returned format.
# Get the details of different available object using id.
my $object = $swapi->get_object('films', '1');# Get the result in different format.
my $object_json = $swapi->get_object('films', '1', 'json');
my $object_wookie = $swapi->get_object('films', '1', 'wookiee');## ping()
Check if the API service or server is responding to a request.
my $server_status = $swapi->ping();
## resources(\[$format\])
List down all the available objects. Optionally takes a returned format.
# Get all available resources or objects.
my $resources = $swapi->resources();# Similarly but in different format.
my $resources_json = $swapi->resources('json');
my $resources_wookie = $swapi->resources('wookie');## schema($object)
Show the data structure of a resource or object.
# Get the schema / structure of a resource or object.
my $schema = $swapi->schema('people');## search($object, $keyword, \[$format\])
Searching by keywords. Takes both an object and keywords. Optionally takes a returned format.
# Search a resource or object by keywords.
my $results = $swapi->search('people', 'solo');# Or in different format.
my $results = $swapi->search('people', 'solo', 'json');
my $results = $swapi->search('people', 'solo', 'wookiee');# AUTHOR
Kian-Meng, Ang
# COPYRIGHT AND LICENSE
This software is Copyright (c) 2017 by Kian Meng, Ang.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)