README.md in dribbble-1.0.0.beta2 vs README.md in dribbble-1.0.0

- old
+ new

@@ -21,74 +21,384 @@ ```ruby gem install dribbble ``` +--- + + + + ## Usage -First you need to instanciate a client with a client access token. You can get one by creating an application on [developer.dribbble.com](http://developer.dribbble.com/). +Lets assume you have your token set: ```ruby -client = Dribbble::Client.new token: '0123456789abcdef' +token = 'my_access_token' ``` -### User +Some calls are through a client: -You can get the current user logged in by calling `client.user` - ```ruby -client.get_user -#=> #<Dribbble::User ...> +client = Dribbble::Client.new(token) ``` -Or you can get a specific user by knowing his ID + + +### Buckets + +##### Find a bucket ```ruby -user = client.get_user(1) -#=> #<Dribbble::User id=1 ...> +bucket = Dribbble::Bucket.find(token, '2754') ``` -You can access users attributes like this : +##### Create a bucket +```ruby +bucket = Dribbble::Bucket.create(token, name: 'A new bucket', description: 'A description') +``` +##### Update a bucket ```ruby -user.name -#=> "Charley D." +bucket.update name: 'An updated bucket name' +``` -user.username -#=> "Calyhre" +##### Delete a bucket +```ruby +bucket.delete ``` -A user also have buckets : +#### Bucket shots +##### List bucket shots ```ruby -user.buckets -#=> [#<Dribbble::Bucket ...>, #<Dribbble::Bucket ...>] +shots = bucket.shots ``` -... And shots : +##### Add shot to a bucket +```ruby +bucket.add_shot(329335) +# or +bucket.add_shot(shot) # shot is a Dribbble::Shot +``` +##### Remove shot from a bucket ```ruby -user.shots -#=> [#<Dribbble::Shot ...>, #<Dribbble::Shot ...>] +bucket.remove_shot(329335) +# or +bucket.remove_shot(shot) # shot is a Dribbble::Shot ``` + + + +### Projects + +##### Find a Projects +```ruby +project = Dribbble::Project.find(token, 3) +``` + +#### Project shots +```ruby +shots = project.shots +``` + + + + ### Shots -You can create a shot by calling `client.create_shot` +##### List shots +```ruby +shots = Dribbble::Shot.all(token) +``` +##### Find a shot ```ruby -shot = { - title: 'Shot title', - desciption: 'Shot description', - image: File.new('some/directory/image.jpg', 'rb'), - tags: %w(tag1 tag2) +shot = Dribbble::Shot.find(token, 1971500) +``` + +##### Create a shot +```ruby +params = { + title: 'A new shot', + description: 'Shot description', + tags: %w(tag1 tag2), + team_id: 1234, + rebound_source_id: 1234, } +shot = Dribbble::Shot.create(token, params) +``` -client.create_shot(shot) -#=> True +##### Update a shot +```ruby +params = { + title: 'A new shot', + description: 'Shot description', + tags: %w(tag1 tag2), + team_id: 1234 +} +shot.update(params) ``` +##### Delete a shot +```ruby +shot.delete +``` + +#### Shot attachments + +##### List attachments for a shot +```ruby +shot.attachments +``` + +##### Create an attachment +```ruby +shot.create_attachment(file: File.open('attachment_path')) +``` + +##### Get a single attachment +```ruby +shot.find_attachment(206165) +``` + +##### Delete an attachment +```ruby +shot.delete_attachment(206165) +``` + + +#### Shot buckets +##### List buckets for a shot +```ruby +shot.buckets +``` + + +#### Shot comments +##### List comments for a shot +```ruby +shot.comments +``` + +##### Create a comment +```ruby +comment = shot.create_comment(body: 'A comment') +``` + +##### Get a single comment +```ruby +comment = shot.find_comment(1145736) +``` + +##### Update a comment +```ruby +comment = shot.update_comment(1145736, body: 'Comment body') +``` + +##### Delete a comment +```ruby +shot.delete_comment(1145736) +``` + +##### List likes for a comment +```ruby +comment.likes +``` + +##### Check if you like a comment +```ruby +comment.like? +``` + +##### Like a comment +```ruby +comment.like! +``` + +##### Unlike a comment +```ruby +comment.unlike! +``` + +#### Shot likes +##### List the likes for a shot +```ruby +shot.likes +``` + +##### Check if you like a shot +```ruby +shot.like? +``` + +##### Like a shot +```ruby +shot.like! +``` + +##### Unlike a shot +```ruby +shot.unlike! +``` + +#### Shot projects +##### List projects for a shot +```ruby +projects = shot.projects +``` + +#### Shot rebounds +##### List rebounds for a shot +```ruby +shots = shot.rebounds +``` + + + + +### Teams + +Let's assume you have a team: +```ruby +user = Dribbble::User.find(token, 483195) +team = user.teams.first +``` + +#### Team members +##### List a team’s members +```ruby +users = team.members +``` + + +#### Team shots +##### List shots for a team +```ruby +shots = team.shots +``` + + + + +### Users +##### Get a single user +```ruby +user = Dribbble::User.find(token, 483195) +``` + +##### Get the authenticated user +```ruby +user = client.user +``` + + +#### User buckets +##### List a user’s buckets +```ruby +user.buckets +``` + +##### List authenticated user’s buckets +```ruby +buckets = client.buckets +``` + + +#### User followers +##### List followers of a user +```ruby +users = user.followers +``` + +##### List followers of authenticated user +```ruby +users = client.followers +``` + +##### List users followed by a user +```ruby +users = user.following +``` + +##### List shots for users followed by a authenticated user +```ruby +shots = client.following_shots +``` + +##### Check if you are following a user +```ruby +user.following? +``` + +##### Check if one user is following another +```ruby +user.following?(483195) +``` + +##### Follow a user +```ruby +user.follow! +``` + +##### Unfollow a user +```ruby +user.unfollow! +``` + + +#### User likes +##### List shot likes for a user +```ruby +shots = user.likes +``` + +##### List shot likes for authenticated user +```ruby +shots = client.likes +``` + + +#### User projects +##### List a user’s projects +```ruby +projects = user.projects +``` + +##### List authenticated user’s projects +```ruby +projects = client.projects +``` + + +#### User shots +##### List shots for a user +```ruby +shots = user.shots +``` + +##### List shots for authenticated user +```ruby +shots = client.shots +``` + + +#### User teams +##### List a user’s teams +```ruby +teams = user.teams +``` + +##### List authenticated user’s teams +```ruby +teams = client.teams +``` + + + ### Pagination & parameters All requests are paginated, defaults params are : | Param | Default | @@ -97,15 +407,13 @@ |per_page | 100| You override them or adding some by passing a `Hash` to every request : ```ruby -client.user page: 2, custom_param: 'My param' +user.shots page: 2, custom_param: 'My param' ``` ## Contributing - -[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/Calyhre/dribbble?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) Feel free to help me make this gem awesome ! [Contributors](https://github.com/Calyhre/dribbble/graphs/contributors) and [CONTRIBUTING](https://github.com/Calyhre/dribbble/blob/master/CONTRIBUTING.md)