Giter Site home page Giter Site logo

aolmez / xendit-go Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xendit/xendit-go

0.0 1.0 0.0 274 KB

Xendit REST API Client for Go - Card, Virtual Account, Invoice, Disbursement, Recurring Payments, Payout, EWallet, Balance, Retail Outlets Services, QR Codes

Home Page: https://developers.xendit.co/api-reference/

License: MIT License

Makefile 0.14% Go 99.82% Shell 0.03%

xendit-go's Introduction

Xendit API Go Client

go.dev reference Coverage Status Go Report Card

This library is the abstraction of Xendit API for access from applications written with Go.

Documentation

For the API documentation, check Xendit API Reference.

For the details of this library, see the GoDoc.

Installation

Install xendit-go with:

go get -u github.com/xendit/xendit-go

Then, import it using:

import (
    "github.com/xendit/xendit-go"
    "github.com/xendit/xendit-go/$product$"
)

with $product$ is the product of Xendit such as invoice and balance.

Go Module Support

This library supports Go modules by default. Simply require xendit-go in go.mod with a version like so:

module github.com/my/package

go 1.13

require (
  github.com/xendit/xendit-go v1.0.0
)

And use the same style of import paths as above:

import (
    "github.com/xendit/xendit-go"
    "github.com/xendit/xendit-go/$product$"
)

with $product$ is the product of Xendit such as invoice and balance.

Using xendit-go with $GOPATH

If you are still using $GOPATH and not planning to migrate to go mod, installing xendit-go would require installing its (only) dependency validator via

go get -u github.com/go-playground/validator

Please note that this means you are using master of validator and effectively miss out on its versioning that's gomod-based.

After installing validator, xendit-go can be installed normally.

Usage

The following pattern is applied throughout the library for a given $product$:

Without Client

If you're only dealing with a single secret key, you can simply import the packages required for the products you're interacting with without the need to create a client.

import (
    "github.com/xendit/xendit-go"
    "github.com/xendit/xendit-go/$product$"
)

// Setup
xendit.Opt.SecretKey = "examplesecretkey"

xendit.SetAPIRequester(apiRequester) // optional, useful for mocking

// Create
resp, err := $product$.Create($product$.CreateParams)

// Get
resp, err := $product$.Get($product$.GetParams)

// GetAll
resp, err := $product$.GetAll($product$.GetAllParams)

With Client

If you're dealing with multiple secret keys, it is recommended you use client.API. This allows you to create as many clients as needed, each with their own individual key.

import (
    "github.com/xendit/xendit-go"
    "github.com/xendit/xendit-go/client"
)

// Basic setup
xenCli := client.New("examplesecretkey")

// or with optional, useful-for-mocking `exampleAPIRequester`
xenCli := client.New("examplesecretkey").WithAPIRequester(exampleAPIRequester)

// Create
resp, err := xenCli.$product$.Create($product$.CreateParams)

// Get
resp, err := xenCli.$product$.Get($product$.GetParams)

// GetAll
resp, err := xenCli.$product$.GetAll($product$.GetAllParams)

Sub-Packages Documentations

The following is a list of pointers to documentations for sub-packages of xendit-go.

Contribute

For any requests, bugs, or comments, please open an issue or submit a pull request.

Test

After modifying the code, please make sure that the code passes all test cases.

Run all tests

go test ./...

Run tests for a package

go test ./invoice

Run a single test

go test ./invoice -run TestCreateInvoice

Run integration tests

SECRET_KEY=<your secret key> go run ./integration_test

Pre-commit

Before making any commits, please install pre-commit. To install pre-commit, follow the installation steps.

After installing the pre-commit, please install the needed dependencies:

make init

After the code passes everything, please submit a pull request.

xendit-go's People

Contributors

stanleynguyen avatar kevindavee avatar ervanadetya avatar mychaelgo avatar mantishk avatar

Watchers

James Cloos 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.