Class: PQSDK::Leaflet

Inherits:
RemoteObject show all
Defined in:
lib/pqsdk/leaflet.rb

Overview

The Leaflet class provides an interface for crawlers to the v1/leaflets api endpoint.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RemoteObject

all, #create, #create!, from_hash, get, #persisted?, #save, #save!, #update, #update!

Instance Attribute Details

#end_dateObject

Returns the value of attribute end_date.



10
11
12
# File 'lib/pqsdk/leaflet.rb', line 10

def end_date
  @end_date
end

#idObject

Returns the value of attribute id.



10
11
12
# File 'lib/pqsdk/leaflet.rb', line 10

def id
  @id
end

#image_urlsObject

Returns the value of attribute image_urls.



10
11
12
# File 'lib/pqsdk/leaflet.rb', line 10

def image_urls
  @image_urls
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/pqsdk/leaflet.rb', line 10

def name
  @name
end

#pdf_dataObject

Returns the value of attribute pdf_data.



10
11
12
# File 'lib/pqsdk/leaflet.rb', line 10

def pdf_data
  @pdf_data
end

#start_dateObject

Returns the value of attribute start_date.



10
11
12
# File 'lib/pqsdk/leaflet.rb', line 10

def start_date
  @start_date
end

#store_idsObject

Returns the value of attribute store_ids.



10
11
12
# File 'lib/pqsdk/leaflet.rb', line 10

def store_ids
  @store_ids
end

#urlObject

Returns the value of attribute url.



10
11
12
# File 'lib/pqsdk/leaflet.rb', line 10

def url
  @url
end

Class Method Details

.find(url) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/pqsdk/leaflet.rb', line 22

def self.find(url)
  res = RestLayer.get(@endpoint, url: url, retailer_id: Token.retailer_id)

  return nil if res[0] == 404
  raise "Unexpected HTTP status code #{res[0]}" unless res[0] == 200

  from_hash res[1]
end

Instance Method Details

#attributesObject



15
16
17
18
19
20
# File 'lib/pqsdk/leaflet.rb', line 15

def attributes
  {
    'name' => nil, 'url' => nil, 'start_date' => nil, 'end_date' => nil,
    'pdf_data' => nil, 'image_urls' => nil, 'store_ids' => nil
  }
end