dribbble

package module
v0.0.0-...-fd5e4c7 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: MIT Imports: 8 Imported by: 0

README

Go Dribbble

Unofficial Go library for interacting with Dribbble API v2 (WIP). Please refer to official Dribbble API v2 Docs for more information about API itself.

Install

go get github.com/bedakb/go-dribbble

Usage

import "github.com/bedakb/go-dribbble"

cfg := dribbble.NewConfig(accessToken)
d, _ := dribbble.New(cfg)

// Get currently logged in user
user, _ := d.User.GetUser()
fmt.Printf("%v", user)

Inspired by go-dropbox.

Documentation

Overview

Package dribbble is Go library for interacting with Dribbble API v2

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachments

type Attachments struct {
	*Client
}

Attachments client

func (*Attachments) DeleteAttachment

func (c *Attachments) DeleteAttachment(shotID int, attachmentID int) error

DeleteAttachment requires the user to be authenticated with the upload scope The authenticated user must also own the attachment

type Client

type Client struct {
	*Config
	User        *User
	Projects    *Projects
	Shots       *Shots
	Jobs        *Jobs
	Likes       *Likes
	Attachments *Attachments
}

Client struct

func New

func New(config *Config) *Client

New returns new instance of Dribbble client

type Config

type Config struct {
	AccessToken string
	HTTPClient  *http.Client
}

Config for Dribbble Auth

func NewConfig

func NewConfig(accessToken string) *Config

NewConfig for auth

type Error

type Error struct {
	StatusCode int
	Message    string `json:"message"`
}

Error response.

func (*Error) Error

func (e *Error) Error() string

Error string.

type JobIn

type JobIn struct {
	OrganizationName string      `json:"organization_name"`
	Title            string      `json:"title"`
	Location         string      `json:"location"`
	URL              string      `json:"url"`
	Active           bool        `json:"active"`
	Team             interface{} `json:"team"`
}

JobIn schema

type JobOut

type JobOut struct {
	ID               int         `json:"id"`
	OrganizationName string      `json:"organization_name"`
	Title            string      `json:"title"`
	Location         string      `json:"location"`
	URL              string      `json:"url"`
	CreatedAt        time.Time   `json:"created_at"`
	UpdatedAt        time.Time   `json:"updated_at"`
	Active           bool        `json:"active"`
	StartsAt         time.Time   `json:"starts_at"`
	EndsAt           time.Time   `json:"ends_at"`
	Team             interface{} `json:"team"`
}

JobOut schema

type Jobs

type Jobs struct {
	*Client
}

Jobs client In order to use this part of API, you will need special token

func (*Jobs) CreateJob

func (c *Jobs) CreateJob(in *JobIn) (out *JobOut, err error)

CreateJob with given payload

func (*Jobs) GetJob

func (c *Jobs) GetJob(id int) (out *JobOut, err error)

GetJob with given id

func (*Jobs) UpdateJob

func (c *Jobs) UpdateJob(id int, in *JobIn) (out *JobOut, err error)

UpdateJob with given id and payload

type LikeOut

type LikeOut struct {
	ID        int       `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	Shot      struct {
		ID          int    `json:"id"`
		Title       string `json:"title"`
		Description string `json:"description"`
		Images      struct {
			Hidpi  interface{} `json:"hidpi"`
			Normal string      `json:"normal"`
			Teaser string      `json:"teaser"`
		} `json:"images"`
		PublishedAt time.Time `json:"published_at"`
		HTMLURL     string    `json:"html_url"`
		Height      int       `json:"height"`
		Width       int       `json:"width"`
	} `json:"shot"`
	User struct {
		ID      int    `json:"id"`
		Name    string `json:"name"`
		Login   string `json:"login"`
		HTMLURL string `json:"html_url"`
	} `json:"user"`
}

LikeOut response structure

type LikedShotOut

type LikedShotOut struct {
	ID        int       `json:"id"`
	CreatedAt time.Time `json:"created_at"`
}

LikedShotOut response structure

type Likes

type Likes struct {
	*Client
}

Likes client

func (*Likes) GetLikes

func (c *Likes) GetLikes() (out *[]LikeOut, err error)

GetLikes returns list of authenticated user’s liked shots Note: This is available only to select applications with our approval

func (*Likes) GetShotLike

func (c *Likes) GetShotLike(id int) (out *LikedShotOut, err error)

GetShotLike checks if you like a shot Note: This is available only to select applications with our approval

func (*Likes) LikeShot

func (c *Likes) LikeShot(id int) (out *LikedShotOut, err error)

LikeShot with given id Note: This is available only to select applications with our approval

func (*Likes) UnlikeShot

func (c *Likes) UnlikeShot(id int) error

UnlikeShot with given id Note: This is available only to select applications with our approval Unliking a shot requires the user to be authenticated with the write scope

type PopularShotOut

type PopularShotOut struct {
	ID          int    `json:"id"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Images      struct {
		Hidpi  interface{} `json:"hidpi"`
		Normal string      `json:"normal"`
		Teaser string      `json:"teaser"`
	} `json:"images"`
	PublishedAt time.Time `json:"published_at"`
	HTMLURL     string    `json:"html_url"`
	Height      int       `json:"height"`
	Width       int       `json:"width"`
}

PopularShotOut schema

type ProjectIn

type ProjectIn struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

ProjectIn payload structure

type ProjectOut

