nekoding/rajaongkir

Rajaongkir PHP Client Library

v1.2.1 2023-05-30 22:23 UTC

This package is auto-updated.

Last update: 2024-10-30 01:48:33 UTC


README

All Contributors

Latest Version on Packagist Total Downloads GitHub Actions CodeFactor

Library PHP sederhana untuk konek ke API Rajaongkir. Projek ini terinspirasi dari https://github.com/kavist/rajaongkir

Installation

You can install the package via composer:

composer require nekoding/rajaongkir

Usage

// Menggunakan class resource
$province = new \Nekoding\Rajaongkir\Resources\Province("api_key_rajaongkir", "api_mode");
$province->find(1);
$province->get();

// Menggunakan wrapper class rajaongkir
\Nekoding\Rajaongkir\Utils\Config::setApiKey("api_key_rajaongkir");
\Nekoding\Rajaongkir\Utils\Config::setApiMode("starter");
$rajaongkir = \Nekoding\Rajaongkir\Rajaongkir::province()->find(1);
$rajaongkir = \Nekoding\Rajaongkir\Rajaongkir::province()->get();

// Jika ingin melakukan pencarian data berdasarkan nama provinsi
$province = new \Nekoding\Rajaongkir\Resources\Province("api_key_rajaongkir", "api_mode");
$province->search("bali")->get();

// Jika ingin melakukan pencarian data berdasarkan nama kota
$city = new \Nekoding\Rajaongkir\Resources\City("api_key_rajaongkir", "api_mode");
$city->search("denpasar")->get();

// Jika ingin melakukan pengecekan biaya ongkos kirim
$cost = new \Nekoding\Rajaongkir\Resources\Cost("api_key_rajaongkir", "api_mode");
$cost->setOrigin(501);
$cost->setDestination(114);
$cost->setWeight(1700);
$cost->setCourier("jne");

$result = $cost->get();

Untuk contoh lainnya cek folder examples atau tests

Default Value

Testing

composer test

Feature

  • Starter API (Province, City, Cost)
  • Get data by province_name, city_name (using PHP Fuse)
  • Support PHP 7.4, PHP 8.0, PHP 8.1, PHP 8.2

TODO

  • Basic API
  • Pro API

Contributors

License

The MIT License (MIT). Please see License File for more information.