Giter VIP home page Giter VIP logo

factom-api's Introduction

Factom API for Laravel

Latest Version Software License Build Status Quality Score StyleCI Total Downloads

This package provides a simple service provider for the Factom API for use with the Laravel Framework.

Factom API documentation: https://docs.factom.com/api

Note: This package is under development and should not be used for production environments.

Installation

You can install this package via composer using:

composer require adrianmejias/factom-api

You must also install this service provider in conifg/app.php.

'providers' => [
  ...
  
  AdrianMejias\FactomApi\FactomApiServiceProvider::class,
  
  ...

The package will automatically register itself. If not, then add the alias in config/app.php.

'aliases' => [
  ...
  
  'FactomApi' => AdrianMejias\FactomApi\Facades\FactomApi::class,
  'FactomWalletApi' => AdrianMejias\FactomApi\Facades\FactomWalletApi::class,
  'FactomDebugApi' => AdrianMejias\FactomApi\Facades\FactomDebugApi::class,
  
  ...

To publish the config file to app/config/factom-api.php

php artisan vendor:publish --provider="AdrianMejias\FactomApi\FactomApiServiceProvider"

This will publish a file factom-api.php in your config directory with teh following content:

<?php

return [
  
  /**
   * Base credentials for Factom server.
   */
  'url' => env('FACTOM_URL', 'http://localhost:8088/v2'),

  'ssl' => [
    'enable' => env('FACTOM_SSL', false),
    'certificate' => env('FACTOM_CERTIFICATE', storage_path('app/factomdAPIpub.cert')),
  ],

  'username' => env('FACTOM_USERNAME'),

  'password' => env('FACTOM_PASSWORD'),

  /**
   * Factom wallet server credentials.
   */
  'wallet' => [
    'url' => env('FACTOM_WALLET_URL', 'http://localhost:8089/v2'),

    'ssl' => [
      'enable' => env('FACTOM_WALLET_SSL', false),
      'certificate' => env('FACTOM_WALLET_CERTIFICATE', storage_path('app/factomdAPIpub.cert')),
    ],

    'username' => env('FACTOM_WALLET_USERNAME'),

    'password' => env('FACTOM_WALLET_PASSWORD'),
  ],

  /**
   * Factom debug server credentials.
   */
  'debug' => [
    'url' => env('FACTOM_DEBUG_URL', 'http://localhost:8088/debug'),

    'ssl' => [
      'enable' => env('FACTOM_DEBUG_SSL', false),
      'certificate' => env('FACTOM_DEBUG_CERTIFICATE', storage_path('app/factomdAPIpub.cert')),
    ],

    'username' => env('FACTOM_DEBUG_USERNAME'),

    'password' => env('FACTOM_DEBUG_PASSWORD'),
  ],

];

Usage

After you've installed the package and filled in the values in the config-file working with this pacakge will be a breeze. All the following examples use the facade.

Route::get('/factom/heights', function() {
  $result = FactomApi::heights();

  return response()->json($result);
});

Todo

  • Replace Curl with Guzzle
  • Add Wallet methods
  • Add certificate auth
  • Add unit tests

Testing

Run the tests with:

vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

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

factom-api's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.