type ProjectOut struct {
	ID          int       `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	ShotsCount  int       `json:"shots_count"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

ProjectOut response structure

type Projects

type Projects struct {
	*Client
}

Projects client

func (*Projects) CreateProject

func (c *Projects) CreateProject(in *ProjectIn) (out *ProjectOut, err error)

CreateProject with given payload

func (*Projects) DeleteProject

func (c *Projects) DeleteProject(id int) error

DeleteProject with given id

func (*Projects) GetProjects

func (c *Projects) GetProjects() (out *[]ProjectOut, err error)

GetProjects of authenticated user

func (*Projects) UpdateProject

func (c *Projects) UpdateProject(id int, in *ProjectIn) (out *ProjectOut, err error)

UpdateProject with given id

type ShotOut

type ShotOut struct {
	ID          int    `json:"id"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Width       int    `json:"width"`
	Height      int    `json:"height"`
	Images      struct {
		Hidpi  interface{} `json:"hidpi"`
		Normal string      `json:"normal"`
		Teaser string      `json:"teaser"`
	} `json:"images"`
	PublishedAt time.Time `json:"published_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	HTMLURL     string    `json:"html_url"`
	Animated    bool      `json:"animated"`
	Tags        []string  `json:"tags"`
	Attachments []struct {
		ID           int       `json:"id"`
		URL          string    `json:"url"`
		ThumbnailURL string    `json:"thumbnail_url"`
		Size         int       `json:"size"`
		ContentType  string    `json:"content_type"`
		CreatedAt    time.Time `json:"created_at"`
	} `json:"attachments"`
	Projects []struct {
		ID          int       `json:"id"`
		Name        string    `json:"name"`
		Description string    `json:"description"`
		ShotsCount  int       `json:"shots_count"`
		CreatedAt   time.Time `json:"created_at"`
		UpdatedAt   time.Time `json:"updated_at"`
	} `json:"projects"`
	Team struct {
		ID        int    `json:"id"`
		Name      string `json:"name"`
		Login     string `json:"login"`
		HTMLURL   string `json:"html_url"`
		AvatarURL string `json:"avatar_url"`
		Bio       string `json:"bio"`
		Location  string `json:"location"`
		Links     struct {
			Web     string `json:"web"`
			Twitter string `json:"twitter"`
		} `json:"links"`
		Type      string    `json:"type"`
		CreatedAt time.Time `json:"created_at"`
		UpdatedAt time.Time `json:"updated_at"`
	} `json:"team"`
	Video struct {
		ID               int       `json:"id"`
		Duration         int       `json:"duration"`
		VideoFileName    string    `json:"video_file_name"`
		VideoFileSize    int       `json:"video_file_size"`
		Width            int       `json:"width"`
		Height           int       `json:"height"`
		Silent           bool      `json:"silent"`
		CreatedAt        time.Time `json:"created_at"`
		UpdatedAt        time.Time `json:"updated_at"`
		URL              string    `json:"url"`
		SmallPreviewURL  string    `json:"small_preview_url"`
		LargePreviewURL  string    `json:"large_preview_url"`
		XlargePreviewURL string    `json:"xlarge_preview_url"`
	} `json:"video"`
	LowProfile bool `json:"low_profile"`
}

ShotOut single schema

type Shots

type Shots struct {
	*Client
}

Shots instance

func (*Shots) DeleteShot

func (c *Shots) DeleteShot(id int) error

DeleteShot with given id Deleting a shot requires the user to be authenticated with the upload scope The authenticated user must also own the shot

func (*Shots) GetPopularShots

func (c *Shots) GetPopularShots() (out *[]PopularShotOut, err error)

GetPopularShots overall Note: This is available only to select applications with our approval

func (*Shots) GetShot

func (c *Shots) GetShot(id int) (out *ShotOut, err error)

GetShot with given id This method returns only shots owned by the currently authenticated user

func (*Shots) GetShots

func (c *Shots) GetShots() (out *[]ShotOut, err error)

GetShots of authenticated user

func (*Shots) UpdateShot

func (c *Shots) UpdateShot(id int, in *UpdateShotIn) (out *ShotOut, err error)

UpdateShot with given id and payload Updating a shot requires the user to be authenticated with the upload scope The authenticated user must also own the shot

type UpdateShotIn

type UpdateShotIn struct {
	Title       string   `json:"title"`
	Description string   `json:"description"`
	Tags        []string `json:"tags"`
}

UpdateShotIn for updating shot

type User

type User struct {
	*Client
}

User client

func (*User) GetUser

func (c *User) GetUser() (out *UserOut, err error)

GetUser which is currenlty logged in

type UserOut

type UserOut struct {
	ID        int    `json:"id"`
	Name      string `json:"name"`
	Login     string `json:"login"`
	HTMLURL   string `json:"html_url"`
	AvatarURL string `json:"avatar_url"`
	Bio       string `json:"bio"`
	Location  string `json:"location"`
	Links     struct {
		Web     string `json:"web"`
		Twitter string `json:"twitter"`
	} `json:"links"`
	CanUploadShot  bool      `json:"can_upload_shot"`
	Pro            bool      `json:"pro"`
	FollowersCount int       `json:"followers_count"`
	CreatedAt      time.Time `json:"created_at"`
	Type           string    `json:"type"`
	Teams          []struct {
		ID        int    `json:"id"`
		Name      string `json:"name"`
		Login     string `json:"login"`
		HTMLURL   string `json:"html_url"`
		AvatarURL string `json:"avatar_url"`
		Bio       string `json:"bio"`
		Location  string `json:"location"`
		Links     struct {
			Web     string `json:"web"`
			Twitter string `json:"twitter"`
		} `json:"links"`
		Type      string    `json:"type"`
		CreatedAt time.Time `json:"created_at"`
		UpdatedAt time.Time `json:"updated_at"`
	} `json:"teams"`
}

UserOut response structure

Jump to

Keyboard shortcuts

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