cloudscrape-client 0.1.4 → 0.2.1
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/README.md +4 -6
- data/cloudscrape-client-ruby.gemspec +3 -2
- data/lib/cloudscrape/client.rb +1 -0
- data/lib/cloudscrape_client.rb +27 -0
- data/lib/{cloud_scrape → cloudscrape_client}/api.rb +11 -7
- data/lib/{cloud_scrape → cloudscrape_client}/configuration.rb +1 -1
- data/lib/{cloud_scrape → cloudscrape_client}/dto.rb +6 -6
- data/lib/{cloud_scrape → cloudscrape_client}/execution_dto.rb +1 -1
- data/lib/{cloud_scrape → cloudscrape_client}/executions.rb +4 -4
- data/lib/{cloud_scrape → cloudscrape_client}/executions/get.rb +1 -1
- data/lib/{cloud_scrape → cloudscrape_client}/executions/result.rb +2 -2
- data/lib/{cloud_scrape → cloudscrape_client}/run_dto.rb +1 -1
- data/lib/{cloud_scrape → cloudscrape_client}/runs.rb +2 -2
- data/lib/{cloud_scrape → cloudscrape_client}/validate.rb +4 -4
- data/lib/cloudscrape_client/version.rb +3 -0
- metadata +15 -14
- data/lib/cloud_scrape.rb +0 -27
- data/lib/cloud_scrape/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e0ac2830d65a7834db84b53d7c8af64b5f76ee0
|
4
|
+
data.tar.gz: f99c2d71c6728807c47bf50a2f13a55cfbf17a88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef9941b4f297ce7dfadc48a8c6b525fe783e80987da29afb76cc13f06fe82311ba9b6c36c7f00596872733f52c13337456c14693f05465cb3c794817869b952a
|
7
|
+
data.tar.gz: 3689fc8fc7a9b6b51aac48ac7ec2e6a5339d040e13aafc4d3e17c3c8a37add95ace06e2e5f2bb04d4cad2409b7cb64f71549b5dee60d5614bd232a6fbc59565e
|
data/README.md
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
# CloudScrape Ruby Client [](https://travis-ci.org/cloudscrape/cloudscrape-client-ruby)
|
1
|
+
# CloudScrape Ruby Client [](https://travis-ci.org/cloudscrape/cloudscrape-client-ruby) [](https://badge.fury.io/rb/cloudscrape-client)
|
2
2
|
|
3
3
|
Wrapper for CloudScrape API.
|
4
4
|
|
5
5
|
* [API Documentation](https://app.cloudscrape.com/#/api)
|
6
6
|
* [Support](https://cloudscrape.zendesk.com/hc/en-us)
|
7
7
|
|
8
|
-
|
9
|
-
|
10
8
|
## Requirements
|
11
9
|
|
12
10
|
* Ruby `> 1.9.x`
|
@@ -28,7 +26,7 @@ Or install it yourself as:
|
|
28
26
|
## Configuration
|
29
27
|
|
30
28
|
``` ruby
|
31
|
-
|
29
|
+
CloudscrapeClient.configure do |config|
|
32
30
|
config.base_url = "https://app.cloudscrape.com/api/"
|
33
31
|
config.api_key = "pol6BFzsASYw4gQBl02b24nt"
|
34
32
|
config.account_id = "a814a8r2-a664-4rcb-759c-9de21744117a"
|
@@ -55,7 +53,7 @@ CLOUD_SCRAPE_CLIENT_VERBOSE=true
|
|
55
53
|
* `base_url` sets the CloudScrape API url `https://app.cloudscrape.com/api/`
|
56
54
|
* `api_key` sets the CloudScrape API Key `nil`
|
57
55
|
* `user_agent_app` sets the UserAgent app sent to CloudScrape `CS-RUBY-CLIENT`
|
58
|
-
* `user_agent_version` sets the UserAgent version sent to
|
56
|
+
* `user_agent_version` sets the UserAgent version sent to CloudscrapeClient `1.0`
|
59
57
|
* `timeout` sets the CloudScrape API request timeout `3600`
|
60
58
|
* `verbose` should all output be printed to STDOUT `false`
|
61
59
|
* `logger` Logger object. `Logger`
|
@@ -64,7 +62,7 @@ CLOUD_SCRAPE_CLIENT_VERBOSE=true
|
|
64
62
|
|
65
63
|
``` ruby
|
66
64
|
# Create client (optional arguments to override configuration)
|
67
|
-
client =
|
65
|
+
client = CloudscrapeClient.new(
|
68
66
|
api_key: "pol6BFzsASYw4gQBl02b24nt",
|
69
67
|
account_id: "a814a8r2-a664-4rcb-759c-9de21744117a"
|
70
68
|
)
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
|
4
|
+
|
5
|
+
require "cloudscrape_client/version"
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
8
|
spec.name = "cloudscrape-client"
|
8
|
-
spec.version =
|
9
|
+
spec.version = CloudscrapeClient::VERSION
|
9
10
|
spec.authors = ["Charles J Hardy"]
|
10
11
|
spec.email = ["support@cloudscrape.com"]
|
11
12
|
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative "../cloudscrape_client"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "logger"
|
2
|
+
|
3
|
+
require "cloudscrape_client/version"
|
4
|
+
require "cloudscrape_client/configuration"
|
5
|
+
require "cloudscrape_client/dto"
|
6
|
+
require "cloudscrape_client/runs"
|
7
|
+
require "cloudscrape_client/executions"
|
8
|
+
|
9
|
+
class CloudscrapeClient
|
10
|
+
extend Configure
|
11
|
+
|
12
|
+
NotFound = Class.new(StandardError)
|
13
|
+
InternalServerError = Class.new(StandardError)
|
14
|
+
|
15
|
+
def initialize(api_key: nil, account_id: nil)
|
16
|
+
CloudscrapeClient.configuration.api_key = api_key if api_key
|
17
|
+
CloudscrapeClient.configuration.account_id = account_id if account_id
|
18
|
+
end
|
19
|
+
|
20
|
+
def runs(id)
|
21
|
+
Runs.new(id: id)
|
22
|
+
end
|
23
|
+
|
24
|
+
def executions(id)
|
25
|
+
Executions.new(id: id)
|
26
|
+
end
|
27
|
+
end
|
@@ -4,7 +4,7 @@ require "faraday_middleware"
|
|
4
4
|
require "faraday/conductivity"
|
5
5
|
require "faraday_middleware/multi_json"
|
6
6
|
|
7
|
-
class
|
7
|
+
class CloudscrapeClient
|
8
8
|
class API
|
9
9
|
InvalidApiKey = Class.new(StandardError)
|
10
10
|
InvalidAccountId = Class.new(StandardError)
|
@@ -47,11 +47,15 @@ class CloudScrape
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def account_id
|
50
|
-
|
50
|
+
CloudscrapeClient.configuration.account_id
|
51
51
|
end
|
52
52
|
|
53
53
|
def api_key
|
54
|
-
|
54
|
+
CloudscrapeClient.configuration.api_key
|
55
|
+
end
|
56
|
+
|
57
|
+
def user_agent_version
|
58
|
+
CloudscrapeClient.configuration.user_agent_version
|
55
59
|
end
|
56
60
|
|
57
61
|
# rubocop:disable Metrics/AbcSize
|
@@ -61,8 +65,8 @@ class CloudScrape
|
|
61
65
|
faraday.request :url_encoded
|
62
66
|
|
63
67
|
faraday.request :user_agent,
|
64
|
-
app:
|
65
|
-
version:
|
68
|
+
app: CloudscrapeClient.configuration.user_agent_app,
|
69
|
+
version: user_agent_version
|
66
70
|
|
67
71
|
faraday.request :request_headers,
|
68
72
|
accept: "application/json",
|
@@ -70,8 +74,8 @@ class CloudScrape
|
|
70
74
|
"X-CloudScrape-Account" => account_id,
|
71
75
|
content_type: "application/json"
|
72
76
|
|
73
|
-
if
|
74
|
-
faraday.response :logger,
|
77
|
+
if CloudscrapeClient.configuration.verbose
|
78
|
+
faraday.response :logger, CloudscrapeClient.configuration.logger
|
75
79
|
end
|
76
80
|
|
77
81
|
faraday.response :multi_json,
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
1
|
+
require "cloudscrape_client/api"
|
2
|
+
require "cloudscrape_client/validate"
|
3
3
|
|
4
|
-
class
|
4
|
+
class CloudscrapeClient
|
5
5
|
class DTO
|
6
6
|
attr_reader :options
|
7
7
|
|
@@ -34,7 +34,7 @@ class CloudScrape
|
|
34
34
|
api_key: api_key,
|
35
35
|
format: "json"
|
36
36
|
}.merge(params)
|
37
|
-
).tap(&
|
37
|
+
).tap(&CloudscrapeClient::Validate).body
|
38
38
|
end
|
39
39
|
|
40
40
|
def params
|
@@ -48,11 +48,11 @@ class CloudScrape
|
|
48
48
|
private
|
49
49
|
|
50
50
|
def domain
|
51
|
-
|
51
|
+
CloudscrapeClient.configuration.base_url
|
52
52
|
end
|
53
53
|
|
54
54
|
def api_key
|
55
|
-
|
55
|
+
CloudscrapeClient.configuration.api_key
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
3
|
-
require "
|
1
|
+
require "cloudscrape_client/execution_dto"
|
2
|
+
require "cloudscrape_client/executions/get"
|
3
|
+
require "cloudscrape_client/executions/result"
|
4
4
|
|
5
|
-
class
|
5
|
+
class CloudscrapeClient
|
6
6
|
class Executions
|
7
7
|
def initialize(id:)
|
8
8
|
@id = id
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class CloudscrapeClient
|
2
2
|
class Executions
|
3
3
|
class Result
|
4
4
|
attr_reader :response
|
@@ -23,7 +23,7 @@ class CloudScrape
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def rows
|
26
|
-
response.fetch(:rows, [[]]).
|
26
|
+
response.fetch(:rows, [[]]).first
|
27
27
|
end
|
28
28
|
|
29
29
|
def define_method_for_header
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class CloudscrapeClient
|
2
2
|
class Validate
|
3
3
|
def initialize(response:)
|
4
4
|
@response = response
|
@@ -13,8 +13,8 @@ class CloudScrape
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def validate
|
16
|
-
fail
|
17
|
-
fail
|
16
|
+
fail CloudscrapeClient::InternalServerError, message if internal_error?
|
17
|
+
fail CloudscrapeClient::NotFound, message if not_found?
|
18
18
|
|
19
19
|
true
|
20
20
|
end
|
@@ -23,7 +23,7 @@ class CloudScrape
|
|
23
23
|
|
24
24
|
attr_reader :response
|
25
25
|
|
26
|
-
def
|
26
|
+
def internal_error?
|
27
27
|
response.status == 500
|
28
28
|
end
|
29
29
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudscrape-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles J Hardy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -194,18 +194,19 @@ files:
|
|
194
194
|
- bin/setup
|
195
195
|
- bin/test
|
196
196
|
- cloudscrape-client-ruby.gemspec
|
197
|
-
- lib/
|
198
|
-
- lib/
|
199
|
-
- lib/
|
200
|
-
- lib/
|
201
|
-
- lib/
|
202
|
-
- lib/
|
203
|
-
- lib/
|
204
|
-
- lib/
|
205
|
-
- lib/
|
206
|
-
- lib/
|
207
|
-
- lib/
|
208
|
-
- lib/
|
197
|
+
- lib/cloudscrape/client.rb
|
198
|
+
- lib/cloudscrape_client.rb
|
199
|
+
- lib/cloudscrape_client/api.rb
|
200
|
+
- lib/cloudscrape_client/configuration.rb
|
201
|
+
- lib/cloudscrape_client/dto.rb
|
202
|
+
- lib/cloudscrape_client/execution_dto.rb
|
203
|
+
- lib/cloudscrape_client/executions.rb
|
204
|
+
- lib/cloudscrape_client/executions/get.rb
|
205
|
+
- lib/cloudscrape_client/executions/result.rb
|
206
|
+
- lib/cloudscrape_client/run_dto.rb
|
207
|
+
- lib/cloudscrape_client/runs.rb
|
208
|
+
- lib/cloudscrape_client/validate.rb
|
209
|
+
- lib/cloudscrape_client/version.rb
|
209
210
|
- postman_collection
|
210
211
|
homepage: https://github.com/cloudscrape/cloudscrape-client-ruby
|
211
212
|
licenses:
|
data/lib/cloud_scrape.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require "logger"
|
2
|
-
|
3
|
-
require "cloud_scrape/version"
|
4
|
-
require "cloud_scrape/configuration"
|
5
|
-
require "cloud_scrape/dto"
|
6
|
-
require "cloud_scrape/runs"
|
7
|
-
require "cloud_scrape/executions"
|
8
|
-
|
9
|
-
class CloudScrape
|
10
|
-
extend Configure
|
11
|
-
|
12
|
-
NotFound = Class.new(StandardError)
|
13
|
-
InternalServerError = Class.new(StandardError)
|
14
|
-
|
15
|
-
def initialize(api_key: nil, account_id: nil)
|
16
|
-
CloudScrape.configuration.api_key = api_key if api_key
|
17
|
-
CloudScrape.configuration.account_id = account_id if account_id
|
18
|
-
end
|
19
|
-
|
20
|
-
def runs(id)
|
21
|
-
Runs.new(id: id)
|
22
|
-
end
|
23
|
-
|
24
|
-
def executions(id)
|
25
|
-
Executions.new(id: id)
|
26
|
-
end
|
27
|
-
end
|
data/lib/cloud_scrape/version.rb
DELETED