Module: Etsy
- Defined in:
- lib/etsy.rb,
lib/etsy/shop.rb,
lib/etsy/user.rb,
lib/etsy/about.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/receipt.rb,
lib/etsy/request.rb,
lib/etsy/section.rb,
lib/etsy/version.rb,
lib/etsy/category.rb,
lib/etsy/response.rb,
lib/etsy/bill_charge.rb,
lib/etsy/transaction.rb,
lib/etsy/basic_client.rb,
lib/etsy/bill_payment.rb,
lib/etsy/secure_client.rb,
lib/etsy/shipping_info.rb,
lib/etsy/attribute_value.rb,
lib/etsy/billing_overview.rb,
lib/etsy/favorite_listing.rb,
lib/etsy/payment_template.rb,
lib/etsy/shipping_template.rb,
lib/etsy/verification_request.rb,
lib/etsy/variation/property_set.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, Variation Classes: About, Address, AttributeValue, BasicClient, BillCharge, BillPayment, BillingOverview, Category, Country, Error, EtsyJSONInvalid, ExceededRateLimit, FavoriteListing, Image, InvalidUserID, Listing, MissingShopID, OAuthTokenRevoked, PaymentTemplate, Profile, Receipt, Request, ResourceUnavailable, Response, Section, SecureClient, ShippingInfo, ShippingTemplate, Shop, TemporaryIssue, Transaction, User, VerificationRequest
Constant Summary collapse
- SANDBOX_HOST =
'sandbox.openapi.etsy.com'
- PRODUCTION_HOST =
'openapi.etsy.com'
- VERSION =
"0.3.4"
Class Attribute Summary collapse
-
.callback_url ⇒ Object
The configured callback URL or ‘oob’ if no callback URL is configured.
-
.permission_scopes ⇒ Object
OAuth permission scopes.
Class Method Summary collapse
-
.access_token(request_token, request_secret, verifier) ⇒ Object
Generate an access token from the request token, secret, and verifier.
-
.api_key ⇒ Object
Make Etsy.api_key and Etsy.api_secret global but also local to threads.
- .api_key=(key) ⇒ Object
- .api_secret ⇒ Object
- .api_secret=(secret) ⇒ Object
- .credentials ⇒ Object
-
.environment ⇒ Object
The currently configured environment.
-
.environment=(environment) ⇒ Object
Set the environment, accepts either :sandbox or :production.
-
.host ⇒ Object
:nodoc:.
-
.myself(token, secret, options = {}) ⇒ Object
Convenience method for accessing the authenticated user’s own user information.
- .protocol ⇒ Object
- .protocol=(protocol) ⇒ Object
-
.request_token ⇒ Object
Generate a request token for authorization.
-
.silent_errors ⇒ Object
The default will change to false for a 1.0 release (breaking changes).
-
.silent_errors=(bool) ⇒ Object
Allow throwing API errors.
- .single_user(access_token, access_secret) ⇒ Object
-
.user(username) ⇒ Object
Find a user by username.
-
.verification_url ⇒ Object
Generate the URL to begin the verification process for a user.
Class Attribute Details
.callback_url ⇒ Object
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.
151 152 153 |
# File 'lib/etsy.rb', line 151 def self.callback_url @callback_url || 'oob' end |
.permission_scopes ⇒ Object
OAuth permission scopes. Defines which private fields we can have access to.
157 158 159 |
# File 'lib/etsy.rb', line 157 def self. @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.
184 185 186 187 188 189 190 191 192 193 |
# File 'lib/etsy.rb', line 184 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 |
.api_key ⇒ Object
Make Etsy.api_key and Etsy.api_secret global but also local to threads
80 81 82 |
# File 'lib/etsy.rb', line 80 def self.api_key Thread.current[:etsy_api_key] || @api_key end |
.api_key=(key) ⇒ Object
84 85 86 87 |
# File 'lib/etsy.rb', line 84 def self.api_key=(key) @api_key ||= key Thread.current[:etsy_api_key] = key end |
.api_secret ⇒ Object
89 90 91 |
# File 'lib/etsy.rb', line 89 def self.api_secret Thread.current[:etsy_api_secret] || @api_secret end |
.api_secret=(secret) ⇒ Object
93 94 95 96 |
# File 'lib/etsy.rb', line 93 def self.api_secret=(secret) @api_secret ||= secret Thread.current[:etsy_api_secret] = secret end |
.credentials ⇒ Object
209 210 211 |
# File 'lib/etsy.rb', line 209 def self.credentials @credentials || {} end |
.environment ⇒ Object
The currently configured environment.
134 135 136 |
# File 'lib/etsy.rb', line 134 def self.environment @environment || :production 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.
104 105 106 107 108 109 110 |
# File 'lib/etsy.rb', line 104 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 |
.host ⇒ Object
:nodoc:
144 145 146 |
# File 'lib/etsy.rb', line 144 def self.host # :nodoc: @host || PRODUCTION_HOST end |
.myself(token, secret, options = {}) ⇒ Object
Convenience method for accessing the authenticated user’s own user information. Requires authentication.
170 171 172 |
# File 'lib/etsy.rb', line 170 def self.myself(token, secret, = {}) User.myself(token, secret, ) end |
.protocol ⇒ Object
128 129 130 |
# File 'lib/etsy.rb', line 128 def self.protocol @protocol || "https" end |
.protocol=(protocol) ⇒ Object
112 113 114 115 116 117 |
# File 'lib/etsy.rb', line 112 def self.protocol=(protocol) unless ["http", "https"].include?(protocol.to_s) raise(ArgumentError, "protocol must be set to either 'http' or 'https'") end @protocol = protocol.to_s end |
.request_token ⇒ Object
Generate a request token for authorization.
176 177 178 179 |
# File 'lib/etsy.rb', line 176 def self.request_token verification_request.request_token end |
.silent_errors ⇒ Object
The default will change to false for a 1.0 release (breaking changes)
140 141 142 |
# File 'lib/etsy.rb', line 140 def self.silent_errors @silent_errors.nil? ? true : @silent_errors end |
.silent_errors=(bool) ⇒ Object
Allow throwing API errors
121 122 123 124 125 126 |
# File 'lib/etsy.rb', line 121 def self.silent_errors=(bool) unless [TrueClass, FalseClass].include?(bool.class) raise(ArgumentError, "Silent errors must be set to either true or false'") end @silent_errors = bool end |
.single_user(access_token, access_secret) ⇒ Object
201 202 203 204 205 206 207 |
# File 'lib/etsy.rb', line 201 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.
163 164 165 |
# File 'lib/etsy.rb', line 163 def self.user(username) User.find(username) end |
.verification_url ⇒ Object
Generate the URL to begin the verification process for a user.
197 198 199 |
# File 'lib/etsy.rb', line 197 def self.verification_url verification_request.url end |