api

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2018 License: BSD-2-Clause Imports: 6 Imported by: 16

Documentation

Overview

Package api implements shared structures and behaviours of the API services

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DateFormat

func DateFormat(date Date) string

DateFormat creates a new string from a given api.Date formatted as dateLayout

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

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

RateLimit represents an API rate limit

func ParseRateLimit

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

func (r *RateLimit) Total() uint64

Total represents the total rate limit

func (*RateLimit) Used

func (r *RateLimit) Used() uint64

Used represents the used rate limit

Directories

Path Synopsis
Package account implements account entities and services
Package account implements account entities and services
Package budget implements budget entities and services
Package budget implements budget entities and services
Package category implements category entities and services
Package category implements category entities and services
Package month implements month entities and services
Package month implements month entities and services
Package payee implements payee entities and services
Package payee implements payee entities and services
Package transaction implements transaction entities and services
Package transaction implements transaction entities and services
Package user implements transaction user and services
Package user implements transaction user and services

Jump to

Keyboard shortcuts

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