Class: CityGrid
- Inherits:
-
Object
show all
- Defined in:
- lib/citygrid/api/mutable.rb,
lib/citygrid.rb,
lib/citygrid/api.rb,
lib/citygrid/offers.rb,
lib/citygrid/search.rb,
lib/citygrid/api/ads.rb,
lib/citygrid/details.rb,
lib/citygrid/listing.rb,
lib/citygrid/reviews.rb,
lib/citygrid/session.rb,
lib/citygrid/api/content.rb,
lib/citygrid/api/accounts.rb,
lib/citygrid/api/response.rb,
lib/citygrid/api/ads/custom.rb,
lib/citygrid/api/searchable.rb,
lib/citygrid/api/advertising.rb,
lib/citygrid/abstraction/item.rb,
lib/citygrid/api/accounts/user.rb,
lib/citygrid/api/accounts/login.rb,
lib/citygrid/api/content/offers.rb,
lib/citygrid/api/content/places.rb,
lib/citygrid/api/content/reviews.rb,
lib/citygrid/api/accounts/account.rb,
lib/citygrid/api/content/response.rb,
lib/citygrid/api/advertising/image.rb,
lib/citygrid/abstraction/collection.rb,
lib/citygrid/abstraction/super_hash.rb,
lib/citygrid/api/advertising/budget.rb,
lib/citygrid/api/advertising/offers.rb,
lib/citygrid/api/advertising/places.rb,
lib/citygrid/abstraction/requestable.rb,
lib/citygrid/abstraction/super_array.rb,
lib/citygrid/api/advertising/billing.rb,
lib/citygrid/api/advertising/ad_group.rb,
lib/citygrid/api/advertising/campaign.rb,
lib/citygrid/api/advertising/category.rb,
lib/citygrid/api/advertising/places_get.rb,
lib/citygrid/api/advertising/ad_group_ad.rb,
lib/citygrid/api/advertising/call_detail.rb,
lib/citygrid/api/advertising/geolocation.rb,
lib/citygrid/api/advertising/performance.rb,
lib/citygrid/api/advertising/ad_group_geo.rb,
lib/citygrid/api/content/profile_internal.rb,
lib/citygrid/api/accounts/method_of_payment.rb,
lib/citygrid/api/accounts/temp_impersonation.rb,
lib/citygrid/api/advertising/account_manager.rb,
lib/citygrid/api/advertising/ad_group_criterion.rb,
lib/citygrid/api/advertising/campaign_promotions.rb,
lib/citygrid/api/advertising/ad_group_call_detail.rb
Overview
Extend Array to provide following features:
——————————- #
Defined Under Namespace
Modules: Abstraction, DetailsMethods
Classes: API, Details, EndpointsNotConfigured, Listing, MultiDetails, Offers, ParseConfigurationError, PublisherNotConfigured, Reviews, Search, Session
Class Method Summary
collapse
Class Method Details
.authenticate(params) ⇒ Object
Also known as:
login
.custom_timeout ⇒ Object
44
45
46
|
# File 'lib/citygrid.rb', line 44
def custom_timeout
@custom_timeout
end
|
.custom_timeout=(timeout) ⇒ Object
40
41
42
|
# File 'lib/citygrid.rb', line 40
def custom_timeout= timeout @custom_timeout = timeout
end
|
.custom_timeout_set? ⇒ Boolean
48
49
50
|
# File 'lib/citygrid.rb', line 48
def custom_timeout_set?
defined?(@custom_timeout)
end
|
.find(listing_id) ⇒ Object
56
57
58
|
# File 'lib/citygrid.rb', line 56
def find listing_id
Listing.new("id" => listing_id).send(:load)
end
|
.load_config(file_path, env = nil) ⇒ Object
load in configs see citygrid_api.yml.sample for format
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/citygrid.rb', line 79
def load_config file_path, env = nil
config = YAML.load_file(file_path)
defaults = config["defaults"]
default_hostname = "http://#{defaults["hostname"]}"
ssl_hostname = "https://#{defaults["ssl_hostname"]}"
config["api"].each do |n, endpoints|
namespace = API.const_get n.camelcase
endpoints.each do |k, v|
klass = namespace.const_get(k.camelcase)
if v.is_a? String
endpoint = v.start_with?("/") ? v : "/#{v}"
klass.endpoint endpoint
klass.newendpoint endpoint
klass.base_uri default_hostname
elsif v.is_a? Hash
hostname = v["hostname"] || (v["ssl"] ? ssl_hostname : default_hostname)
throw ParseConfigurationError.new file_path, "No endpoint defined for #{k}" unless v["endpoint"]
newendpoint = v["newendpoint"] ? v["newendpoint"] : v["endpoint"]
endpoint = v["endpoint"].start_with?("/") ? v["endpoint"] : "/#{v["endpoint"]}"
newendpoint = newendpoint.start_with?("/") ? newendpoint : "/#{newendpoint}"
klass.endpoint endpoint
klass.base_uri hostname
klass.newendpoint newendpoint
else
throw ParseConfigurationError.new file_path, "Invalid value type for #{k}"
end
end
end
end
|
.offers(opts) ⇒ Object
60
61
62
|
# File 'lib/citygrid.rb', line 60
def offers opts
Offers.new opts
end
|
.print_curls=(v) ⇒ Object
whether the gem with print curls or not by default it will not print curls
32
33
34
|
# File 'lib/citygrid.rb', line 32
def print_curls= v
@print_curls = v
end
|
.print_curls? ⇒ Boolean
36
37
38
|
# File 'lib/citygrid.rb', line 36
def print_curls?
defined?(@print_curls) ? @print_curls : false
end
|
.publisher ⇒ Object
15
16
17
18
|
# File 'lib/citygrid.rb', line 15
def publisher
raise PublisherNotConfigured if !defined?(@publisher) || @publisher.nil?
@publisher
end
|
.publisher=(code) ⇒ Object
11
12
13
|
# File 'lib/citygrid.rb', line 11
def publisher= code
@publisher = code
end
|
.raise_errors=(v) ⇒ Object
whether api calls will throw errors or fail silently by default, we will raise errors
22
23
24
|
# File 'lib/citygrid.rb', line 22
def raise_errors= v
@raise_errors = v
end
|
.raise_errors? ⇒ Boolean
26
27
28
|
# File 'lib/citygrid.rb', line 26
def raise_errors?
!defined?(@raise_errors) || @raise_errors
end
|
.reviews(opts) ⇒ Object
64
65
66
|
# File 'lib/citygrid.rb', line 64
def reviews opts
Reviews.new opts
end
|
.search(opts = {}) ⇒ Object
52
53
54
|
# File 'lib/citygrid.rb', line 52
def search opts = {}
Search.new opts
end
|
.session(username, password) ⇒ Object
68
69
70
|
# File 'lib/citygrid.rb', line 68
def session username, password
Session.login username, password
end
|