Skip to content

Repository files navigation

Dropmark Gem

Installation

The Dropmark gem is available for installation on Rubygems. To install run:

gem install dropmark # todo

Using this gem in your application

To use this gem in your application, add the following to your Gemfile:

gem 'dropmark', :git => 'git://github.com/dropmark/dropmark-gem.git'

Using the API

This gem allows you to interact with the Dropmark API.

require'dropmark'# authenticate applicationDropmark.configuredo |config|
config.api_key='API_KEY'config.api_base='https://api.dropmark.com/v1'# optionalconfig.user_id='USER_ID'# optional, see below to retrieveconfig.user_token='USER_TOKEN'# optional, see below to retrieveend# retreive user token if neededuser=Dropmark::User.auth(email: 'EMAIL',password: 'PASSWORD')# note: store user.id and user.token for future use, never store password# get authenticated useruser=Dropmark::User.find('me')# get first 20 collections for authenticated usercollections=Dropmark::Collection.all(page: 1,count: 20)# get collection by idcollection=Dropmark::Collection.find(133727)# create new collection for authenticated usercollection=Dropmark::Collection.create(name: 'New collection',type: 'private',# optional ('private', 'public', 'global')sort_by: 'created_at',# optional ('name', 'created_at', 'updated_at')sort_order: 'desc',# optional ('asc', 'desc')view: 'square',# optional ('tile', 'shelf')labels: 'true',# optional ('true', 'false'))# delete collectioncollection.destroy# or delete collection by idDropmark::Collection.destroy_existing(133727)# sort collections by idscollections=Dropmark::Collection.sort([101,102,103])# get items in collectionitems=collection.items# or get items without fetching collectionitems=Dropmark::Item.where(collection_id: 133727)# get item by iditem=Dropmark::Item.find(2139403)# sort items in collection by item idsitems=collection.sort_items([101,102,103])# or sort items without fetching collectionitems=Dropmark::Item.sort(collection_id,[101,102,103])# create new itemitem=collection.items.create(content: 'http://dropmark.com')# oritem=Dropmark::Item.create(collection_id: 133727,name: 'Logo',# optionalcontent: 'http://dropmark.com/assets/images/logo.png',# required (URL, file, or text)description: 'Dropmark logo',# optionallink: 'http://dropmark.com',# optionalthumbnail: 'http://dropmark.com/assets/images/logo.png',# optionalshareable: 'true'# optional)# upload file itemitem=Dropmark::Item.create(collection_id: 133727,content: Dropmark::File.new('~/photo.jpg'))# update itemitem.name='My Photo'item.save# or update by iditem=Dropmark::Item.save_existing(2316519,name: 'My Photo')# delete itemitem.destroy# or delete by idDropmark::Item.destroy_existing(2139403)# get item commentscomments=item.comments.all# add commentcomment=item.comments.create(body: 'My comment')# or comment by item idcomment=Dropmark::Comment.create(item_id: 2316545,body: 'My comment')# delete commentcomment.destroy# or comment by idDropmark::Comment.destroy_existing(2139403)

Contributing

Help us improve this gem:

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

Ruby interface and command line utility for the Dropmark API

Resources

Stars

5 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages