Module: Dawanda

Defined in:
lib/dawanda.rb,
lib/dawanda/shop.rb,
lib/dawanda/user.rb,
lib/dawanda/color.rb,
lib/dawanda/model.rb,
lib/dawanda/oauth.rb,
lib/dawanda/channel.rb,
lib/dawanda/product.rb,
lib/dawanda/request.rb,
lib/dawanda/category.rb,
lib/dawanda/pinboard.rb,
lib/dawanda/response.rb,
lib/dawanda/shop_category.rb

Overview

DaWanda Client: A friendly Ruby interface to the DaWanda API

Quick Start

Getting started is easy. First, you will need a valid API key from the Dawanda developer site (dawanda.com/apps). Since the API is read-only at the moment, that’s all you need to do.

To start using the API, require the dawanda gem and set it up to use your API key:

require 'rubygems'
require 'dawanda'

Dawanda.api_key = 'itsasecret'

Now you can make API calls that originate from an Dawanda user:

# Find a user by username
user = Dawanda.user('meko')

# Grab that user's shop information
user.seller?
user.shop
user.shop.title

# ... and the products in the shop
product = user.shop.products.first
product.title
product.description

To see what else is available for a user, check out the full documentation for the Dawanda::User class.

Defined Under Namespace

Modules: Model Classes: Category, Channel, Color, OAuth, Pinboard, Product, Request, Response, Shop, ShopCategory, User

Class Method Summary collapse

Class Method Details

.api_keyObject

Retrieve the API key



66
67
68
# File 'lib/dawanda.rb', line 66

def self.api_key
  @api_key
end

.api_key=(api_key) ⇒ Object

Set the API key for all requests



61
62
63
# File 'lib/dawanda.rb', line 61

def self.api_key=(api_key)
  @api_key = api_key
end

.category(category_id, options = {}) ⇒ Object

Find a category by id. See Dawanda::Category for more information.



117
118
119
# File 'lib/dawanda.rb', line 117

def self.category(category_id, options={})
  Category.find_by_id(category_id, options)
end

.countryObject

Retrieve the country



76
77
78
# File 'lib/dawanda.rb', line 76

def self.country
  @country || 'de'
end

.country=(country) ⇒ Object

Set the country for all requests



71
72
73
# File 'lib/dawanda.rb', line 71

def self.country=(country)
  @country = country
end

.domainObject

Retrieve the domain



86
87
88
# File 'lib/dawanda.rb', line 86

def self.domain
  @domain || 'dawanda.com'
end

.domain=(domain) ⇒ Object

Set the domain for all requests



81
82
83
# File 'lib/dawanda.rb', line 81

def self.domain=(domain)
  @domain = domain
end

.http_basicObject

retrieve HTTP Basic credentials



91
92
93
# File 'lib/dawanda.rb', line 91

def self.http_basic
  @http_basic || nil
end

.http_basic=(credentials = nil) ⇒ Object

set credetials for HTTP Basic Authentification like: Dawanda.http_basic = => ‘myusername’, :password => ‘mypassword’



97
98
99
# File 'lib/dawanda.rb', line 97

def self.http_basic= credentials=nil
  @http_basic = credentials
end

.pinboard(pinboard_id) ⇒ Object

Find a pinboard by id. See Dawanda::Pinboard for more information.



127
128
129
# File 'lib/dawanda.rb', line 127

def self.pinboard(pinboard_id)
  Pinboard.find_by_id(pinboard_id)
end

.product(product_id, options = {}) ⇒ Object

Find a product by id. See Dawanda::Product for more information.



112
113
114
# File 'lib/dawanda.rb', line 112

def self.product(product_id, options={})
  Product.find_by_id(product_id, options)
end

.shop(username_or_id, options = {}) ⇒ Object

Find a shop by username. See Dawanda::Shop for more information.



107
108
109
# File 'lib/dawanda.rb', line 107

def self.shop(username_or_id, options={})
  Shop.find_by_user_id(username_or_id, options)
end

.shop_category(shop_category_id, options = {}) ⇒ Object

Find a shop_category by id. See Dawanda::ShopCategory for more information.



122
123
124
# File 'lib/dawanda.rb', line 122

def self.shop_category(shop_category_id, options={})
  ShopCategory.find_by_id(shop_category_id, options)
end

.user(username_or_id, options = {}) ⇒ Object

Find a user by username. See Dawanda::User for more information.



102
103
104
# File 'lib/dawanda.rb', line 102

def self.user(username_or_id, options={})
  User.find_by_user_id(username_or_id, options)
end