api

package
v1.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package api provides HTTP client for GitScrum API

Package api provides shared types for the GitScrum API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeResponse

func DecodeResponse(resp *http.Response, target interface{}) error

DecodeResponse decodes JSON response body into target struct

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
	Errors     map[string][]string `json:"errors,omitempty"`
}

APIError represents an error from the API

func (*APIError) Error

func (e *APIError) Error() string

type Client

type Client struct {
	BaseURL    string
	HTTPClient *http.Client
	Token      *auth.Token
}

Client handles HTTP requests to GitScrum API

func NewClient

func NewClient(baseURL string, token *auth.Token) *Client

NewClient creates a new API client

func (*Client) Delete

func (c *Client) Delete(path string) (*http.Response, error)

Delete makes a DELETE request

func (*Client) Get

func (c *Client) Get(path string) (*http.Response, error)

Get makes a GET request

func (*Client) Patch

func (c *Client) Patch(path string, body interface{}) (*http.Response, error)

Patch makes a PATCH request

func (*Client) Post

func (c *Client) Post(path string, body interface{}) (*http.Response, error)

Post makes a POST request

func (*Client) Put

func (c *Client) Put(path string, body interface{}) (*http.Response, error)

Put makes a PUT request

func (*Client) Request

func (c *Client) Request(method, path string, body interface{}) (*http.Response, error)

Request makes an HTTP request to the API

type DateResource

type DateResource struct {
	DateForHumans string `json:"date_for_humans"`
	ISO8601       string `json:"iso8601"`
	Timestamp     int64  `json:"timestamp"`
}

DateResource represents a date object from the API (DateResource.php) All dates in the API are returned in this format with timezone-aware fields.

func (*DateResource) DateTime

func (d *DateResource) DateTime() string

DateTime returns date and time (YYYY-MM-DD HH:MM) from ISO8601

func (*DateResource) FormatDate

func (d *DateResource) FormatDate() string

FormatDate returns the human-readable date or ISO8601 fallback

func (*DateResource) FormatISO

func (d *DateResource) FormatISO() string

FormatISO returns the ISO8601 date string

func (*DateResource) ISODate

func (d *DateResource) ISODate() string

ISODate returns just the date portion (YYYY-MM-DD) from ISO8601

Jump to

Keyboard shortcuts

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