places_scout 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +215 -107
- data/lib/places_scout.rb +210 -89
- data/lib/places_scout/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27ecdc11ba39810414a4caefcc71c3f6fbc8d754
|
4
|
+
data.tar.gz: f45ffc2edb7af62378c639a724b30f65dad36696
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c0943743624ace0f8eb41e9b418e007284b3f5800830e9d9280c5771ff1181c882cf1cab99b936795420bba3ffd2d773e1780ab42224c158e73d5ccb9317edc
|
7
|
+
data.tar.gz: f1166504a71bb71aa0267cedabfa81a8acdde20a312fd2b1e6331d0f218c645a9073a2b6d82cd3c069c01690341305745dcbeab1f83fa7849e9aecac4231ac2f
|
data/README.md
CHANGED
@@ -29,12 +29,19 @@ get_ranking_reports(:size => '5', page => '5') # Returns only the 5th page
|
|
29
29
|
```
|
30
30
|
### Connecting to the API
|
31
31
|
```ruby
|
32
|
-
|
32
|
+
opts = {}
|
33
|
+
opts[:username] = "<username>"
|
34
|
+
opts[:password] = "<password>"
|
35
|
+
testcon = PlacesScout::Api.new(opts)
|
33
36
|
```
|
34
37
|
### Clients
|
35
38
|
```ruby
|
36
39
|
testcon.get_clients() # Grab all clients.
|
40
|
+
testcon.get_clients(:names_and_ids => true) # Just get names and ids
|
37
41
|
testcon.get_clients(:clientid => 'client-id') #Grab specific client
|
42
|
+
testcon.create_client(:Name => 'test company',:CustomClientId => 'XXX' , :PrimaryEmail => 'test@test.com', :Website => 'www.test.com')
|
43
|
+
testcon.update_client(:clientid => 'client-id', :Name => 'test company',:CustomClientId => 'XXX' , :PrimaryEmail => 'test@test.com', :Website => 'www.test.com')
|
44
|
+
testcon.delete_client(:clientid => 'client-id')
|
38
45
|
```
|
39
46
|
### Locations
|
40
47
|
```ruby
|
@@ -42,126 +49,227 @@ testcon.get_client_locations() # Grab all client locations.
|
|
42
49
|
testcon.get_client_locations(:clientid => 'client-id') #Grab locations for specific client
|
43
50
|
testcon.get_client_locations(:locationid => 'location-id') #Grab by location id
|
44
51
|
```
|
52
|
+
# Create client location
|
53
|
+
opts[:clientid]
|
54
|
+
opts[:locationid]
|
55
|
+
opts[:BusinessName]
|
56
|
+
opts[:LocationName]
|
57
|
+
opts[:StreetAddress]
|
58
|
+
opts[:StreetAddress2]
|
59
|
+
opts[:City]
|
60
|
+
opts[:State]
|
61
|
+
opts[:Zip]
|
62
|
+
opts[:Country]
|
63
|
+
opts[:Phone]
|
64
|
+
opts[:Email]
|
65
|
+
opts[:CustomLocationId]
|
66
|
+
opts[:Region]
|
67
|
+
opts[:StoreNumber]
|
68
|
+
opts[:PlusLocalPageLink]
|
69
|
+
opts[:ListingSites]
|
70
|
+
opts[:YextApiKey]
|
71
|
+
opts[:YextCustomerId]
|
72
|
+
opts[:YextLocationId]
|
73
|
+
opts[:LocationGroupId]
|
74
|
+
```ruby
|
75
|
+
opts = {}
|
76
|
+
opts[:clientid] = '<client-id>'
|
77
|
+
opts[:LocationName] = "Location Name"
|
78
|
+
puts testcon.create_client_location(opts)
|
79
|
+
```
|
80
|
+
# Delete client location
|
81
|
+
```ruby
|
82
|
+
opts = {}
|
83
|
+
opts[:LocationId] = '<location-id>'
|
84
|
+
puts testcon.delete_client_location(opts)
|
85
|
+
```
|
45
86
|
### Folders
|
46
87
|
```ruby
|
47
88
|
testcon.get_client_folders()#Grab all client folders.
|
48
89
|
testcon.get_client_folders(:clientid => 'client-id') #Grab folder off client id
|
49
90
|
```
|
50
91
|
### Rank Reports
|
92
|
+
# GET /rankingreports
|
93
|
+
All rank reports, or for client or location
|
94
|
+
```ruby
|
95
|
+
opts = {}
|
96
|
+
```
|
97
|
+
Optional
|
98
|
+
opts[:locationid] = '<location-id>' <-- Doesn't restrict results, might not be working on API end
|
99
|
+
opts[:clientid] = '<client-id>'
|
51
100
|
```ruby
|
52
|
-
testcon.get_ranking_reports
|
53
|
-
testcon.get_ranking_reports(:all => true) #Grab all ranking report data.
|
54
|
-
testcon.get_ranking_reports(:clientid => 'client-id') #Grab Rank reports for a specific client
|
55
|
-
testcon.get_ranking_reports(:clientid => 'client-id', :locationid=> 'location-id') # Grab specific location for specific client
|
56
|
-
testcon.get_ranking_reports(:reportid => 'report-id') #Grab a specific ranking report
|
57
|
-
testcon.get_ranking_reports(:reportid => 'report-id', :historical => true) #Return chart for average rankings over time
|
58
|
-
testcon.get_ranking_reports(:reportid => 'report-id', :historical => true, :keywords => true) #Return chart for keyword rankings over time
|
59
|
-
testcon.get_ranking_reports(:reportid => 'report-id', :rundates => true) # Return run dates and ID's for a report
|
60
|
-
testcon.get_ranking_reports(:reportid => 'report-id', :runs => true) #Grab the runs for a report
|
61
|
-
testcon.get_ranking_reports(:reportid => 'report-id', :runs => true, :runid => 'run-id') #Grab a specific report run
|
62
|
-
testcon.get_ranking_reports(:reportid => 'report-id', :runs => true, :runid => 'run-id', :keywordresults => true) #Grab a specific report run keyword results
|
63
|
-
testcon.get_ranking_reports(:reportid => 'report-id', :runs => true, :runid => 'run-id', :keywordresults => true, :keywordresultsid => 'keyword-results-id') #Grab a specific keyword result for a specific report run
|
64
|
-
testcon.get_ranking_reports(:reportid => 'report-id', :runs => true, :runid => 'run-id', :keywordserpscreenshot => 'adhesion treatment' , :googlelocation => 'San Luis Obispo, CA') #Google Organic SERP Page
|
65
|
-
testcon.get_ranking_reports(:reportid => 'report-id', :runs => true, :runid => 'run-id', :summary => true) # Grab summary metrics
|
66
|
-
testcon.get_ranking_reports(:reportid => 'report-id', :runs => true, :newest => true) # Grab newest if :newest => true. Grab oldest if :newest => false
|
101
|
+
puts testcon.get_ranking_reports(opts)
|
67
102
|
```
|
68
103
|
|
69
|
-
|
104
|
+
# GET /rankingreports/{clientId}/allbyclient
|
105
|
+
All rank reports for client
|
70
106
|
```ruby
|
71
|
-
|
107
|
+
opts = {}
|
108
|
+
opts[:clientid] = '<client-id>'
|
109
|
+
puts testcon.get_ranking_reports(opts)
|
72
110
|
```
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
111
|
+
# GET /rankingreports/{ReportId}
|
112
|
+
Returns the ranking report configuration data for the given RankingReportId
|
113
|
+
```ruby
|
114
|
+
opts = {}
|
115
|
+
opts[:ReportId] = '<report-id>'
|
116
|
+
puts testcon.get_ranking_reports(opts)
|
117
|
+
```
|
118
|
+
# GET /rankingreports/{ReportId}/historical
|
119
|
+
Returns historical data that can be used to display charts over time for the given RankingReportId
|
120
|
+
```ruby
|
121
|
+
opts = {}
|
122
|
+
opts[:ReportId] = '<report-id>'
|
123
|
+
opts[:historical] = true
|
124
|
+
puts testcon.get_ranking_reports(opts)
|
125
|
+
```
|
126
|
+
# GET /rankingreports/{ReportId}/historical/keywords
|
127
|
+
Returns historical data for each keyword search that can be used to display charts over time for the given RankingReportId
|
128
|
+
```ruby
|
129
|
+
opts = {}
|
130
|
+
opts[:ReportId] = '<report-id>'
|
131
|
+
opts[:historical] = true
|
132
|
+
opts[:keywords] = true
|
133
|
+
puts testcon.get_ranking_reports(opts)
|
134
|
+
```
|
135
|
+
# GET /rankingreports/{ReportId}/rundatesandids
|
136
|
+
Returns report run ids and dates
|
137
|
+
```ruby
|
138
|
+
opts = {}
|
139
|
+
opts[:ReportId] = '<report-id>'
|
140
|
+
opts[:rundatesandids] = true
|
141
|
+
puts testcon.get_ranking_reports(opts)
|
142
|
+
```
|
143
|
+
# GET /rankingreports/{ReportId}/runs
|
144
|
+
Returns all runs of a report
|
145
|
+
```ruby
|
146
|
+
opts = {}
|
147
|
+
opts[:ReportId] = '<report-id>'
|
148
|
+
opts[:runs] = true
|
149
|
+
puts testcon.get_ranking_reports(opts)
|
150
|
+
```
|
151
|
+
# GET /rankingreports/{ReportId}/runs/{reportRunId}
|
152
|
+
Returns a ranking report run based on the passed ReportRunId
|
153
|
+
```ruby
|
154
|
+
opts = {}
|
155
|
+
opts[:ReportId] = '<report-id>'
|
156
|
+
opts[:reportRunId] = '<report-run-id>'
|
157
|
+
puts testcon.get_ranking_reports(opts)
|
158
|
+
```
|
159
|
+
# GET /rankingreports/{ReportId}/runs/{reportRunId}/keywordsearchresults
|
160
|
+
Returns a list of all keyword search results for a given ranking report run
|
161
|
+
```ruby
|
162
|
+
opts = {}
|
163
|
+
opts[:ReportId] = '<report-id>'
|
164
|
+
opts[:reportRunId] = '<report-run-id>'
|
165
|
+
opts[:keywordsearchresults] = true
|
166
|
+
puts testcon.get_ranking_reports(opts)
|
167
|
+
```
|
168
|
+
# GET /rankingreports/{ReportId}/runs/{reportRunId}/keywordsearchresults/{keywordSearchResultsId}
|
169
|
+
Returns a list of all keyword search results for a given ranking report run
|
170
|
+
```ruby
|
171
|
+
opts = {}
|
172
|
+
opts[:ReportId] = '<report-id>'
|
173
|
+
opts[:reportRunId] = '<report-run-id>'
|
174
|
+
opts[:keywordsearchresults] = true
|
175
|
+
opts[:KeywordSearchResultsId] = '<report-run-id>-surgery-for-adhesions-san-luis-obispo-ca'
|
176
|
+
puts testcon.get_ranking_reports(opts)
|
177
|
+
```
|
178
|
+
# GET /rankingreports/{ReportId}/runs/{reportRunId}/keywordserpscreenshot
|
179
|
+
Returns a byte array of image data for the first Google Organic SERP Page for the provided ReportId, reportRunId, keyword, and location setting if the ranking report is configured to gather screenshots
|
180
|
+
```ruby
|
181
|
+
opts = {}
|
182
|
+
opts[:ReportId] = '<report-id>'
|
183
|
+
opts[:reportRunId] = '<report-run-id>'
|
184
|
+
opts[:keywordsearchresults] = true
|
185
|
+
opts[:GoogleLocation] = ''
|
186
|
+
puts testcon.get_ranking_reports(opts)
|
187
|
+
```
|
188
|
+
# GET /rankingreports/{ReportId}/runs/{reportRunId}/summarymetrics
|
189
|
+
Returns the ranking summary metrics for the passed ReportRunId
|
190
|
+
```ruby
|
191
|
+
opts = {}
|
192
|
+
opts[:ReportId] = '<report-id>'
|
193
|
+
opts[:reportRunId] = '<report-run-id>'
|
194
|
+
opts[:summarymetrics] = true
|
195
|
+
puts testcon.get_ranking_reports(opts)
|
196
|
+
```
|
197
|
+
# GET /rankingreports/{ReportId}/runs/newest
|
198
|
+
Returns the newest runs of a report
|
199
|
+
```ruby
|
200
|
+
opts = {}
|
201
|
+
opts[:ReportId] = '<report-id>'
|
202
|
+
opts[:age] = "oldest" || "newest"
|
203
|
+
puts testcon.get_ranking_reports(opts)
|
204
|
+
```
|
205
|
+
# GET /rankingreports/all
|
206
|
+
Retrieving all ranking report data
|
207
|
+
```ruby
|
208
|
+
opts = {}
|
209
|
+
opts[:all] = true
|
210
|
+
puts testcon.get_ranking_reports(opts)
|
211
|
+
```
|
212
|
+
# POST /rankingreports/{ReportId}/runreport
|
213
|
+
Run a ranking report
|
214
|
+
```ruby
|
215
|
+
opts = {}
|
216
|
+
opts[:ReportId] = '<report-id>'
|
217
|
+
puts testcon.run_ranking_report(opts)
|
162
218
|
```
|
163
219
|
|
220
|
+
# DELETE /rankingreports/{ReportId}
|
221
|
+
```ruby
|
222
|
+
opts = {}
|
223
|
+
opts[:ReportId] = '<report-id>'
|
224
|
+
puts testcon.delete_ranking_report(opts)
|
225
|
+
```
|
164
226
|
|
227
|
+
###Reputation Reports
|
228
|
+
```ruby
|
229
|
+
opts = {}
|
230
|
+
opts[:clientid] = '<client-id>'
|
231
|
+
opts[:ReportId] = '<report-id>'
|
232
|
+
opts[:reportRunId] = '<report-run-id>'
|
233
|
+
opts[:historical] = true
|
234
|
+
opts[:newreviews] = true
|
235
|
+
opts[:reviews] = true
|
236
|
+
opts[:source] = "Yelp"
|
237
|
+
opts[:rundatesandids] = true
|
238
|
+
opts[:runs] = true
|
239
|
+
puts testcon.get_reputation_reports(opts)
|
240
|
+
```
|
241
|
+
|
242
|
+
## POST /reputationreports/{reportId}/runreport
|
243
|
+
Runs the passed reputation report, placing the request in the queue to run the report
|
244
|
+
```ruby
|
245
|
+
opts = {}
|
246
|
+
opts[:ReportId] = '<report-id>'
|
247
|
+
opts[:FullScrape] = true
|
248
|
+
puts testcon.run_reputation_report(opts)
|
249
|
+
```
|
250
|
+
|
251
|
+
## Delete Reputation Report or Reputation Report Run
|
252
|
+
Pass a report id to delete the report and all runs, add a run id to only delete that run.
|
253
|
+
```ruby
|
254
|
+
opts = {}
|
255
|
+
opts[:ReportId] = '<report-id>'
|
256
|
+
opts[:ReportRunId] = '<report-run-id>'
|
257
|
+
puts testcon.delete_reputation_report(opts)
|
258
|
+
```
|
259
|
+
|
260
|
+
|
261
|
+
###Combined Reports
|
262
|
+
# GET /combinedclientreports
|
263
|
+
All rank reports, or for client or location
|
264
|
+
```ruby
|
265
|
+
opts = {}
|
266
|
+
opts[:clientid] = '<client-id>'
|
267
|
+
puts testcon.get_combined_reports(opts)
|
268
|
+
```
|
269
|
+
### Status
|
270
|
+
```ruby
|
271
|
+
testcon.get_status #Grab the status of all reports
|
272
|
+
```
|
165
273
|
## Development
|
166
274
|
|
167
275
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/places_scout.rb
CHANGED
@@ -11,125 +11,246 @@ module PlacesScout
|
|
11
11
|
# RestClient.log = 'stdout' #Debugging API calls
|
12
12
|
MAX_PAGE_SIZE = '100'
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(opts = {})
|
15
15
|
@url = 'https://apihost1.placesscout.com'
|
16
|
-
@auth = 'Basic ' + Base64.encode64(
|
16
|
+
@auth = 'Basic ' + Base64.encode64(opts[:username] + ':' + opts[:password]).chomp
|
17
17
|
end
|
18
18
|
|
19
19
|
def parse_json(response)
|
20
|
-
body = JSON.parse(response.to_str) if response.code == 200
|
20
|
+
body = JSON.parse(response.to_str) if response.code == 200 || response.code == 201
|
21
21
|
OpenStruct.new(code: response.code, body: body)
|
22
22
|
end
|
23
23
|
|
24
|
+
def set_params(opts = {})
|
25
|
+
params = {}
|
26
|
+
#Result params
|
27
|
+
params[:size] = opts[:size] || MAX_PAGE_SIZE
|
28
|
+
params[:path] = opts[:path] if opts[:path]
|
29
|
+
params[:page] = opts[:page] || 1
|
30
|
+
#Client params
|
31
|
+
params[:Name] = opts[:Name] if opts[:Name] #String
|
32
|
+
params[:CustomClientId] = opts[:CustomClientId] if opts[:CustomClientId] #String
|
33
|
+
params[:PrimaryEmail] = opts[:PrimaryEmail] if opts[:PrimaryEmail] #String
|
34
|
+
params[:Website] = opts[:Website] if opts[:Website] #String
|
35
|
+
params[:Industry] = opts[:Industry] if opts[:Industry] #String
|
36
|
+
params[:Categories] = opts[:Categories] if opts[:Categories] #List
|
37
|
+
params[:ClientYextSettings] = opts[:ClientYextSettings] if opts[:ClientYextSettings]
|
38
|
+
params[:GoogleAccountId] = opts[:GoogleAccountId] if opts[:GoogleAccountId] #String
|
39
|
+
params[:GoogleWebPropertyId] = opts[:GoogleWebPropertyId] if opts[:GoogleWebPropertyId] #String
|
40
|
+
params[:GoogleProfileId] = opts[:GoogleProfileId] if opts[:GoogleProfileId] #String
|
41
|
+
params[:GoogleAnalyticsReportSections] = opts[:GoogleAnalyticsReportSections] if opts[:GoogleAnalyticsReportSections] #List
|
42
|
+
#Location params
|
43
|
+
params[:clientid] = opts[:clientid] if opts[:clientid]
|
44
|
+
params[:locationid] = opts[:locationid] if opts[:locationid]
|
45
|
+
params[:BusinessName] = opts[:BusinessName] if opts[:BusinessName]
|
46
|
+
params[:LocationName] = opts[:LocationName] if opts[:LocationName]
|
47
|
+
params[:StreetAddress] = opts[:StreetAddress] if opts[:StreetAddress]
|
48
|
+
params[:StreetAddress2] = opts[:StreetAddress2] if opts[:StreetAddress]
|
49
|
+
params[:City] = opts[:City] if opts[:City]
|
50
|
+
params[:State] = opts[:State] if opts[:State]
|
51
|
+
params[:Zip] = opts[:Zip] if opts[:Zip]
|
52
|
+
params[:Country] = opts[:Country] if opts[:Country]
|
53
|
+
params[:Phone] = opts[:Phone] if opts[:Phone]
|
54
|
+
params[:Email] = opts[:Email] if opts[:Email]
|
55
|
+
params[:CustomLocationId] = opts[:CustomLocationId] if opts[:CustomLocationId]
|
56
|
+
params[:Region] = opts[:Region] if opts[:Region]
|
57
|
+
params[:StoreNumber] = opts[:StoreNumber] if opts[:StoreNumber]
|
58
|
+
params[:PlusLocalPageLink] = opts[:PlusLocalPageLink] if opts[:PlusLocalPageLink]
|
59
|
+
params[:ListingSites] = opts[:ListingSites] if opts[:ListingSites]
|
60
|
+
params[:YextApiKey] = opts[:YextApiKey] if opts[:YextApiKey]
|
61
|
+
params[:YextCustomerId] = opts[:YextCustomerId] if opts[:YextCustomerId]
|
62
|
+
params[:YextLocationId] = opts[:YextLocationId] if opts[:YextLocationId]
|
63
|
+
params[:LocationGroupId] = opts[:LocationGroupId] if opts[:LocationGroupId]
|
64
|
+
#Ranking Reports
|
65
|
+
params[:Keyword] = opts[:keywordserpscreenshot] if opts[:keywordserpscreenshot]
|
66
|
+
params[:GoogleLocation] = opts[:googlelocation] if opts[:googlelocation]
|
67
|
+
#Reputation Reports
|
68
|
+
params[:FullScrape] = opts[:FullScrape] if opts[:FullScrape]
|
69
|
+
|
70
|
+
return params
|
71
|
+
end
|
72
|
+
|
73
|
+
def get_responses(opts = {})
|
74
|
+
responses = []
|
75
|
+
params = set_params(opts)
|
76
|
+
response = parse_json(RestClient.get(@url+opts[:path], params: params,:content_type => 'application/json', :accept => 'application/json', :Authorization => @auth)).body
|
77
|
+
|
78
|
+
total_records = response["total"] || 1
|
79
|
+
size = response["size"] || 1
|
80
|
+
total_pages = (total_records.to_f/size).ceil || 1
|
81
|
+
|
82
|
+
while total_pages > 0
|
83
|
+
response = (opts[:data]) ? response[opts[:data]] : response
|
84
|
+
responses.push(response)
|
85
|
+
params[:page] += 1 unless opts[:page]
|
86
|
+
total_pages -= 1
|
87
|
+
response = parse_json(RestClient.get(@url+params[:path], params: params,:content_type => 'application/json', :accept => 'application/json', :Authorization => @auth)).body unless total_pages < 1
|
88
|
+
end
|
89
|
+
|
90
|
+
return responses.flatten! || responses
|
91
|
+
end
|
92
|
+
|
24
93
|
# /clients
|
25
94
|
def get_clients( opts = {})
|
95
|
+
opts[:path] = "/clients/#{opts[:clientid] || ((opts[:names_and_ids]) ? "namesandids" : "")}"
|
96
|
+
opts[:data] = "items" unless opts[:clientid]
|
97
|
+
return get_responses(opts)
|
98
|
+
end
|
99
|
+
|
100
|
+
def create_client( opts = {})
|
101
|
+
params = set_params(opts)
|
102
|
+
path = "/clients"
|
103
|
+
response = parse_json(RestClient.post(@url+path, params ,:content_type => 'application/json', :accept => 'application/json', :Authorization => @auth))
|
104
|
+
return response
|
105
|
+
end
|
106
|
+
|
107
|
+
def update_client( opts = {})
|
108
|
+
params = set_params(opts)
|
26
109
|
path = "/clients/#{opts[:clientid]}"
|
27
|
-
|
28
|
-
|
29
|
-
params[:page] = opts[:page] || 1
|
30
|
-
params[:size] = opts[:size] || MAX_PAGE_SIZE
|
31
|
-
total_size = parse_json(RestClient.get(@url+path, params: params, :content_type => 'application/json', :accept => 'application/json', :Authorization => @auth)).body['total'] || 1
|
32
|
-
total_pages = (opts[:page]) ? 1 : (total_size/params[:size].to_f).ceil
|
33
|
-
|
34
|
-
while total_pages > 0
|
35
|
-
response = parse_json(RestClient.get(@url+path, params: params, :content_type => 'application/json', :accept => 'application/json', :Authorization => @auth)).body
|
36
|
-
results.push(response)
|
37
|
-
params[:page] += 1 unless opts[:page]
|
38
|
-
total_pages -= 1
|
39
|
-
end
|
110
|
+
return parse_json(RestClient.put(@url+path, params,:content_type => 'application/json', :accept => 'application/json', :Authorization => @auth)).body
|
111
|
+
end
|
40
112
|
|
41
|
-
|
113
|
+
def delete_client ( opts = {} )
|
114
|
+
if opts[:clientid]
|
115
|
+
path = "/clients/#{opts[:clientid]}"
|
116
|
+
return RestClient.delete(@url+path, :Authorization => @auth)
|
117
|
+
else
|
118
|
+
return "Must pass client id"
|
119
|
+
end
|
42
120
|
end
|
43
121
|
|
44
122
|
# Client Locations
|
45
123
|
def get_client_locations( opts = {})
|
46
|
-
path = "/clientlocations/#{opts[:locationid]}"
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
params[:size] = opts[:size] || MAX_PAGE_SIZE
|
51
|
-
params[:clientid] = opts[:clientid]
|
52
|
-
location = opts[:locationid]
|
53
|
-
total_size = parse_json(RestClient.get(@url+path, params: params, :content_type => 'application/json', :accept => 'application/json', :Authorization => @auth)).body['total'] || 1
|
54
|
-
total_pages = (opts[:page]) ? 1 : (total_size/params[:size].to_f).ceil
|
124
|
+
opts[:path] = "/clientlocations/#{opts[:locationid]}"
|
125
|
+
opts[:data] = "items" unless opts[:locationid]
|
126
|
+
return get_responses(opts)
|
127
|
+
end
|
55
128
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
129
|
+
def create_client_location( opts = {})
|
130
|
+
params = set_params(opts)
|
131
|
+
path = "/clientlocations"
|
132
|
+
response = parse_json(RestClient.post(@url+path, params ,:content_type => 'application/json', :accept => 'application/json', :Authorization => @auth))
|
133
|
+
return response
|
134
|
+
end
|
135
|
+
|
136
|
+
def delete_client_location ( opts = {} )
|
137
|
+
if opts[:LocationId]
|
138
|
+
path = "/clientlocations/#{opts[:LocationId]}"
|
139
|
+
return RestClient.delete(@url+path, :Authorization => @auth)
|
140
|
+
else
|
141
|
+
return "Must pass location id"
|
61
142
|
end
|
62
|
-
return results
|
63
143
|
end
|
64
144
|
|
65
145
|
# /folders
|
66
|
-
def get_client_folders( opts = {})
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
params[:size] = opts[:size] || MAX_PAGE_SIZE
|
71
|
-
params[:clientid] = opts[:clientid]
|
72
|
-
path = "/clientfolders"
|
73
|
-
total_size = parse_json(RestClient.get(@url+path, params: params, :content_type => 'application/json', :accept => 'application/json', :Authorization => @auth)).body['total'] || 1
|
74
|
-
total_pages = (opts[:page]) ? 1 : (total_size/params[:size].to_f).ceil
|
75
|
-
|
76
|
-
while total_pages > 0
|
77
|
-
response = parse_json(RestClient.get(@url+path, params: params, :content_type => 'application/json', :accept => 'application/json', :Authorization => @auth)).body
|
78
|
-
results.push(response)
|
79
|
-
params[:page] += 1 unless opts[:page]
|
80
|
-
total_pages -= 1
|
81
|
-
end
|
82
|
-
return results
|
146
|
+
def get_client_folders( opts = {})
|
147
|
+
opts[:path] = "/clientfolders"
|
148
|
+
opts[:data] = "items"
|
149
|
+
return get_responses(opts)
|
83
150
|
end
|
84
151
|
|
152
|
+
# /combinedreports
|
153
|
+
def get_combined_reports( opts = {})
|
154
|
+
opts[:path] = "/combinedclientreports"
|
155
|
+
opts[:data] = "items"
|
156
|
+
return get_responses(opts)
|
157
|
+
end
|
158
|
+
|
85
159
|
# /rankingreports
|
86
160
|
def get_ranking_reports( opts = {})
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
end
|
111
|
-
|
112
|
-
path = (opts[:clientid] && params[:locationid] == "" && all == "") ? "/rankingreports/#{opts[:clientid]}/allbyclient" : "/rankingreports#{all}#{reportid}#{rundates}#{runs}#{newest}#{runid}#{summary}#{historical}#{keywords}#{keywordresults}#{keywordresultsid}#{keywordserpscreenshot}"
|
113
|
-
params[:Keyword] = opts[:keywordserpscreenshot] if opts[:keywordserpscreenshot]
|
114
|
-
params[:GoogleLocation] = opts[:googlelocation] if opts[:googlelocation]
|
115
|
-
params[:page] = opts[:page] || 1
|
116
|
-
params[:size] = opts[:size] || MAX_PAGE_SIZE
|
117
|
-
total_size = parse_json(RestClient.get(@url+path, params: params, :content_type => 'application/json', :accept => 'application/json', :Authorization => @auth)).body['total'] || 1
|
118
|
-
total_pages = (opts[:page] || opts[:locationid]) ? 1 : (total_size/params[:size].to_f).ceil
|
119
|
-
|
120
|
-
while total_pages > 0
|
121
|
-
response = parse_json(RestClient.get(@url+path, params: params, :content_type => 'application/json', :accept => 'application/json', :Authorization => @auth)).body
|
122
|
-
results.push(response)
|
123
|
-
params[:page] += 1 unless opts[:page]
|
124
|
-
total_pages -= 1
|
161
|
+
|
162
|
+
opts[:path] = "/rankingreports/"
|
163
|
+
|
164
|
+
if opts[:clientid]
|
165
|
+
opts[:path] += "#{opts[:clientid]}/allbyclient"
|
166
|
+
elsif opts[:ReportId]
|
167
|
+
opts[:path] += "#{opts[:ReportId]}/"
|
168
|
+
if opts[:historical]
|
169
|
+
opts[:path] += "historical"
|
170
|
+
opts[:path] += "/keywords" if opts[:keywords]
|
171
|
+
elsif opts[:rundatesandids]
|
172
|
+
opts[:path] += "rundatesandids"
|
173
|
+
elsif opts[:runs] || opts[:reportRunId]
|
174
|
+
opts[:path] += "runs/#{opts[:age]}"
|
175
|
+
if opts[:reportRunId] && opts[:age].nil?
|
176
|
+
opts[:path] += "/#{opts[:reportRunId]}"
|
177
|
+
opts[:path] += "/keywordsearchresults" if opts[:keywordsearchresults]
|
178
|
+
opts[:path] += "/#{opts[:KeywordSearchResultsId]}" if opts[:KeywordSearchResultsId]
|
179
|
+
opts[:path] += "/summarymetrics" if opts[:summarymetrics]
|
180
|
+
end
|
181
|
+
end
|
182
|
+
elsif opts[:all]
|
183
|
+
opts[:path] += "all"
|
125
184
|
end
|
126
|
-
|
185
|
+
|
186
|
+
opts[:data] = "items" unless (opts[:ReportId] && opts[:runs].nil? && opts[:rundatesandids].nil? && opts[:keywordsearchresults].nil?) || opts[:KeywordSearchResultsId]
|
187
|
+
|
188
|
+
return get_responses(opts)
|
189
|
+
end
|
190
|
+
|
191
|
+
def run_ranking_report( opts = {})
|
192
|
+
path = "/rankingreports/#{opts[:ReportId]}/runreport"
|
193
|
+
params = {:ReportId => opts[:ReportId]}
|
194
|
+
response = RestClient.post(@url+path, params ,:content_type => 'application/json', :accept => 'application/json', :Authorization => @auth)
|
195
|
+
return response
|
196
|
+
end
|
197
|
+
|
198
|
+
def delete_ranking_report ( opts = {} )
|
199
|
+
path = "/rankingreports/#{opts[:ReportId]}"
|
200
|
+
path += "/runs/#{opts[:reportRunId]}" if opts[:reportRunId]
|
201
|
+
return RestClient.delete(@url+path, :Authorization => @auth)
|
202
|
+
end
|
203
|
+
|
204
|
+
#Reputation Reports
|
205
|
+
|
206
|
+
def get_reputation_reports ( opts = {})
|
207
|
+
opts[:path] = "/reputationreports/"
|
208
|
+
|
209
|
+
if opts[:clientid]
|
210
|
+
opts[:path] += "#{opts[:clientid]}/allbyclient"
|
211
|
+
elsif opts[:ReportId]
|
212
|
+
opts[:path] += "#{opts[:ReportId]}/"
|
213
|
+
if opts[:historical]
|
214
|
+
opts[:path] += "historical"
|
215
|
+
elsif opts[:newreviews]
|
216
|
+
opts[:path] += "newreviews"
|
217
|
+
elsif opts[:reviews] || opts[:source]
|
218
|
+
opts[:path] += "reviews"
|
219
|
+
opts[:path] += "/#{opts[:source]}"if opts[:source]
|
220
|
+
elsif opts[:rundatesandids]
|
221
|
+
opts[:path] += "rundatesandids"
|
222
|
+
elsif opts[:runs] || opts[:reportRunId]
|
223
|
+
opts[:path] += "runs"
|
224
|
+
opts[:path] += "/#{opts[:reportRunId]}" if opts[:reportRunId]
|
225
|
+
opts[:path] += "/newest" if opts[:newest]
|
226
|
+
opts[:path] += "/oldest" if opts[:oldest]
|
227
|
+
end
|
228
|
+
|
229
|
+
else
|
230
|
+
opts[:path] += "all"
|
231
|
+
end
|
232
|
+
|
233
|
+
opts[:data] = "items" unless (opts[:ReportId] && opts[:reviews].nil? && opts[:rundatesandids].nil?)
|
234
|
+
return get_responses(opts)
|
235
|
+
|
236
|
+
end
|
237
|
+
|
238
|
+
def run_reputation_report( opts = {})
|
239
|
+
path = "/reputationreports/#{opts[:ReportId]}/runreport"
|
240
|
+
params = set_params(opts)
|
241
|
+
response = RestClient.post(@url+path, params ,:content_type => 'application/json', :accept => 'application/json', :Authorization => @auth)
|
242
|
+
return response
|
243
|
+
end
|
244
|
+
|
245
|
+
def delete_reputation_report ( opts = {} )
|
246
|
+
path = "/reputationreports/#{opts[:ReportId]}"
|
247
|
+
path += "/runs/#{opts[:reportRunId]}" if opts[:reportRunId]
|
248
|
+
return RestClient.delete(@url+path, :Authorization => @auth)
|
127
249
|
end
|
128
250
|
|
129
251
|
def get_status( opts = {})
|
130
252
|
results = []
|
131
253
|
params = {}
|
132
|
-
reportid = "/#{opts[:reportid]}" || ""
|
133
254
|
path = "/status/getreportstatus"
|
134
255
|
response = parse_json(RestClient.get(@url+path, params: params, :content_type => 'application/json', :accept => 'application/json', :Authorization => @auth)).body
|
135
256
|
end
|
data/lib/places_scout/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: places_scout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Hoskison
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
106
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
107
|
+
rubygems_version: 2.6.8
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Used to access the Places Scout api
|