Giter Club home page Giter Club logo

apidq-client-go's Introduction

ApiDQ API GoLang Client

Godoc Reference GitHub tag (latest by date) GitHub Workflow Status codecov License


This is the GoLang ApiDQ API client. This library allows using of the actual API version. You can find more info in the documentation.

Installation

Follow those steps to install the library:

  1. Import the library our code:
go get github.com/nikitaksv/apidq-client-go

Usage

The client is separated into several resource groups, all of which are accessible through the Client's public properties. You can call API methods from those groups like this:

package main

import (
	"context"
	"fmt"
	"net/http"

	"github.com/nikitaksv/apidq-client-go"
	"github.com/nikitaksv/apidq-client-go/dto/address"
)

func main() {
	client, err := apidq.NewClient(http.DefaultClient, apidq.BaseURL)
	if err != nil {
		panic(err)
	}

	client.WithAuth("your token here")
	// Or set a individual ApiKey for a specific service
	// client.WithAuthService("you_token_here", "address")

	cleanRsp, _, err := client.Address.Clean(context.TODO(), &address.CleanRequest{
		Query:       "москва спартаковская 10с12",
		CountryCode: "RU",
	})
	if err != nil {
		if serviceErr, ok := err.(*apidq.ErrorResponse); ok {
			fmt.Printf("Code: %d; Message: %s", serviceErr.Code, serviceErr.Message)
		}
		panic(err)
	}

	fmt.Println(cleanRsp.Address.Address) // -- print: г Москва, пл Спартаковская
}

To handle errors you must use one type of errors:

  • apidq.ErrorResponse for the api service error.

apidq-client-go's People

Contributors

nikitaksv avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

apiship

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.