Class: Appilf::Listing

Inherits:
AppilfObject show all
Extended by:
APIActions
Defined in:
lib/appilf/listing.rb

Constant Summary collapse

PATH =
"/listings"

Constants included from APIActions

APIActions::BASE_API_URL

Instance Attribute Summary

Attributes inherited from AppilfObject

#item_data, #links, #meta

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIActions

api_delete, api_get, api_post, handle_from_response

Methods inherited from AppilfObject

#add_relationships, #init_meta_data, #method_missing, #respond_to_missing?

Constructor Details

#initialize(listing_hash) ⇒ Listing

Returns a new instance of Listing.



8
9
10
11
# File 'lib/appilf/listing.rb', line 8

def initialize(listing_hash)
  add_relationships(listing_hash['data'].delete('relationships'))
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Appilf::AppilfObject

Class Method Details

.list(params = {}) ⇒ Object



13
14
15
16
# File 'lib/appilf/listing.rb', line 13

def self.list(params = {})
  response = api_get(listings_path, params: Appilf::Util.parse_query_params(params))
  Appilf::Util.translate_from_response(response)
end

.listings_path(listing_id = nil) ⇒ Object



23
24
25
# File 'lib/appilf/listing.rb', line 23

def self.listings_path(listing_id = nil)
  "#{APIActions::BASE_API_URL}#{PATH}/#{listing_id}"
end

.retrieve(listing_id) ⇒ Object



18
19
20
21
# File 'lib/appilf/listing.rb', line 18

def self.retrieve(listing_id)
  response = api_get(listings_path(listing_id))
  Appilf::Util.translate_from_response(response)
end