The Dropmark gem is available for installation on Rubygems. To install run:
gem install dropmark # todo
To use this gem in your application, add the following to your Gemfile:
gem 'dropmark', :git => 'git://github.com/dropmark/dropmark-gem.git'
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)Help us improve this gem:
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request