Skip to content

dawanda/dawanda-api-client-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DaWanda

The Dawanda gem provides a friendly Ruby interface to the Dawanda API, plus a secure OAuth interface to get user-specific data.

Installation

 Installing the latest stable version is simple:

sudo gem install dawanda_client

Usage

The Dawanda API is read-only - all you need to gain access is an API Key (available from dawanda.com/apps). Once you have your API key, set it in your script:

require 'rubygems'
require 'dawanda'
Dawanda.api_key = 'foobar'
Dawanda.country = 'de'

From there, you can make any calls to the API that you need. Note: Any call to the API can fail. In case of an error an exception is raised. So make sure your API client codes handles it.

See the wiki for more information about what you can recieve via the DaWanda API.

Example

If you’re starting with a user, the easiest way is to use the Dawanda.user method:

>> user = Dawanda.get_user('meko')
=> #<Dawanda::User:0x141bf58 @result={"name"=>"meko", "city"=>"auma", "is_seller"=>true, ...
>> user.name
=> "meko"
>> user.id
=> 13008

Each user may optionally have a shop. If a user is a seller, he / she also has an associated shop object:

>> user.seller?
=> true
>> shop = user.shop
=> #<Dawanda::Shop:0x14170c0 @result={"is_vacation"=>false, "name"=>"MEKO STORE" ...
>> shop.name
=> "MEKO STORE"

See the wiki for more information about what you can recieve via the DaWanda API.

Exceptions

Chances are, that for some reason a HTTP request to the dawanda API can fail. This can have many reasons, either missing network connection or a wrong id. In case the HTTP status code is different von 2xx or 3xx an exception containing a meaningful error message is raised.

>> category = Dawanda::Category.find_by_id(2323)
=> RuntimeError: {"error":{"status":404,"message":"The Category 2323 could not be found"}}

Releases

No releases published

Packages

No packages published