yapla

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 7 Imported by: 0

README

go-yapla

Go Report Card Go Reference Go coverage Apache V2 License

Support Yapla API 2.0
Official documentation available here

Getting Started

Dependencies

No extra dependency are needed

Go mod

To get a specific release version use @<tag> in your go get command.

go get git.iglou.eu/Production/go-yapla@v0.0.1

Or @latest to get the latest repository change

go get git.iglou.eu/Production/go-yapla@latest

Quick Example

This example shows a complete working Go file which will login a member and showing their information map

package main

import (
	"fmt"
	"log"

	"git.iglou.eu/Production/go-yapla"
)

func main() {
    // Create a new required instance
    //
    // Need to provide a valid Yapla API Key 
    //
    // You can overwrite default configuration
    // For this provide an extra argument like
    // yapla.Config{...}
	y, err := yapla.NewSession("HP1ST252NFKX6Z6RVJ4RKEU23WS2QXSTQHTVYA1JAFWYX306")
	if err != nil {
		log.Fatalln(err)
	}

    // Login a Yapla member of your organisation
    // Need "only" user email and user password
    //
    // Return a struct with the API reply state and data on map format
    //
    // LoginContact() function is also avilable
	yRep, err := y.LoginMember("moncompte@macompagnie.com", "monp4ssW0R4!")
	if err != nil {
		log.Fatalln(err)
	}

	fmt.Println(yRep.Data)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

type Api struct {

	// Api setting, see Config struct.
	Config Config
	// contains filtered or unexported fields
}

Api denotes the Yapla API client session.

func NewSession

func NewSession(apiKey string, config ...Config) (*Api, error)

NewSession create a named client connection with Yapla v2.0 API Authenticate admin Yapla and set Session token You can pass optional configuration options with Config struct:

  y := yappla.NewSession(
		  "xxxxxxxxxxxxxxx"
	  	  fiber.Config{
     	  URL: "https://s2.yapla.com/api/2",
     	  Timeout: time.Second * 30,
		  },
  )

func (*Api) LoginContact

func (api *Api) LoginContact(login, password string) (Reply, error)

LoginContact login to your Yapla account Using for access to all informations about this contact

func (*Api) LoginMember

func (api *Api) LoginMember(login, password string) (Reply, error)

LoginMember login to your Yapla account Using for access to all informations about this member

type Config

type Config struct {
	// Base URL to target API server.
	//
	// Default: "https://s1.yapla.com/api/2"
	URL string

	// The maximum amount of time to wait for the end of the request.
	//
	// Default: time.Second * 10
	Timeout time.Duration
}

Config is a struct holding the api setting.

type Reply

type Reply struct {
	// Status of actual request
	//
	// Success = true
	Result bool `json:"result"`

	// Due to inconsistent data structure, this is a map of interface
	//
	// Success response can be ... anything
	// Data: {
	//	 string: string/[]interface{},
	// }
	//
	// Error response are "consistent"
	// Data: {
	//	 "code": 524,
	//	 "type": "error_bad_login_pawssord",
	//	 "message": "Error's message",
	// }
	//
	// Can be string or sub map
	Data map[string]interface{} `json:"data"`
}

Reply is a struct holding the api response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL