api

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2018 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const DateLayout = "2006-01-02"

DateLayout expected layout format for the Date type

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientReader

type ClientReader interface {
	GET(url string, responseModel interface{}) error
}

ClientReader contract for a read only client

type ClientReaderWriter

type ClientReaderWriter interface {
	ClientReader
	ClientWriter
}

ClientReaderWriter contract for a read-write client

type ClientWriter

type ClientWriter interface {
	POST(url string, responseModel interface{}, requestBody []byte) error
	PUT(url string, responseModel interface{}, requestBody []byte) error
}

ClientWriter contract for a write only client

type Date

type Date struct {
	time.Time
}

Date represents a budget date

func DateFromString

func DateFromString(s string) (Date, error)

DateFromString creates a new Date from a given string date formatted as DateLayout

Example
package main

import (
	"fmt"

	"go.bmvs.io/ynab/api"
)

func main() {
	date, _ := api.DateFromString("2020-01-20")
	fmt.Println(date)

}
Output:

2020-01-20 00:00:00 +0000 UTC

func (*Date) MarshalJSON

func (d *Date) MarshalJSON() ([]byte, error)

MarshalJSON parses the expected format for a Date

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(b []byte) error

UnmarshalJSON parses the expected format for a Date

type Error

type Error struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Detail string `json:"detail"`
}

Error represents an API Error

func (Error) Error

func (e Error) Error() string

Error returns the string version of the error

type RateLimit added in v1.1.0

type RateLimit struct {
	// contains filtered or unexported fields
}

RateLimit represents an API rate limit

func ParseRateLimit added in v1.1.0

func ParseRateLimit(rateLimit string) (*RateLimit, error)

ParseRateLimit returns a *RateLimit for a given rate limit string

Example
package main

import (
	"fmt"

	"go.bmvs.io/ynab/api"
)

func main() {
	r, _ := api.ParseRateLimit("1/200")
	fmt.Println(r.Used())

}
Output:

1

func (*RateLimit) Total added in v1.1.0

func (r *RateLimit) Total() uint64

Total represents the total rate limit

func (*RateLimit) Used added in v1.1.0

func (r *RateLimit) Used() uint64

Used represents the used rate limit

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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