sfapi

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2020 License: MIT Imports: 10 Imported by: 1

README

Sourceforge API Library

Based on https://github.com/google/go-github

Example

sfClient = sfapi.NewClient(nil, project)

tickets, _, err := sfClient.Tracker.Info(category)

for _, ticket := range tickets.Tickets {
	ticket, _, err := sfClient.Tracker.Get(category, ticket.TicketNum)

	fmt.Println(ticket)
}

Documentation

Overview

Package github provides a client for using the Sourceforge.net API. Sourceforge API docs: https://anypoint.mulesoft.com/apiplatform/sourceforge/#/portals/organizations/98f11a03-7ec0-4a34-b001-c1ca0e0c45b1/apis/32951/versions/34322

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.

Types

type Client

type Client struct {
	BaseURL *url.URL
	Project string

	// Services
	Tracker *TrackerService
	// contains filtered or unexported fields
}

Client manages communication with the Sourceforge API

func NewClient

func NewClient(httpClient *http.Client, project string) *Client

NewClient returns a new Sourceforge API client. If nil httpClient provided, http.DefaultClient will be used.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.

func (*Client) NewRequest

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

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type DiscussionPost

type DiscussionPost struct {
	Attachments []TicketAttachment `json:"attachments"`
	Author      string             `json:"author"`
	LastEdited  interface{}        `json:"last_edited"`
	Slug        string             `json:"slug"`
	Subject     string             `json:"subject"`
	Text        string             `json:"text"`
	Timestamp   string             `json:"timestamp"`
}

DiscussionPost represents comments on a Sourceforge issue

func (DiscussionPost) TimestampTime added in v1.3.0

func (t DiscussionPost) TimestampTime() time.Time

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response
}

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type Milestone

type Milestone struct {
	Closed   int  `json:"closed"`
	Complete bool `json:"complete"`
	// Default     bool   `json:"default"` // bool or string in sourceforge
	Description string `json:"description"`
	DueDate     string `json:"due_date"`
	Name        string `json:"name"`
	Total       int    `json:"total"`
}

Milestone represents project milestones, comes in TrackerInfo

func (*Milestone) DueTime added in v1.2.0

func (m *Milestone) DueTime() time.Time

type RequestQuery added in v1.1.0

type RequestQuery struct {
	Page  int
	Limit int
}

RequestQuery Object represents what fields can be added to query string

func NewRequestQuery added in v1.1.0

func NewRequestQuery() *RequestQuery

NewRequestQuery Creates a RequestQuery object with default values

type Response

type Response struct {
	Response *http.Response
}

type Ticket

type Ticket struct {
	ID           string             `json:"_id"`
	AssignedTo   string             `json:"assigned_to"`
	AssignedToID string             `json:"assigned_to_id"`
	Attachments  []TicketAttachment `json:"attachments"`
	CreatedDate  string             `json:"created_date"`
	CustomFields struct {
		Milestone string `json:"_milestone"`
		Priority  string `json:"_priority"`
	} `json:"custom_fields"`
	Description        string `json:"description"`
	DiscussionDisabled bool   `json:"discussion_disabled"`
	DiscussionThread   struct {
		ID           string           `json:"_id"`
		DiscussionID string           `json:"discussion_id"`
		Limit        int              `json:"limit"`
		Page         interface{}      `json:"page"`
		Posts        []DiscussionPost `json:"posts"`
		Subject      string           `json:"subject"`
	} `json:"discussion_thread"`
	DiscussionThreadURL string        `json:"discussion_thread_url"`
	Labels              []string      `json:"labels"`
	ModDate             string        `json:"mod_date"`
	Private             bool          `json:"private"`
	RelatedArtifacts    []interface{} `json:"related_artifacts"`
	ReportedBy          string        `json:"reported_by"`
	ReportedByID        string        `json:"reported_by_id"`
	Status              string        `json:"status"`
	Summary             string        `json:"summary"`
	TicketNum           int           `json:"ticket_num"`
	VotesDown           int           `json:"votes_down"`
	VotesUp             int           `json:"votes_up"`
}

Ticket represents Sourceforge issue

func (*Ticket) CreatedTime added in v1.2.0

func (t *Ticket) CreatedTime() time.Time

func (*Ticket) ModTime added in v1.2.0

func (t *Ticket) ModTime() time.Time

type TicketAttachment

type TicketAttachment struct {
	Bytes int    `json:"bytes"`
	URL   string `json:"url"`
}

TicketAttachment represents attachments of a ticket

type TicketResponse

type TicketResponse struct {
	Ticket `json:"ticket"`
}

TicketResponse represents a ticket response

type TrackerInfo

type TrackerInfo struct {
	Count      int                 `json:"count"`
	Limit      int                 `json:"limit"`
	Page       int                 `json:"page"`
	Milestones []Milestone         `json:"milestones"`
	Tickets    []TrackerInfoTicket `json:"tickets"`
}

TrackerInfo represents information of individual ticket categories

type TrackerInfoTicket

type TrackerInfoTicket struct {
	Summary   string `json:"summary"`
	TicketNum int    `json:"ticket_num"`
}

TrackerInfoTicket represents tickets in the TrackerInfo response

type TrackerService

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

TrackerService handles communication with the ticket tracker tool releated methods of the Sourceforge API

func (*TrackerService) Get

func (s *TrackerService) Get(trackerName string, id int) (*Ticket, *Response, error)

Get a single ticket

func (*TrackerService) Info

func (s *TrackerService) Info(trackerName string, query RequestQuery) (*TrackerInfo, *Response, error)

Info Downloads information of a tracker

Jump to

Keyboard shortcuts

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