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)


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

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'])


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

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

Instance Method Details

#created_atObject

Time that this shop was created



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

def created_at
  Time.at(created)
end

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

The collection of listings associated with this shop



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

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

#sectionsObject



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

def sections
  Section.find_by_shop(self)
end

#updated_atObject

Time that this shop was last updated



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

def updated_at
  Time.at(updated)
end