Module: Etsy

Defined in:
lib/etsy.rb,
lib/etsy/shop.rb,
lib/etsy/user.rb,
lib/etsy/image.rb,
lib/etsy/model.rb,
lib/etsy/address.rb,
lib/etsy/country.rb,
lib/etsy/listing.rb,
lib/etsy/profile.rb,
lib/etsy/request.rb,
lib/etsy/section.rb,
lib/etsy/version.rb,
lib/etsy/category.rb,
lib/etsy/response.rb,
lib/etsy/transaction.rb,
lib/etsy/basic_client.rb,
lib/etsy/secure_client.rb,
lib/etsy/payment_template.rb,
lib/etsy/shipping_template.rb,
lib/etsy/verification_request.rb

Overview

Etsy: A friendly Ruby interface to the Etsy API

Quick Start

Getting started is easy. First, you will need a valid API key from the Etsy developer site (developer.etsy.com/).

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

require 'rubygems'
require 'etsy'

Etsy.api_key = 'itsasecret'

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

# Find a user by username
user = Etsy.user('littletjane')

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

# ... and the listings in the shop
listing = user.shop.listings.first
listing.title
listing.description

To see what else is available for a user, check out the full documentation for the Etsy::User class. Information about making authenticated calls is available in the README.

Defined Under Namespace

Modules: Model Classes: Address, BasicClient, Category, Country, Error, EtsyJSONInvalid, Image, InvalidUserID, Listing, MissingShopID, OAuthTokenRevoked, PaymentTemplate, Profile, Request, Response, Section, SecureClient, ShippingTemplate, Shop, TemporaryIssue, Transaction, User, VerificationRequest

Constant Summary collapse

SANDBOX_HOST =
'sandbox.openapi.etsy.com'
PRODUCTION_HOST =
'openapi.etsy.com'
VERSION =
"0.2.2"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Returns the value of attribute api_key.



65
66
67
# File 'lib/etsy.rb', line 65

def api_key
  @api_key
end

.api_secretObject

Returns the value of attribute api_secret.



65
66
67
# File 'lib/etsy.rb', line 65

def api_secret
  @api_secret
end

.callback_urlObject

The configured callback URL or ‘oob’ if no callback URL is configured. This controls whether or not we need to pass the OAuth verifier by hand.



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

def self.callback_url
  @callback_url || 'oob'
end

.permission_scopesObject

OAuth permission scopes. Defines which private fields we can have access to.



103
104
105
# File 'lib/etsy.rb', line 103

def self.permission_scopes
  @permission_scopes || []
end

Class Method Details

.access_token(request_token, request_secret, verifier) ⇒ Object

Generate an access token from the request token, secret, and verifier. The verifier can either be passed manually or from the params in the callback URL.



130
131
132
133
134
135
136
137
138
139
# File 'lib/etsy.rb', line 130

def self.access_token(request_token, request_secret, verifier)
  @access_token = begin
    client = Etsy::SecureClient.new({
      :request_token  => request_token,
      :request_secret => request_secret,
      :verifier       => verifier
    })
    client.client
  end
end

.credentialsObject



155
156
157
# File 'lib/etsy.rb', line 155

def self.credentials
  @credentials || {}
end

.environmentObject

The currently configured environment.



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

def self.environment
  @environment || :sandbox
end

.environment=(environment) ⇒ Object

Set the environment, accepts either :sandbox or :production. Defaults to :sandbox and will raise an exception when set to an unrecognized environment.



76
77
78
79
80
81
82
# File 'lib/etsy.rb', line 76

def self.environment=(environment)
  unless [:sandbox, :production].include?(environment)
    raise(ArgumentError, "environment must be set to either :sandbox or :production")
  end
  @environment = environment
  @host = (environment == :sandbox) ? SANDBOX_HOST : PRODUCTION_HOST
end

.hostObject

:nodoc:



90
91
92
# File 'lib/etsy.rb', line 90

def self.host # :nodoc:
  @host || SANDBOX_HOST
end

.myself(token, secret, options = {}) ⇒ Object

Convenience method for accessing the authenticated user’s own user information. Requires authentication.



116
117
118
# File 'lib/etsy.rb', line 116

def self.myself(token, secret, options = {})
  User.myself(token, secret, options)
end

.request_tokenObject

Generate a request token for authorization.



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

def self.request_token
  clear_for_new_authorization
  verification_request.request_token
end

.single_user(access_token, access_secret) ⇒ Object



147
148
149
150
151
152
153
# File 'lib/etsy.rb', line 147

def self.single_user(access_token, access_secret)
  @credentials = {
    :access_token => access_token,
    :access_secret => access_secret
  }
  nil
end

.user(username) ⇒ Object

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



109
110
111
# File 'lib/etsy.rb', line 109

def self.user(username)
  User.find(username)
end

.verification_urlObject

Generate the URL to begin the verification process for a user.



143
144
145
# File 'lib/etsy.rb', line 143

def self.verification_url
  verification_request.url
end