Git Product home page Git Product logo

go-unsplash's People

Contributors

bluebugs avatar fat-fellow avatar hbagdi avatar klauern avatar looskie avatar lukechesser avatar martinroberts avatar mdeluise avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

go-unsplash's Issues

Reture a Response in all calls

Currently a few of the API methods don't have a return Response object which has rate limiting and pagination info.
This needs to be uniform across every API call.

user.Photos(); user.Portfolio();user.Followers() - links in user

Users have the following link relations:

photos API location of this user’s photos.
portfolio API location of this user’s external portfolio.
followers API location of this user’s followers.
following API location of users this user is following.

Need to expose methods for each of these.

RandomPhotoOpt needs to be updated

More filters are introduced in the API
https://unsplash.com/documentation#get-a-random-photo
Get a random photo
Retrieve a single random photo, given optional filters.

GET /photos/random
Note: See the note on hotlinking.

Parameters
All parameters are optional, and can be combined to narrow the pool of photos from which a random one will be chosen.

param Description
collections Public collection ID(‘s) to filter selection. If multiple, comma-separated
featured Limit selection to featured photos.
username Limit selection to a single user.
query Limit selection to photos matching a search term.
w Image width in pixels.
h Image height in pixels.
orientation Filter search results by photo orientation. Valid values are landscape, portrait, and squarish.
count The number of photos to return. (Default: 1; max: 30)
Note: You can’t use the collections and query parameters in the same request

Note: When supplying a count parameter - and only then - the response will be an array of photos, even if the value of count is 1.

Process errors JSON when an error occurs and put in struct response

Current implementation drops the errors fields returned by the API whenever an API error occurs.
Explore the possibility of including this errors fields.
The current implementation has custom errors and signals those errors based on HTTP response codes.
This would require exploring what kind of errors the API returns.

Utilize a dependency manager ('dep', 'glide', etc.)

I think it would make sense to adopt a dependency management tool to allow reproducable builds and such. I have been bitten by this with another web service API, so at least trialling out 'dep' or something similar would be a good start.

User.PortfolioURL is not always a valid URL

Issue

The Unsplash API can return invalid URLs for the User.PortfolioURL in the case I ran into the url contained a whitespace character at the end of the url. This causes parsing the entire response to fail.

Potential Fix

Changing User.PortfolioURL to *string instead of *Url should work and handle any invalid URLs there since it's not clear if Unsplash will verify that the url the user enters is valid. Otherwise updating Url.UnmarshalJSON to trim whitespace before parsing should at least eliminate some of these errors. It could also be a good idea to more gracefully handle errors here so parsing the entire response doesn't fail due to a single malformed URL.

Feature: introduce un.Users.Statistics method as well

This is related to #9
There will two ways of doing the same thing.
Once via as a method on user struct and another directly on the UserService via a username.

Both will need a new opt struct to specify resolution and quantity.

Parameters
param Description
username The user’s username. Required.
resolution The frequency of the stats. (Optional; default: “days”)
quantity The amount of for each stat. (Optional; default: 30)

Currently, the only resolution param supported is “days”. The quantity param can be any number between 1 and 30.

Return Rate limiting error

The current code is returning AuthError even for a rate limiting case.
unsplash's API doesn't give a resume time header but since they do it per hour, upon hitting the rate limit, just don't send the request till the next hour begins. Needs much more though.

Update /stats/total endpoint

seems like the endpoint previously used to return int values but now one of them returns a string.
Probably because of overflow??

The change is to write a custom UnmarshalJSON for the GlobalStats struct.

Errors with ListOpt{} when not specifying all values

When using ListOpt to populate List Options, you need to specify all values for the options rather than each as you need them. For instance, I have to specify Page, PerPage and OrderBy if I want it to work, otherwise it fails with opt provided is not valid:

	photos, resp, err := u.Photos.Curated(&unsplash.ListOpt{
		OrderBy: unsplash.Popular,
	})

Will create an error

Search results missing Link headers

Unsplash /search endpoints don't return a Link header for pagination support.
Their dev has acknowledged the bug and they are going to fix it soon.
There's nothing much to be done here except wait and test the code again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.