atapi

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2023 License: MIT Imports: 5 Imported by: 93

README

atapi

An Iteung API Interface HTTTP Method

package main

import (
 "fmt"
 "github.com/aiteung/atapi"
)

type TestApi struct {
 Phone      string `json:"phoneNumber"`
 Password   string `json:"password"`
 FirebaseId string `json:"firebaseId"`
 DeviceId   string `json:"deviceId"`
}

type Sister struct {
 Id_sdm string `url:"id_sdm" json:"id_sdm"`
}

type Response struct{
 Message      string `json:"message"`
 Status   string `json:"status"`
}

func main(){
 var res Response
 dt := TestApi{
    Phone:      "+6285155476774",
    Password:   "#P@ssw0rd",
    FirebaseId: "123",
    DeviceId:   "6580fb6e714844ca",
 }
 url := "https://awangga.requestcatcher.com/"
 res = atapi.PostStruct[Response](dt, url)
 fmt.Println("TestPostStruct : ", res)
 res = atapi.Get[Response](url)
 fmt.Println("TestPostStruct : ", res)
 res = atapi.GetStructWithToken[Response]("token", "dsfdsfdsfdsfdsf", dt, url)
 fmt.Println("GetStructWithToken : ", res)
 res = PostStructWithToken[Response]("Login", "dsfdsfdsfdsfdsf", dt, url)
 fmt.Println("PostStructWithToken : ", res)
 res = PostStructWithBearer[Response]("dsfdsfdsfdsfdsf", dt, url)
 fmt.Println("PostStructWithBearer : ", res)
 res = GetStructWithBearer[Response]("dsfdsfdsfdsfdsf", dt, url)
 fmt.Println("GetStructWithBeare : ", res)
 res = GetStruct[Response](dt, url)
 fmt.Println("GetStruct : ", res)

}

Tagging

git tag v0.0.1
git push origin --tags
go list -m github.com/aiteung/atapi@v0.0.1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get added in v0.0.2

func Get[T any](urltarget string) (result T, errormessage string)

func GetImageWithBearer added in v0.0.12

func GetImageWithBearer(tokenbearer string, urltarget string) (respBody []byte, errormessage string)

func GetStruct added in v0.0.3

func GetStruct[T any](structname interface{}, urltarget string) (result T, errormessage string)

func GetStructWithBearer added in v0.0.8

func GetStructWithBearer[T any](tokenbearer string, structname interface{}, urltarget string) (result T, errormessage string)

func GetStructWithToken added in v0.0.6

func GetStructWithToken[T any](tokenkey string, tokenvalue string, structname interface{}, urltarget string) (result T, errormessage string)

func GetWithBearer added in v0.0.11

func GetWithBearer[T any](tokenbearer string, urltarget string) (result T, errormessage string)

func PostStruct

func PostStruct[T any](structname interface{}, urltarget string) (result T, errormessage string)

func PostStructWithBearer added in v0.0.8

func PostStructWithBearer[T any](tokenbearer string, structname interface{}, urltarget string) (result T, errormessage string)

func PostStructWithToken added in v0.0.6

func PostStructWithToken[T any](tokenkey string, tokenvalue string, structname interface{}, urltarget string) (result T, errormessage string)

func PutStructWithBearer added in v0.0.13

func PutStructWithBearer[T any](tokenbearer string, structname interface{}, urltarget string) (result T, errormessage string)

Types

type Token added in v0.0.4

type Token struct {
	Key    string
	Values string
}

Jump to

Keyboard shortcuts

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