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
-
.api_key ⇒ Object
Retrieve the API key.
-
.api_key=(api_key) ⇒ Object
Set the API key for all requests.
-
.category(category_id, options = {}) ⇒ Object
Find a category by id.
-
.country ⇒ Object
Retrieve the country.
-
.country=(country) ⇒ Object
Set the country for all requests.
-
.domain ⇒ Object
Retrieve the domain.
-
.domain=(domain) ⇒ Object
Set the domain for all requests.
-
.http_basic ⇒ Object
retrieve HTTP Basic credentials.
-
.http_basic=(credentials = nil) ⇒ Object
set credetials for HTTP Basic Authentification like: Dawanda.http_basic = => ‘myusername’, :password => ‘mypassword’.
-
.pinboard(pinboard_id) ⇒ Object
Find a pinboard by id.
-
.product(product_id, options = {}) ⇒ Object
Find a product by id.
-
.shop(username_or_id, options = {}) ⇒ Object
Find a shop by username.
-
.shop_category(shop_category_id, options = {}) ⇒ Object
Find a shop_category by id.
-
.user(username_or_id, options = {}) ⇒ Object
Find a user by username.
Class Method Details
.api_key ⇒ Object
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, ={}) Category.find_by_id(category_id, ) end |
.country ⇒ Object
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 |
.domain ⇒ Object
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_basic ⇒ Object
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, ={}) Product.find_by_id(product_id, ) 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, ={}) Shop.find_by_user_id(username_or_id, ) 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, ={}) ShopCategory.find_by_id(shop_category_id, ) 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, ={}) User.find_by_user_id(username_or_id, ) end |