Git Product home page Git Product logo

ror_desk's Introduction

RorDesk

This plugin allows you to use oDesk APIs in your rails application seamlessly. It uses the gem ruby_desk (www.github.com/aseldawy/ruby_desk) to interact with oDesk APIs.

Overview

RorDesk makes it very easy to use oDesk APIs from within rails applications.

  • It takes care of the whole authentication process leaving you to call only the APIs you want.

  • It also hides most API details like forming the URL and parameters.

  • All calls are signed by default using you API key and secret to be much easier.

  • Results are automatically parsed so that your application interact with Ruby classes instead of json/xml.

  • Dates and times are automatically mapped to Ruby Date/Time objects leaving no ambiguity on time zone.

How it works

RorDesk integrates easily with a Rails application by adding a controller and some methods in ApplicationController. The controller OdeskController accepts one action that is sent by oDesk after the authorization is completed. The path to this action is assumed to be ‘/odesk’. This action reads the ‘frob’ parameter and stores it into session for later use with API calls.

The method ‘odesk_required’ is added to ApplicationController. This method should be used as a before_filter for actions that use oDesk APIs. This method either creates an @odesk_connector that will be used in the action, or redirects to oDesk authentication/authorization page so that the user accepts the application. When a redirection to oDesk Auth* page occurs, the application redirects to the original action that was called after authorization is complete.

Inside your action you have an instance variable @odesk_connector that can be used with all RubyDesk methods. See

http://www.github.com/aseldawy/ruby_desk

for more details on how to use RubyDesk.

Installation

To install ror_desk plugin just type this at your rails application root

script/plugin install git://github.com/aseldawy/ror_desk.git

Example

First of all, you should generate API keys through oDesk web site.

http://www.odesk.com/services/api/apply

In the ‘Callback URL’ field type:

http://<your domain>/odesk

Copy and paste your ‘key’ and ‘secret’ from oDesk page to the file

<Rails Root>/config/odesk.yml

You may need to create it if it is not existing.

A sample config file (config/odesk.yml)

development:
  api_key: 824d225a889aca186c55ac49a6b23957
  api_secret: 984aa36db13fff5c

test:
  api_key: 824d225a889aca186c55ac49a6b23957
  api_secret: 984aa36db13fff5c

production:
  api_key: 824d225a889aca186c55ac49a6b23957
  api_secret: 984aa36db13fff5c

A sample controller (app/controllers/teams_controller.rb)

TeamsController < ApplicationController
    before_filter :odesk_required

    def index
        @teamrooms = RubyDesk::TeamRoom.get_teamrooms(@odesk_connector)
    end
end

A sample view (app/views/teams/index.html.erb)

<h1>Teams</h1>
<% @teamrooms.each do |teamroom| -%>
  <%= teamroom.company_name %><br/>
<% end -%>

(new) RorDesk is logging its messages to your log file. This makes life easier when a problem happens.

Copyright © 2010 BadrIT (Ahmed ElDawy), released under the MIT license

ror_desk's People

Contributors

aseldawy avatar

Stargazers

Marius Ion avatar Dominic Becker avatar  avatar Kamil Sarna avatar Dmitry Vasilets avatar Oleg Kostyuk avatar Volodymyr Hotsyk avatar

Watchers

 avatar Marius Ion avatar  avatar

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.