Project

copy-ruby

0.0
No commit activity in last 3 years
No release in over 3 years
API wrapper for Copy.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

>= 0
>= 0
 Project Readme

Copy Build Status Code Climate Coverage Status

This is a Ruby wrapper for copy's API.

Documentation

We use RubyDoc for documentation.

Usage

First, you've to install the gem

  gem install copy-ruby 

and require it

  require "copy"

and set up your app credentials

  Copy.config do |configuration|
    configuration[:consumer_key] = '_your_consumer_key_'
    configuration[:consumer_secret] = '_your_consumer_secret_'
  end

in fact this last step is optional (yes! we support multiple applications) but if as most fo the humans you use only one copy app, this is the easyest way to go.

Oauth

Copy oauth2 API documentation

using omniauth? 👍 good choice, just try this gem

plexinc/omniauth-copy

not using omniauth,? no prob oauth implementation comming soon

...

Client

Everything starts with the client, once you have the user credentials you should create a session and a client to start interaction with the API

  session = Copy::Session.new(
    token: '_your_user_token_',
    secret: '_your_user_secret_'
  )
  client = Copy::Client.new(session)

Now you can perform any user api call inside the clien wrapper

  client.user(:show)

If you have multiple applications or you just want to ve explicit use the application credentials inside the session creation

  session = Copy::Session.new(
    token: '_your_user_token_',
    secret: '_your_user_secret_',
    consumer_key: '_your_app_key_',
    consumer_secret: '_your_app_secret'
  )
  client = Copy::Client.new(session)

Users

Copy users API documentation

Showing user profile:

  user = client.user(:show)

Updating user (only last_name or first_name)

  user = client.user(:update, { first_name: 'New name', last_name: 'New last name'})

Files

Copy files API documentation

Showing root dir:

 file = client.file(:show)

listing dir children:

files has children if is a dir and is not sutbbed (already being listed form his father)

  if file.is_dir?
    file = client.file(:show, id: file.id ) if file.stubbed?
    file.children
  end

get file revisions

  file = client.file(:activity, id: '/copy/readme.txt')
  revisions = file.revisions
  file_revision = client.file(:show, id: revisions.first.id )

delete a file

  client.file(:delete, id: '/test/readme.txt')

create a file. You need to provide a valid copy directory and a file (currently we accept File, Tempfile, String or StringIO objects )

  file = client.file(:create, path: '/test/readme.txt', file: File.open('path/to/file'))

Links

Copy links API documentation

List all links created by the user

  links = client.file(:all)

Show a link

  link = client.file(:show, id: links.first.id )

List link recipients. Returns a list of users

  link.recipients if !link.public

Create a new link

  link = client.link(:create,
    name: 'My new fancy link',
    public: true,
    paths: [
      '/path/to/the/file_1.txt',
      '/path/to/the/file_2.txt'
    ]
  )

Delete a existing link

  client.link(:delete, id: link.id )

Get metadata of a link

  link = client.link(:meta, id: link.id )
  files = link.children

Get a download link url

  link = client.link(:show, id: link.id )
  files = link.download_url

Documentation

Copy developers page

Copy API documentation

Requirements

This gem requires at least Ruby 1.9 and faces version 1 of Copy's API.

Bugs

Please report bugs at http://github.com/andresbravog/copy-ruby/issues.

Note on Patches/Pull Requests

  • Fork the project from http://github.com/andresbravog/copy-ruby.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright (c) 2012-2013 andresbravog Internet Service, Andres Bravo. See LICENSE for details.