outscraper 0.3.4 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/outscraper/version.rb +1 -1
- data/lib/outscraper.rb +86 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9476b68f4bd7fc5b7af263cc5cb28b5e753960d760c44d1e697681123aee6236
|
|
4
|
+
data.tar.gz: 298ec43dbdec09108bbf6e98660b0e1150dce799d3408740a2c6d8fdbfd33c43
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fb819008c8e1a0e634c4a73779842810153156b7c22fc2ce94954e8a030ee363d8dc57127a0db61e190b40dab50d349a93c852d5faf1ebe1cefeba7b7674dde0
|
|
7
|
+
data.tar.gz: 2b8beb1a3fdf33a45d0bfc20f293516b535106dfb723f5499f831fea583e5f5788423033939665ce109536ac804ecb2b47dd17f016265f860c45efdb197a7fe2
|
data/lib/outscraper/version.rb
CHANGED
data/lib/outscraper.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "httparty"
|
|
4
|
+
require "cgi"
|
|
5
|
+
require "json"
|
|
4
6
|
|
|
5
7
|
require_relative "outscraper/version"
|
|
6
8
|
|
|
@@ -391,5 +393,89 @@ module Outscraper
|
|
|
391
393
|
webhook: webhook
|
|
392
394
|
}).parsed_response['data']
|
|
393
395
|
end
|
|
396
|
+
|
|
397
|
+
def postAPIRequest(path, parameters = {})
|
|
398
|
+
payload = parameters || {}
|
|
399
|
+
|
|
400
|
+
response = self.class.post(
|
|
401
|
+
path,
|
|
402
|
+
headers: { 'Content-Type' => 'application/json' },
|
|
403
|
+
body: payload.to_json
|
|
404
|
+
).parsed_response
|
|
405
|
+
|
|
406
|
+
response.is_a?(Hash) && response.key?('data') ? response['data'] : response
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
def businessesSearch(
|
|
410
|
+
filters: {},
|
|
411
|
+
limit: 10,
|
|
412
|
+
include_total: false,
|
|
413
|
+
cursor: nil,
|
|
414
|
+
fields: nil,
|
|
415
|
+
async_request: false,
|
|
416
|
+
ui: false,
|
|
417
|
+
webhook: nil
|
|
418
|
+
)
|
|
419
|
+
payload = {
|
|
420
|
+
filters: (filters || {}),
|
|
421
|
+
limit: limit,
|
|
422
|
+
include_total: include_total,
|
|
423
|
+
cursor: cursor,
|
|
424
|
+
fields: fields ? Array(fields) : nil,
|
|
425
|
+
async: async_request,
|
|
426
|
+
ui: ui,
|
|
427
|
+
webhook: webhook
|
|
428
|
+
}.compact
|
|
429
|
+
|
|
430
|
+
postAPIRequest('/businesses', payload)
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
def businessesIterSearch(filters: {}, limit: 10, fields: nil, include_total: false)
|
|
434
|
+
cursor = nil
|
|
435
|
+
all_items = []
|
|
436
|
+
|
|
437
|
+
loop do
|
|
438
|
+
page = businessesSearch(
|
|
439
|
+
filters: filters,
|
|
440
|
+
limit: limit,
|
|
441
|
+
include_total: include_total,
|
|
442
|
+
cursor: cursor,
|
|
443
|
+
fields: fields,
|
|
444
|
+
async_request: false
|
|
445
|
+
)
|
|
446
|
+
|
|
447
|
+
items = page.is_a?(Hash) ? (page['items'] || []) : []
|
|
448
|
+
break if !items.is_a?(Array) || items.empty?
|
|
449
|
+
|
|
450
|
+
all_items.concat(items)
|
|
451
|
+
|
|
452
|
+
has_more = !!(page['has_more'])
|
|
453
|
+
next_cursor = page['next_cursor']
|
|
454
|
+
break if !has_more || next_cursor.nil? || next_cursor.to_s.strip.empty?
|
|
455
|
+
|
|
456
|
+
cursor = next_cursor.to_s
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
all_items
|
|
460
|
+
end
|
|
461
|
+
|
|
462
|
+
def businessesGet(business_id, fields: nil, async_request: false, ui: false, webhook: nil)
|
|
463
|
+
raise ArgumentError, 'business_id is required' if business_id.nil? || business_id.to_s.strip.empty?
|
|
464
|
+
|
|
465
|
+
fields_param =
|
|
466
|
+
if fields.is_a?(Array)
|
|
467
|
+
fields.map(&:to_s).join(',')
|
|
468
|
+
else
|
|
469
|
+
fields
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
response = self.class.get("/businesses/#{CGI.escape(business_id.to_s)}", query: {
|
|
473
|
+
fields: fields_param,
|
|
474
|
+
async: async_request,
|
|
475
|
+
ui: ui,
|
|
476
|
+
webhook: webhook
|
|
477
|
+
}.compact).parsed_response
|
|
478
|
+
response.is_a?(Hash) && response.key?('data') ? response['data'] : response
|
|
479
|
+
end
|
|
394
480
|
end
|
|
395
481
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: outscraper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Outscraper
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: httparty
|