Class: Etsy::Shop

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/etsy/shop.rb

Overview

Shop

Represents a single Etsy shop. Users may or may not have an associated shop.

A shop has the following attributes:

name

The shop’s name

title

A brief heading for the shop’s main page

announcement

An announcement to buyers (displays on the shop’s home page)

message

The message sent to users who buy from this shop

image_url

The full URL to the shops’s banner image

active_listings_count

The number of active listings present in this shop

url

The full URL to the shop on Etsy

favorers_count

Number of favorers

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

included, #initialize, #result, #secret, #token

Class Method Details

.all(options = {}) ⇒ Object

Retrieve a list of all shops. By default it fetches 25 at a time, but that can be configured by passing the :limit and :offset parameters:

Etsy::Shop.all(:limit => 100, :offset => 100)


52
53
54
# File 'lib/etsy/shop.rb', line 52

def self.all(options = {})
  self.get_all("/shops", options)
end

.find(*identifiers_and_options) ⇒ Object

Retrieve one or more shops by name or ID:

Etsy::Shop.find('reagent')

You can find multiple shops by passing an array of identifiers:

Etsy::Shop.find(['reagent', 'littletjane'])


43
44
45
# File 'lib/etsy/shop.rb', line 43

def self.find(*identifiers_and_options)
  self.find_one_or_more('shops', identifiers_and_options)
end

Instance Method Details

#aboutObject



79
80
81
# File 'lib/etsy/shop.rb', line 79

def about
  About.find_by_shop(self)
end

#created_atObject

Time that this shop was created



58
59
60
# File 'lib/etsy/shop.rb', line 58

def created_at
  Time.at(created)
end

#listings(state = nil, options = {}) ⇒ Object

The collection of listings associated with this shop



70
71
72
73
# File 'lib/etsy/shop.rb', line 70

def listings(state = nil, options = {})
  state = state ? {:state => state} : {}
  Listing.find_all_by_shop_id(id, state.merge(options).merge(oauth))
end

#sectionsObject



75
76
77
# File 'lib/etsy/shop.rb', line 75

def sections
  Section.find_by_shop(self)
end

#updated_atObject

Time that this shop was last updated



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

def updated_at
  Time.at(updated)
end